Package com.sodius.oslc.server.oauth
Class OAuthServer
- java.lang.Object
-
- com.sodius.oslc.server.oauth.OAuthServer
-
public abstract class OAuthServer extends Object
The central place for OAuth capabilities provided on server side.This class is recommended to be used in conjunction with
OAuthFilter
.- Since:
- 1.3.0
- See Also:
OAuthFilter
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OAuthServer(ServletContext context)
Creates a new instance of the specified servlet context.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract org.eclipse.lyo.server.oauth.core.consumer.ConsumerStore
createConsumerStore(ServletContext context)
Creates the store that manages the registered OAuth consumers.protected abstract FriendStore
createFriendStore(ServletContext context)
Creates the store that manages the registered OAuth friends.protected abstract OAuthHandler
createOAuthHandler(HttpServletRequest request)
Creates a handler to manage user authorization to access remote OSLC applications.OslcClientFactory
getClientFactory(HttpServletRequest request)
Returns a factory to create anOslcClient
associated to the specified request.org.eclipse.lyo.server.oauth.core.consumer.ConsumerStore
getConsumerStore()
Returns the store controlling the OAuth consumers registered for this server.FriendProvider
getFriendProvider()
Returns a provider of friends, used to instantiate OAuth OSLC clients.FriendStore
getFriendStore()
Returns the store controlling the OAuth friends registered for this server.static OAuthServer
getInstance(ServletContext context)
Returns the singleton instance configured for the specified servlet context.void
validateAdministratorAccess(HttpServletRequest request)
Verifies the user performing the request is an administrator.
-
-
-
Constructor Detail
-
OAuthServer
protected OAuthServer(ServletContext context)
Creates a new instance of the specified servlet context.- Parameters:
context
- the servlet context.
-
-
Method Detail
-
getInstance
public static OAuthServer getInstance(ServletContext context)
Returns the singleton instance configured for the specified servlet context. This method can safely be called once OAuthFilter has been initialized.- Parameters:
context
- the servlet context.- Returns:
- the singleton OAuth Server.
- See Also:
OAuthFilter
-
getFriendStore
public final FriendStore getFriendStore()
Returns the store controlling the OAuth friends registered for this server.- Returns:
- the friend store.
-
createFriendStore
protected abstract FriendStore createFriendStore(ServletContext context)
Creates the store that manages the registered OAuth friends.- Parameters:
context
- the servlet context.- Returns:
- the created store.
-
getFriendProvider
public final FriendProvider getFriendProvider()
Returns a provider of friends, used to instantiate OAuth OSLC clients.- Returns:
- a provider of friends for OAuth OSLC clients.
- See Also:
OAuthStore
-
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.
-
createConsumerStore
protected abstract org.eclipse.lyo.server.oauth.core.consumer.ConsumerStore createConsumerStore(ServletContext context)
Creates the store that manages the registered OAuth consumers.- Parameters:
context
- the servlet context.- Returns:
- the created store.
-
getClientFactory
public OslcClientFactory getClientFactory(HttpServletRequest request)
Returns a factory to create anOslcClient
associated 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
OAuthHandler
provided by this server instance to handle user authorization.- Parameters:
request
- the servlet request.- Returns:
- a factory to create
OslcClient
instances. - See Also:
getFriendProvider()
,createOAuthHandler(HttpServletRequest)
-
createOAuthHandler
protected abstract OAuthHandler createOAuthHandler(HttpServletRequest request)
Creates a handler to manage user authorization to access remote OSLC applications. The handler is used by the OSLC client factory provided by this server instance to access remote applications.Subclasses are recommended to create a
RedirectOAuthHandler
instance.- Parameters:
request
- the servlet request- Returns:
- a
OAuthHandler
to manage user authorization to access remote OSLC applications. - See Also:
getClientFactory(HttpServletRequest)
,RedirectOAuthHandler
-
validateAdministratorAccess
public void validateAdministratorAccess(HttpServletRequest request)
Verifies the user performing the request is an administrator. Throws aWebApplicationException
if 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.
-
-