Class OAuthServer
- Direct Known Subclasses:
BrokerOAuthServer
This class is recommended to be used in conjunction with OAuthFilter.
- Since:
- 1.3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOAuthServer(FriendStore friendStore, org.eclipse.lyo.server.oauth.core.consumer.ConsumerStore consumerStore, OAuthApplication application, Function<HttpServletRequest, OAuthHandler> handlerFactory) Creates a new instance of OAuth server. -
Method Summary
Modifier and TypeMethodDescriptionfinal OAuthApplicationReturns the OAuth application.getClientFactory(OAuthIdentity identity) Returns a factory to create anOslcClientfor the given user identity.getClientFactory(HttpServletRequest request) Returns a factory to create anOslcClientassociated to the specified request.final org.eclipse.lyo.server.oauth.core.consumer.ConsumerStoreReturns the store controlling the OAuth consumers registered for this server.final FriendProviderReturns a provider of friends, used to instantiate OAuth OSLC clients.final FriendStoreReturns the store controlling the OAuth friends registered for this server.static OAuthServerReturns the singleton instance.static voidsetInstance(OAuthServer oauthServer) Replaces the current server instance with the given one.voidVerifies the user performing the request is an administrator.
-
Constructor Details
-
OAuthServer
public OAuthServer(FriendStore friendStore, org.eclipse.lyo.server.oauth.core.consumer.ConsumerStore consumerStore, OAuthApplication application, Function<HttpServletRequest, OAuthHandler> handlerFactory) Creates a new instance of OAuth server.The given function is to create a OAuth handler managing user authorization to access remote OSLC applications, used by
OSLC client factoriescreated by this instance. The function is recommended to return an instance ofRedirectOAuthHandler.- Parameters:
friendStore- the friend store, to fetch content from remote OSLC applicationsconsumerStore- the consumer store, to control access from remote OSLC applicationsapplication- the OAuth application controlling user authenticationhandlerFactory- a function to create aOAuthHandlerfor a given incoming servlet request- Since:
- 4.0.0
- See Also:
-
-
Method Details
-
getInstance
Returns the singleton instance.- Returns:
- the singleton OAuth Server.
- Throws:
WebApplicationException- if OAuthServer instance is not set- Since:
- 3.8.0
- See Also:
-
setInstance
Replaces the current server instance with the given one.- Parameters:
oauthServer- the new server instance- Since:
- 3.8.0
-
getFriendStore
Returns the store controlling the OAuth friends registered for this server.- Returns:
- the friend store.
-
getFriendProvider
Returns a provider of friends, used to instantiate OAuth OSLC clients.- Returns:
- a provider of friends for OAuth OSLC clients.
- See Also:
-
getConsumerStore
public final org.eclipse.lyo.server.oauth.core.consumer.ConsumerStore getConsumerStore()Returns the store controlling the OAuth consumers registered for this server.- Returns:
- the consumer store.
-
getApplication
Returns the OAuth application.- Returns:
- the OAuth application
- Since:
- 4.0.0
-
getClientFactory
Returns a factory to create anOslcClientassociated to the specified request.The factory is stored in the request attributes, so that it's reused on a successive calls. The factory creates clients that can be safely used in concurrent threads.
The factory uses the friends configured in the friend store of this server instance. It uses the
OAuthHandlerprovided by this server instance to handle user authorization.- Parameters:
request- the servlet request.- Returns:
- a factory to create
OslcClientinstances. - See Also:
-
getClientFactory
Returns a factory to create anOslcClientfor the given user identity. This factory can be used when no HTTP incoming request is known. If a request is accessible, prefer usinggetClientFactory(HttpServletRequest)which provides more features.This factory is limited to existing OAuth tokens yet acquired for the given user identity, through
getClientFactory(HttpServletRequest)in regular OSLC flows. It implies outgoing requests executed with OSLC clients built with this factory will be rejected with HTTP 401, if there's not yet a valid OAuth token for the given friend application.The factory creates clients that can be safely used in concurrent threads.
- Parameters:
identity- the user identity for which OAuth tokens were acquired- Returns:
- a factory to create
OslcClientinstances. - Since:
- 3.8.0
-
validateAdministratorAccess
Verifies the user performing the request is an administrator. Throws aWebApplicationExceptionif the current user is not an administrator.- Parameters:
request- the request which requires administrator access.- Throws:
WebApplicationException- if the current user is not an administrator.
-