@Service @PerLookup public class RealmAdapter extends RealmBase implements RealmInitializer, org.glassfish.hk2.api.PostConstruct
| Modifier and Type | Field and Description |
|---|---|
static String |
BASIC |
protected static String |
CONF_FILE_NAME |
static String |
FORM |
protected static String |
HTTP_SERVLET_LAYER |
protected boolean |
isCurrentURIincluded |
protected static String |
name
Descriptive information about this Realm implementation.
|
protected ReadWriteLock |
rwLock |
static String |
SECURITY_CONTEXT |
protected WebSecurityManager |
webSecurityManager
A
WebSecurityManager object associated with a CONTEXT_ID |
protected WebSecurityManagerFactory |
webSecurityManagerFactory
The factory used for creating
WebSecurityManager object. |
checkIfRequestIsSecure, container, controller, debug, digest, digestEncoding, info, lifecycle, log, md, md5Encoder, md5Helper, started, support, validateAFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENTAUTHENTICATE_NEEDED, AUTHENTICATE_NOT_NEEDED, AUTHENTICATED_NOT_AUTHORIZED| Constructor and Description |
|---|
RealmAdapter() |
RealmAdapter(String realmName,
String moduleID)
Create for WS Ejb endpoint authentication.
|
| Modifier and Type | Method and Description |
|---|---|
Principal |
authenticate(javax.servlet.http.HttpServletRequest hreq)
Does digest authentication and returns the Principal associated with the username in the
HTTP header.
|
Principal |
authenticate(String username,
char[] password)
Authenticates and sets the SecurityContext in the TLS.
|
protected boolean |
authenticate(String username,
char[] password,
X509Certificate[] certs)
Authenticates and sets the SecurityContext in the TLS.
|
boolean |
authenticate(WebPrincipal prin) |
Principal |
authenticate(X509Certificate[] certs)
Return the Principal associated with the specified chain of X509
client certificates.
|
protected void |
configureSecurity(WebBundleDescriptor wbd,
boolean isSystem)
Generate the JSR 115 policy file for a web application, bundled
within a ear or deployed as a standalone war file.
|
Principal |
createFailOveredPrincipal(String username)
This method is added to create a Principal based on the username only.
|
void |
destroy() |
SecurityConstraint[] |
findSecurityConstraints(HttpRequest request,
Context context)
Returns null
1.
|
SecurityConstraint[] |
findSecurityConstraints(String requestPathMB,
String httpMethod,
Context context)
Returns null
1.
|
protected String |
getName()
Return a short name for this Realm Adapter implementation.
|
protected char[] |
getPassword(String username)
Return the password associated with the given principal's user name.
|
protected Principal |
getPrincipal(String username)
Return the Principal associated with the given user name.
|
String |
getRealmName()
Return the name of the realm this RealmAdapter uses.
|
WebBundleDescriptor |
getWebDescriptor() |
WebSecurityManager |
getWebSecurityManager(boolean logNull) |
boolean |
hasResourcePermission(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints,
Context context)
Perform access control based on the specified authorization constraint.
|
boolean |
hasRole(HttpRequest request,
HttpResponse response,
Principal principal,
String role)
Check if the given principal has the provided role.
|
boolean |
hasRole(String servletName,
Principal principal,
String role) |
boolean |
hasUserDataPermission(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints)
Enforce any user data constraint required by the security constraint
guarding this request URI.
|
boolean |
hasUserDataPermission(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints,
String uri,
String method)
Checks if the given request URI and method are the target of any
user-data-constraint with a transport-guarantee of CONFIDENTIAL,
and whether any such constraint is already satisfied.
|
void |
initConfigHelper(javax.servlet.ServletContext servletContext) |
void |
initializeRealm(Object descriptor,
boolean isSystemApp,
String realmName) |
boolean |
invokeAuthenticateDelegate(HttpRequest request,
HttpResponse response,
Context context,
Authenticator authenticator,
boolean calledFromAuthenticate)
Authenticates the user making this request, based on the specified
login configuration.
|
boolean |
invokePostAuthenticateDelegate(HttpRequest request,
HttpResponse response,
Context context)
Post authentication for given request and response.
|
boolean |
isSecurityExtensionEnabled(javax.servlet.ServletContext context)
Return true if a Security Extension is available.
|
void |
logout()
Clean up security and policy context.
|
void |
logout(HttpRequest req)
Logs out.
|
void |
postConstruct() |
void |
postSetRunAsIdentity(ComponentInvocation inv)
Attempts to restore old SecurityContext (but fails).
|
int |
preAuthenticateCheck(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints,
boolean disableProxyCaching,
boolean securePagesWithPragma,
boolean ssoEnabled)
Checks whether or not authentication is needed.
|
void |
preSetRunAsIdentity(ComponentInvocation inv)
Set the run-as principal into the SecurityContext when needed.
|
void |
setCurrentSecurityContext(Principal principal) |
void |
setCurrentSecurityContextWithWebPrincipal(Principal principal) |
void |
setRealmName(String realmName) |
void |
setVirtualServer(Object container)
Sets the virtual server on which the web module (with which this
RealmAdapter is associated with) has been deployed.
|
void |
updateWebSecurityManager() |
addLifecycleListener, addPropertyChangeListener, authenticate, backgroundProcess, digest, disableProxyCaching, findLifecycleListeners, getAlternateAuthType, getAlternatePrincipal, getContainer, getController, getDebug, getDigest, getDigest, getDigestEncoding, getInfo, getValidate, hasMessageDigest, hasRole, log, log, removeLifecycleListener, removePropertyChangeListener, setContainer, setController, setDebug, setDigest, setDigestEncoding, setRealmName, setValidate, start, stoppublic static final String SECURITY_CONTEXT
public static final String BASIC
public static final String FORM
protected static final String name
protected volatile WebSecurityManager webSecurityManager
WebSecurityManager object associated with a CONTEXT_IDprotected boolean isCurrentURIincluded
protected final ReadWriteLock rwLock
@Inject protected WebSecurityManagerFactory webSecurityManagerFactory
WebSecurityManager object.protected static final String CONF_FILE_NAME
protected static final String HTTP_SERVLET_LAYER
public void setVirtualServer(Object container)
setVirtualServer in interface RealmInitializercontainer - The virtual serverpublic WebBundleDescriptor getWebDescriptor()
public WebSecurityManager getWebSecurityManager(boolean logNull)
public void updateWebSecurityManager()
updateWebSecurityManager in interface RealmInitializerpublic boolean hasRole(HttpRequest request, HttpResponse response, Principal principal, String role)
public void logout(HttpRequest req)
Realmpublic void logout()
RealmInitializerlogout in interface RealmInitializerpublic Principal authenticate(javax.servlet.http.HttpServletRequest hreq)
Realmauthenticate in interface Realmauthenticate in class RealmBasehreq - HTTP servlet request.public Principal authenticate(String username, char[] password)
authenticate in interface Realmauthenticate in class RealmBaseusername - the user name.password - the password.public Principal authenticate(X509Certificate[] certs)
RealmBasenull.authenticate in interface Realmauthenticate in class RealmBasecerts - Array of client certificates, with the first one in
the array being the certificate of the client itself.public boolean authenticate(WebPrincipal prin)
protected boolean authenticate(String username, char[] password, X509Certificate[] certs)
username - the username .password - the password.certs - Certificate Array.public void preSetRunAsIdentity(ComponentInvocation inv)
This method will attempt to obtain the name of the servlet from the ComponentInvocation. Note that there may not be one since this gets called also during internal processing (not clear..) not just part of servlet requests. However, if it is not a servlet request there is no need (or possibility) to have a run-as setting so no further action is taken.
If the servlet name is present the runAsPrincipals cache is checked to find the run-as principal to use (if any). If one is set, the SecurityContext is switched to this principal.
inv - The invocation object to process.public void postSetRunAsIdentity(ComponentInvocation inv)
In theory this method seems to attempt to check if a run-as principal was set by preSetRunAsIdentity() (based on the indirect assumption that if the servlet in the given invocation has a run-as this must've been the case). If so, it retrieves the oldSecurityContext from the invocation object and set it in the SecurityContext.
The problem is that the invocation object is not the same object as was passed in to preSetRunAsIdentity() so it will never contain the right info - see bug 4757733.
In practice it means this method only ever sets the SecurityContext to null (if run-as matched) or does nothing. In particular note the implication that it will be set to null after a run-as invocation completes. This behavior will be retained for the time being for consistency with RI. It must be fixed later.
inv - The invocation object to process.protected char[] getPassword(String username)
RealmBasegetPassword in class RealmBaseprotected Principal getPrincipal(String username)
RealmBasegetPrincipal in class RealmBasepublic Principal createFailOveredPrincipal(String username)
username - public boolean hasResourcePermission(HttpRequest request, HttpResponse response, SecurityConstraint[] constraints, Context context) throws IOException
true if this constraint is satisfied and processing
should continue, or false otherwise.hasResourcePermission in interface RealmhasResourcePermission in class RealmBaserequest - Request we are processingresponse - Response we are creatingconstraint - Security constraint we are enforcingThe - Context to which client of this class is attached.IOException - if an input/output error occurspublic boolean hasUserDataPermission(HttpRequest request, HttpResponse response, SecurityConstraint[] constraints) throws IOException
hasUserDataPermission in interface RealmhasUserDataPermission in class RealmBaserequest - Request we are processingresponse - Response we are creatingconstraints - Security constraint being checkedtrue if this constraint was not violated and
processing should continue, or false if we have created
a response alreadyIOException - if an input/output error occurspublic boolean hasUserDataPermission(HttpRequest request, HttpResponse response, SecurityConstraint[] constraints, String uri, String method) throws IOException
hasUserDataPermission in interface RealmhasUserDataPermission in class RealmBaserequest - the request that may be redirectedresponse - the response that may be redirectedconstraints - the security constraints to check againsturi - the request URI (minus the context path) to checkmethod - the request method to checkIOExceptionprotected String getName()
public String getRealmName()
getRealmName in interface RealmgetRealmName in class RealmBasepublic void setRealmName(String realmName)
public SecurityConstraint[] findSecurityConstraints(HttpRequest request, Context context)
findSecurityConstraints in interface RealmfindSecurityConstraints in class RealmBaserequest - Request we are processingcontext - Context the Request is mapped topublic SecurityConstraint[] findSecurityConstraints(String requestPathMB, String httpMethod, Context context)
findSecurityConstraints in interface RealmfindSecurityConstraints in class RealmBaserequestPathMB - the request URI (minus the context Path)httpMethod - the request methodcontext - the contextpublic int preAuthenticateCheck(HttpRequest request, HttpResponse response, SecurityConstraint[] constraints, boolean disableProxyCaching, boolean securePagesWithPragma, boolean ssoEnabled) throws IOException
preAuthenticateCheck in interface RealmpreAuthenticateCheck in class RealmBaserequest - Request we are processingresponse - Response we are creatingconstraints - Security constraint we are enforcingdisableProxyCaching - whether or not to disable proxy caching for
protected resources.securePagesWithPragma - true if we add headers which
are incompatible with downloading office documents in IE under SSL but
which fix a caching problem in Mozilla.ssoEnabled - true if sso is enabledIOException - if an input/output error occurspublic boolean invokeAuthenticateDelegate(HttpRequest request, HttpResponse response, Context context, Authenticator authenticator, boolean calledFromAuthenticate) throws IOException
true if any specified
requirements have been satisfied, or false if we have
created a response challenge already.invokeAuthenticateDelegate in interface RealminvokeAuthenticateDelegate in class RealmBaserequest - Request we are processingresponse - Response we are creatingcontext - The Context to which client of this class is attached.authenticator - the current authenticator.calledFromAuthenticate - IOException - if an input/output error occurspublic boolean invokePostAuthenticateDelegate(HttpRequest request, HttpResponse response, Context context) throws IOException
invokePostAuthenticateDelegate in interface RealminvokePostAuthenticateDelegate in class RealmBaserequest - Request we are processingresponse - Response we are creatingcontext - The Context to which client of this class is attached.IOException - if an input/output error occurspublic boolean isSecurityExtensionEnabled(javax.servlet.ServletContext context)
isSecurityExtensionEnabled in interface RealmisSecurityExtensionEnabled in class RealmBasecontext - the ServletContextpublic void initializeRealm(Object descriptor, boolean isSystemApp, String realmName)
initializeRealm in interface RealmInitializerprotected void configureSecurity(WebBundleDescriptor wbd, boolean isSystem)
public void setCurrentSecurityContextWithWebPrincipal(Principal principal)
public void setCurrentSecurityContext(Principal principal)
public void initConfigHelper(javax.servlet.ServletContext servletContext)
public void postConstruct()
postConstruct in interface org.glassfish.hk2.api.PostConstructCopyright © 2017. All rights reserved.