public class RequiresAuthenticationHandler extends SessionAwareHandler
Wrapper handler acting as a security barrier. If the user is authenticated, the next handler in the chain is called. Otherwise the user is redirected to the pac4j client security provider if stateful or an unauthorized response is sent if stateless.
The pac4j client to use is selected with the clientName attributes.
sessionHelper
Constructor and Description |
---|
RequiresAuthenticationHandler(String clientName,
boolean isAjax,
org.vertx.java.core.Handler<org.vertx.java.core.http.HttpServerRequest> delegate,
Pac4jHelper pac4jHelper,
SessionHelper sessionHelper) |
RequiresAuthenticationHandler(String clientName,
org.vertx.java.core.Handler<org.vertx.java.core.http.HttpServerRequest> delegate,
Pac4jHelper pac4jHelper,
boolean stateless) |
RequiresAuthenticationHandler(String clientName,
org.vertx.java.core.Handler<org.vertx.java.core.http.HttpServerRequest> delegate,
Pac4jHelper pac4jHelper,
SessionHelper sessionHelper) |
Modifier and Type | Method and Description |
---|---|
protected void |
authenticate(org.vertx.java.core.http.HttpServerRequest req,
String sessionId,
org.vertx.java.core.json.JsonObject sessionAttributes,
org.vertx.java.core.Handler<org.vertx.java.core.eventbus.Message<org.vertx.java.core.json.JsonObject>> handler)
Authenticates the given request.
|
protected void |
authenticationFailure(org.vertx.java.core.http.HttpServerRequest req,
String sessionId,
org.vertx.java.core.json.JsonObject sessionAttributes)
Default authentication failure strategy; save the original url in session and redirects to the Identity Provider if stateful.
|
protected void |
authenticationSuccess(AuthHttpServerRequest req,
String sessionId,
org.vertx.java.core.json.JsonObject sessionAttributes)
Default authentication success strategy; forwards the request to the next handler if the user has a granted access,
sends a 403 forbidden response otherwise.
|
protected void |
doHandle(org.vertx.java.core.http.HttpServerRequest req,
String sessionId,
org.vertx.java.core.json.JsonObject sessionAttributes) |
String |
getRequireAllRoles() |
String |
getRequireAnyRole() |
protected boolean |
hasAccess(org.pac4j.core.profile.UserProfile profile,
org.vertx.java.core.http.HttpServerRequest req)
Default access strategy based on the hasAccess method from the
UserProfile . |
protected boolean |
isAjaxRequest(org.vertx.java.core.http.HttpServerRequest req)
Is the current request an Ajax request.
|
protected void |
redirectToIdentityProvider(org.vertx.java.core.http.HttpServerRequest req,
String sessionId,
org.vertx.java.core.json.JsonObject sessionAttributes)
Redirects to the configured Identity Provider.
|
protected String |
retrieveOriginalUrl(org.vertx.java.core.http.HttpServerRequest req,
org.vertx.java.core.json.JsonObject sessionAttributes) |
protected void |
retrieveUserProfile(org.vertx.java.core.http.HttpServerRequest req,
String sessionId,
org.vertx.java.core.json.JsonObject sessionAttributes,
org.vertx.java.core.Handler<org.vertx.java.core.eventbus.Message<org.vertx.java.core.json.JsonObject>> handler)
Returns the User Profile from the session if stateful or from the credentials if stateless.
|
protected void |
saveOriginalUrl(org.vertx.java.core.http.HttpServerRequest req,
org.vertx.java.core.json.JsonObject sessionAttributes)
Save the original url in session if the request is not Ajax.
|
protected void |
saveUrl(String requestedUrlToSave,
org.vertx.java.core.json.JsonObject sessionAttributes) |
protected AuthHttpServerRequest |
saveUserProfile(Object profile,
org.vertx.java.core.http.HttpServerRequest req,
org.vertx.java.core.json.JsonObject sessionAttributes)
Save User Profile in session if stateful.
|
void |
setRequireAllRoles(String requireAllRoles) |
void |
setRequireAnyRole(String requireAnyRole) |
handle, isStateless, saveSessionAttributes
public RequiresAuthenticationHandler(String clientName, org.vertx.java.core.Handler<org.vertx.java.core.http.HttpServerRequest> delegate, Pac4jHelper pac4jHelper, SessionHelper sessionHelper)
public RequiresAuthenticationHandler(String clientName, boolean isAjax, org.vertx.java.core.Handler<org.vertx.java.core.http.HttpServerRequest> delegate, Pac4jHelper pac4jHelper, SessionHelper sessionHelper)
public RequiresAuthenticationHandler(String clientName, org.vertx.java.core.Handler<org.vertx.java.core.http.HttpServerRequest> delegate, Pac4jHelper pac4jHelper, boolean stateless)
protected void doHandle(org.vertx.java.core.http.HttpServerRequest req, String sessionId, org.vertx.java.core.json.JsonObject sessionAttributes)
doHandle
in class SessionAwareHandler
protected void retrieveUserProfile(org.vertx.java.core.http.HttpServerRequest req, String sessionId, org.vertx.java.core.json.JsonObject sessionAttributes, org.vertx.java.core.Handler<org.vertx.java.core.eventbus.Message<org.vertx.java.core.json.JsonObject>> handler)
req
- the HTTP requestsessionId
- the session identifiersessionAttributes
- the session attributeshandler
- the handlerprotected void authenticate(org.vertx.java.core.http.HttpServerRequest req, String sessionId, org.vertx.java.core.json.JsonObject sessionAttributes, org.vertx.java.core.Handler<org.vertx.java.core.eventbus.Message<org.vertx.java.core.json.JsonObject>> handler)
req
- the HTTP requestsessionId
- the session identifiersessionAttributes
- the session attributeshandler
- the handlerprotected void authenticationSuccess(AuthHttpServerRequest req, String sessionId, org.vertx.java.core.json.JsonObject sessionAttributes)
req
- the HTTP requestsessionId
- the session identifiersessionAttributes
- the session attributesprotected void authenticationFailure(org.vertx.java.core.http.HttpServerRequest req, String sessionId, org.vertx.java.core.json.JsonObject sessionAttributes)
req
- the HTTP requestsessionId
- the session identifiersessionAttributes
- the session attributesprotected boolean hasAccess(org.pac4j.core.profile.UserProfile profile, org.vertx.java.core.http.HttpServerRequest req)
UserProfile
.profile
- the user profilereq
- the HTTP requestprotected AuthHttpServerRequest saveUserProfile(Object profile, org.vertx.java.core.http.HttpServerRequest req, org.vertx.java.core.json.JsonObject sessionAttributes)
HttpServerRequest
in an AuthHttpServerRequest
.profile
- the user profilereq
- the HTTP requestsessionAttributes
- the session attributesprotected void redirectToIdentityProvider(org.vertx.java.core.http.HttpServerRequest req, String sessionId, org.vertx.java.core.json.JsonObject sessionAttributes)
req
- the HTTP requestsessionId
- the session identifiersessionAttributes
- the session attributesprotected boolean isAjaxRequest(org.vertx.java.core.http.HttpServerRequest req)
req
- the HTTP requestprotected void saveOriginalUrl(org.vertx.java.core.http.HttpServerRequest req, org.vertx.java.core.json.JsonObject sessionAttributes)
req
- the HTTP requestsessionAttributes
- the session attributesprotected void saveUrl(String requestedUrlToSave, org.vertx.java.core.json.JsonObject sessionAttributes)
protected String retrieveOriginalUrl(org.vertx.java.core.http.HttpServerRequest req, org.vertx.java.core.json.JsonObject sessionAttributes)
public String getRequireAnyRole()
public void setRequireAnyRole(String requireAnyRole)
public String getRequireAllRoles()
public void setRequireAllRoles(String requireAllRoles)
Copyright © 2015. All rights reserved.