Class OAuthFilter
java.lang.Object
com.sodius.oslc.server.services.HttpFilter
com.sodius.oslc.server.oauth.services.OAuthFilter
- All Implemented Interfaces:
Filter
A filter that uses
OAuthServer to ensure requests requiring restricted access are authenticated. Possible authentications are:
- OAuth - check for valid Access token or perform the OAuth dance
- Basic - check for valid user credentials
- Session - if no Authorization header on the request, use the OAuthIdentity from the HTTP session, if any
com.sodius.oslc.server.accessControl extension point
to indicate servlet paths that require authentication of those which can be freely accessed.
If the OSLC provider application does not run in an OSGi container, the access control should be done by overriding the
isProtected(HttpServletRequest request) method.
- Since:
- 1.3.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) If the servlet being accessed requires user authentication, this filter performs the authentication challenge.protected Optional<OAuthIdentity>getLoggedInUser(HttpServletRequest request) Gets the identity of the user currently logged in the application,nullif none is found.protected booleanisProtected(HttpServletRequest request) Determines whether a request URI requires user authentication.Methods inherited from class com.sodius.oslc.server.services.HttpFilter
destroy, doFilter, handleOslcError, init
-
Constructor Details
-
OAuthFilter
public OAuthFilter()
-
-
Method Details
-
isProtected
Determines whether a request URI requires user authentication.This is a default implementation that requires an OSGi container, and is based on the
com.sodius.oslc.server.accessControlextension point.- Parameters:
request- the HTTP servlet request- Returns:
- true if the request requires an authentication, false otherwise
- Since:
- 1.8.0
-
doFilter
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException If the servlet being accessed requires user authentication, this filter performs the authentication challenge.An OSLC provider application can register extensions of the
com.sodius.oslc.server.accessControlextension point to indicate servlet paths that require authentication of those which can be freely accessed.- Specified by:
doFilterin classHttpFilter- Parameters:
request- the request.response- the response.chain- the filter chain to process.- Throws:
IOException- if an I/O error occurs.ServletException- if the filter execution fails.
-
getLoggedInUser
Gets the identity of the user currently logged in the application,nullif none is found.- Parameters:
request- the HTTP request- Returns:
- the logged-in user identity
- Since:
- 2.1.0
-