@Service
@PerLookup
public class RealmAdapter
extends org.apache.catalina.realm.RealmBase
implements com.sun.enterprise.security.integration.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 com.sun.enterprise.security.web.integration.WebSecurityManager |
webSecurityManager
A
WebSecurityManager object associated with a CONTEXT_ID |
protected com.sun.enterprise.security.web.integration.WebSecurityManagerFactory |
webSecurityManagerFactory
The factory used for creating
WebSecurityManager object. |
checkIfRequestIsSecure, container, controller, debug, digest, digestEncoding, info, lifecycle, log, md, sha256Helper, started, support, validate| 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) |
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(com.sun.enterprise.security.web.integration.WebPrincipal prin) |
Principal |
authenticate(X509Certificate[] certs) |
protected void |
configureSecurity(com.sun.enterprise.deployment.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()
Create the realm adapter.
|
org.apache.catalina.deploy.SecurityConstraint[] |
findSecurityConstraints(org.apache.catalina.HttpRequest request,
org.apache.catalina.Context context)
Returns null
1.
|
org.apache.catalina.deploy.SecurityConstraint[] |
findSecurityConstraints(String requestPathMB,
String httpMethod,
org.apache.catalina.Context context)
Returns null
1.
|
protected String |
getName()
Return a short name for this Realm Adapter implementation.
|
protected char[] |
getPassword(String username) |
protected Principal |
getPrincipal(String username) |
String |
getRealmName()
Return the name of the realm this RealmAdapter uses.
|
com.sun.enterprise.deployment.WebBundleDescriptor |
getWebDescriptor() |
com.sun.enterprise.security.web.integration.WebSecurityManager |
getWebSecurityManager(boolean logNull) |
boolean |
hasResourcePermission(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints,
org.apache.catalina.Context context)
Perform access control based on the specified authorization constraint.
|
boolean |
hasRole(org.apache.catalina.HttpRequest request,
org.apache.catalina.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(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints)
Enforce any user data constraint required by the security constraint
guarding this request URI.
|
boolean |
hasUserDataPermission(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.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(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.Context context,
org.apache.catalina.Authenticator authenticator,
boolean calledFromAuthenticate)
Authenticates the user making this request, based on the specified
login configuration.
|
boolean |
invokePostAuthenticateDelegate(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.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() |
void |
logout(org.apache.catalina.HttpRequest req) |
void |
postConstruct() |
void |
postSetRunAsIdentity(org.glassfish.api.invocation.ComponentInvocation inv)
Attempts to restore old SecurityContext (but fails).
|
int |
preAuthenticateCheck(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints,
boolean disableProxyCaching,
boolean securePagesWithPragma,
boolean ssoEnabled)
Checks whether or not authentication is needed.
|
void |
preSetRunAsIdentity(org.glassfish.api.invocation.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 com.sun.enterprise.security.web.integration.WebSecurityManager webSecurityManager
WebSecurityManager object associated with a CONTEXT_ID@Inject protected com.sun.enterprise.security.web.integration.WebSecurityManagerFactory webSecurityManagerFactory
WebSecurityManager object.protected boolean isCurrentURIincluded
protected final ReadWriteLock rwLock
protected static final String CONF_FILE_NAME
protected static final String HTTP_SERVLET_LAYER
public void destroy()
destroy in class org.apache.catalina.realm.RealmBasethe - web bundle deployment descriptor.isSystemApp - if the app is a system app.realmName - The realm name to use if the app does not specify its
own
public RealmAdapter(WebBundleDescriptor descriptor,
boolean isSystemApp,
String realmName) {
this.isSystemApp = isSystemApp;
webDesc = descriptor;
Application app = descriptor.getApplication();
mapper = app.getRoleMapper();
LoginConfiguration loginConfig = descriptor.getLoginConfiguration();
_realmName = app.getRealm();
if (_realmName == null && loginConfig != null) {
_realmName = loginConfig.getRealmName();
}
if (realmName != null && (_realmName == null || _realmName.equals(""))) {
_realmName = realmName;
}
// BEGIN IASRI 4747594
CONTEXT_ID = WebSecurityManager.getContextID(descriptor);
runAsPrincipals = new HashMap();
Iterator bundle = webDesc.getWebComponentDescriptors().iterator();
while (bundle.hasNext()) {
WebComponentDescriptor wcd = (WebComponentDescriptor) bundle.next();
RunAsIdentityDescriptor runAsDescriptor = wcd.getRunAsIdentity();
if (runAsDescriptor != null) {
String principal = runAsDescriptor.getPrincipal();
String servlet = wcd.getCanonicalName();
if (principal == null || servlet == null) {
_logger.warning("web.realmadapter.norunas");
} else {
runAsPrincipals.put(servlet, principal);
_logger.fine("Servlet " + servlet +
" will run-as: " + principal);
}
}
}
// END IASRI 4747594
this.appID = app.getRegistrationName();
// helper are set until setVirtualServer is invoked
}public void setVirtualServer(Object container)
setVirtualServer in interface com.sun.enterprise.security.integration.RealmInitializercontainer - The virtual serverpublic com.sun.enterprise.deployment.WebBundleDescriptor getWebDescriptor()
public com.sun.enterprise.security.web.integration.WebSecurityManager getWebSecurityManager(boolean logNull)
public void updateWebSecurityManager()
updateWebSecurityManager in interface com.sun.enterprise.security.integration.RealmInitializerpublic boolean hasRole(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
Principal principal,
String role)
hasRole in interface org.apache.catalina.RealmhasRole in class org.apache.catalina.realm.RealmBaserequest - Request we are processingresponse - Response we are creatingthe - principalthe - rolepublic void logout(org.apache.catalina.HttpRequest req)
logout in interface org.apache.catalina.Realmlogout in class org.apache.catalina.realm.RealmBasepublic void logout()
logout in interface com.sun.enterprise.security.integration.RealmInitializerpublic Principal authenticate(javax.servlet.http.HttpServletRequest hreq)
authenticate in interface org.apache.catalina.Realmauthenticate in class org.apache.catalina.realm.RealmBasepublic Principal authenticate(String username, char[] password)
authenticate in interface org.apache.catalina.Realmauthenticate in class org.apache.catalina.realm.RealmBasethe - user name.the - password.public Principal authenticate(X509Certificate[] certs)
authenticate in interface org.apache.catalina.Realmauthenticate in class org.apache.catalina.realm.RealmBasepublic boolean authenticate(com.sun.enterprise.security.web.integration.WebPrincipal prin)
protected boolean authenticate(String username, char[] password, X509Certificate[] certs)
the - username.the - authentication method.the - authentication data.public void preSetRunAsIdentity(org.glassfish.api.invocation.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(org.glassfish.api.invocation.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)
getPassword in class org.apache.catalina.realm.RealmBaseprotected Principal getPrincipal(String username)
getPrincipal in class org.apache.catalina.realm.RealmBasepublic Principal createFailOveredPrincipal(String username)
username - public boolean hasResourcePermission(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints,
org.apache.catalina.Context context)
throws IOException
true if this constraint is satisfied and processing
should continue, or false otherwise.hasResourcePermission in interface org.apache.catalina.RealmhasResourcePermission in class org.apache.catalina.realm.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(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints)
throws IOException
hasUserDataPermission in interface org.apache.catalina.RealmhasUserDataPermission in class org.apache.catalina.realm.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(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints,
String uri,
String method)
throws IOException
hasUserDataPermission in interface org.apache.catalina.RealmhasUserDataPermission in class org.apache.catalina.realm.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()
getName in class org.apache.catalina.realm.RealmBasepublic String getRealmName()
getRealmName in interface org.apache.catalina.RealmgetRealmName in class org.apache.catalina.realm.RealmBasepublic void setRealmName(String realmName)
public org.apache.catalina.deploy.SecurityConstraint[] findSecurityConstraints(org.apache.catalina.HttpRequest request,
org.apache.catalina.Context context)
findSecurityConstraints in interface org.apache.catalina.RealmfindSecurityConstraints in class org.apache.catalina.realm.RealmBasepublic org.apache.catalina.deploy.SecurityConstraint[] findSecurityConstraints(String requestPathMB, String httpMethod, org.apache.catalina.Context context)
findSecurityConstraints in interface org.apache.catalina.RealmfindSecurityConstraints in class org.apache.catalina.realm.RealmBasepublic int preAuthenticateCheck(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.deploy.SecurityConstraint[] constraints,
boolean disableProxyCaching,
boolean securePagesWithPragma,
boolean ssoEnabled)
throws IOException
preAuthenticateCheck in interface org.apache.catalina.RealmpreAuthenticateCheck in class org.apache.catalina.realm.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(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.Context context,
org.apache.catalina.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 org.apache.catalina.RealminvokeAuthenticateDelegate in class org.apache.catalina.realm.RealmBaserequest - Request we are processingresponse - Response we are creatingcontext - The Context to which client of this class is attached.authenticantion - the current authenticator.IOException - if an input/output error occurspublic boolean invokePostAuthenticateDelegate(org.apache.catalina.HttpRequest request,
org.apache.catalina.HttpResponse response,
org.apache.catalina.Context context)
throws IOException
invokePostAuthenticateDelegate in interface org.apache.catalina.RealminvokePostAuthenticateDelegate in class org.apache.catalina.realm.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 org.apache.catalina.RealmisSecurityExtensionEnabled in class org.apache.catalina.realm.RealmBasepublic void initializeRealm(Object descriptor, boolean isSystemApp, String realmName)
initializeRealm in interface com.sun.enterprise.security.integration.RealmInitializerprotected void configureSecurity(com.sun.enterprise.deployment.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–2019 Eclipse Foundation. All rights reserved.