Package com.sodius.oslc.server.oauth
Class AbstractOAuthApplication
java.lang.Object
com.sodius.oslc.server.oauth.AbstractOAuthApplication
- All Implemented Interfaces:
OAuthApplication,org.eclipse.lyo.server.oauth.core.Application
- Direct Known Subclasses:
BrokerOAuthApplication
Provides a skeletal implementation of the
OAuthApplication
interface, to minimize the effort required to implement this interface.- Since:
- 1.3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTwoLeggedOAuthIdentity(HttpServletRequest request, org.eclipse.lyo.server.oauth.core.consumer.LyoOAuthConsumer consumer) Gets the OAuthIdentity for a consumer's functional user if it has one.protected abstract booleanisAdminSession(OAuthIdentity identity) Determines whether the given identity has administration privileges.booleanisAdminSession(HttpServletRequest request) Returnstrueif theOAuthIdentityinstance associated to this request by theOAuthFilterclass was granted administrator privilege, meaning the connected user is an administrator.booleanisAuthenticated(HttpServletRequest request) Returnstrueif anOAuthIdentityinstance has been associated to this request by theOAuthFilterclass, meaning the user has successfully authenticated.voidlogin(HttpServletRequest request, String userName, String password) If login is successful, associates the createdOAuthIdentityinstance to the request.protected abstract OAuthIdentitylogin(HttpServletRequest request, org.apache.http.auth.Credentials credentials) Authenticates with the application and returns anOAuthIdentityinstance representing the connected user.voidsendUnauthorized(HttpServletRequest request, HttpServletResponse response) SendsWWW-Authenticateheader forOAuthauthorization.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.lyo.server.oauth.core.Application
getName, getRealmMethods inherited from interface com.sodius.oslc.server.oauth.OAuthApplication
getLoginUri, logout
-
Constructor Details
-
AbstractOAuthApplication
public AbstractOAuthApplication()
-
-
Method Details
-
isAuthenticated
Returnstrueif anOAuthIdentityinstance has been associated to this request by theOAuthFilterclass, meaning the user has successfully authenticated.- Specified by:
isAuthenticatedin interfaceorg.eclipse.lyo.server.oauth.core.Application- See Also:
-
isAdminSession
Returnstrueif theOAuthIdentityinstance associated to this request by theOAuthFilterclass was granted administrator privilege, meaning the connected user is an administrator.- Specified by:
isAdminSessionin interfaceorg.eclipse.lyo.server.oauth.core.Application
-
isAdminSession
Determines whether the given identity has administration privileges.- Parameters:
identity- the given identity representing thecurrent instance.- Returns:
trueif the identity has administration privileges;falseotherwise.- Since:
- 4.0.0
-
login
public void login(HttpServletRequest request, String userName, String password) throws org.eclipse.lyo.server.oauth.core.AuthenticationException If login is successful, associates the createdOAuthIdentityinstance to the request.- Specified by:
loginin interfaceorg.eclipse.lyo.server.oauth.core.Application- Throws:
org.eclipse.lyo.server.oauth.core.AuthenticationException- See Also:
-
login
protected abstract OAuthIdentity login(HttpServletRequest request, org.apache.http.auth.Credentials credentials) throws org.eclipse.lyo.server.oauth.core.utils.UnauthorizedException Authenticates with the application and returns anOAuthIdentityinstance representing the connected user.- Parameters:
request- the servlet request.credentials- the credentials entered by the user trying to authenticate.- Returns:
- an
OAuthIdentityinstance representing the connected user. - Throws:
org.eclipse.lyo.server.oauth.core.utils.UnauthorizedException- if the authentication failed.
-
sendUnauthorized
public void sendUnauthorized(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException SendsWWW-Authenticateheader forOAuthauthorization.Sends
WWW-Authenticateheader forBasicauthorization, if the request has no Referer (i.e. is not made from a browser).- Specified by:
sendUnauthorizedin interfaceOAuthApplication- Parameters:
request- the servlet request.response- the servlet response.- Throws:
IOException- if an error occurs while writing the response.ServletException- if an error occurs while producing the response.- See Also:
-
getTwoLeggedOAuthIdentity
public Optional<OAuthIdentity> getTwoLeggedOAuthIdentity(HttpServletRequest request, org.eclipse.lyo.server.oauth.core.consumer.LyoOAuthConsumer consumer) throws org.eclipse.lyo.server.oauth.core.utils.UnauthorizedException Description copied from interface:OAuthApplicationGets the OAuthIdentity for a consumer's functional user if it has one.- Specified by:
getTwoLeggedOAuthIdentityin interfaceOAuthApplication- Parameters:
request- the servlet request.consumer- the consumer used for two legged OAuth.- Returns:
- an
OAuthIdentityrepresenting the functional user associated to the consumer,Optional.empty()if no functional user is associated to the consumer. - Throws:
org.eclipse.lyo.server.oauth.core.utils.UnauthorizedException- if a functional user is associated to the consumer but this user cannot be found
-