|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.catalina.realm.RealmBase
com.sun.web.security.RealmAdapter
@Service @Scoped(value=org.jvnet.hk2.component.PerLookup.class) public class RealmAdapter
This is the realm adapter used to authenticate users and authorize access to web resources. The authenticate method is called by Tomcat to authenticate users. The hasRole method is called by Tomcat during the authorization process.
| Field Summary | |
|---|---|
static java.lang.String |
BASIC
|
protected static java.lang.String |
CONF_FILE_NAME
|
static java.lang.String |
FORM
|
protected static java.lang.String |
HTTP_SERVLET_LAYER
|
protected boolean |
isCurrentURIincluded
|
protected static java.lang.String |
name
Descriptive information about this Realm implementation. |
protected java.util.concurrent.locks.ReadWriteLock |
rwLock
|
static java.lang.String |
SECURITY_CONTEXT
|
protected WebSecurityManager |
webSecurityManager
A WebSecurityManager object associated with a CONTEXT_ID |
protected WebSecurityManagerFactory |
webSecurityManagerFactory
The factory used for creating WebSecurityManager object. |
| Fields inherited from class org.apache.catalina.realm.RealmBase |
|---|
checkIfRequestIsSecure, container, controller, debug, digest, digestEncoding, domain, host, info, initialized, lifecycle, md, md5Encoder, md5Helper, mserver, oname, path, sm, started, support, type, validate |
| Fields inherited from interface org.apache.catalina.Lifecycle |
|---|
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT |
| Fields inherited from interface org.apache.catalina.Realm |
|---|
AUTHENTICATE_NEEDED, AUTHENTICATE_NOT_NEEDED, AUTHENTICATED_NOT_AUTHORIZED |
| Constructor Summary | |
|---|---|
RealmAdapter()
|
|
RealmAdapter(java.lang.String realmName,
java.lang.String moduleID)
Create for WS Ejb endpoint authentication. |
|
| Method Summary | |
|---|---|
java.security.Principal |
authenticate(javax.servlet.http.HttpServletRequest hreq)
|
java.security.Principal |
authenticate(java.lang.String username,
char[] password)
Authenticates and sets the SecurityContext in the TLS. |
protected boolean |
authenticate(java.lang.String username,
char[] password,
java.security.cert.X509Certificate[] certs)
Authenticates and sets the SecurityContext in the TLS. |
boolean |
authenticate(WebPrincipal prin)
|
java.security.Principal |
authenticate(java.security.cert.X509Certificate[] certs)
|
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. |
java.security.Principal |
createFailOveredPrincipal(java.lang.String username)
This method is added to create a Principal based on the username only. |
void |
destroy()
Create the realm adapter. |
SecurityConstraint[] |
findSecurityConstraints(HttpRequest request,
Context context)
Returns null 1. |
SecurityConstraint[] |
findSecurityConstraints(java.lang.String requestPathMB,
java.lang.String httpMethod,
Context context)
Returns null 1. |
protected java.lang.String |
getName()
Return a short name for this Realm Adapter implementation. |
protected char[] |
getPassword(java.lang.String username)
|
protected java.security.Principal |
getPrincipal(java.lang.String username)
|
java.lang.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,
java.security.Principal principal,
java.lang.String role)
Check if the given principal has the provided role. |
boolean |
hasRole(java.lang.String servletName,
java.security.Principal principal,
java.lang.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,
java.lang.String uri,
java.lang.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()
|
void |
initializeRealm(java.lang.Object descriptor,
boolean isSystemApp,
java.lang.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()
Return true if a Security Extension is available. |
void |
logout()
|
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(java.security.Principal principal)
|
void |
setCurrentSecurityContextWithWebPrincipal(java.security.Principal principal)
|
void |
setRealmName(java.lang.String realmName)
|
void |
setVirtualServer(java.lang.Object container)
Sets the virtual server on which the web module (with which this RealmAdapter is associated with) has been deployed. |
void |
updateWebSecurityManager()
|
| Methods inherited from class org.apache.catalina.realm.RealmBase |
|---|
addLifecycleListener, addPropertyChangeListener, authenticate, backgroundProcess, digest, disableProxyCaching, findLifecycleListeners, getAlternateAuthType, getAlternatePrincipal, getContainer, getController, getDebug, getDigest, getDigest, getDigestEncoding, getDomain, getInfo, getObjectName, getType, getValidate, hasMessageDigest, hasRole, init, log, log, postDeregister, postRegister, preDeregister, preRegister, removeLifecycleListener, removePropertyChangeListener, setContainer, setController, setDebug, setDigest, setDigestEncoding, setRealmName, setValidate, start, stop |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SECURITY_CONTEXT
public static final java.lang.String BASIC
public static final java.lang.String FORM
protected static final java.lang.String name
protected volatile WebSecurityManager webSecurityManager
WebSecurityManager object associated with a CONTEXT_ID
protected WebSecurityManagerFactory webSecurityManagerFactory
WebSecurityManager object.
protected boolean isCurrentURIincluded
protected final java.util.concurrent.locks.ReadWriteLock rwLock
protected static final java.lang.String CONF_FILE_NAME
protected static final java.lang.String HTTP_SERVLET_LAYER
| Constructor Detail |
|---|
public RealmAdapter()
public RealmAdapter(java.lang.String realmName,
java.lang.String moduleID)
| Method Detail |
|---|
public void destroy()
destroy in class 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(java.lang.Object container)
setVirtualServer in interface RealmInitializercontainer - The virtual serverpublic WebBundleDescriptor getWebDescriptor()
public WebSecurityManager getWebSecurityManager(boolean logNull)
public void updateWebSecurityManager()
updateWebSecurityManager in interface RealmInitializer
public boolean hasRole(HttpRequest request,
HttpResponse response,
java.security.Principal principal,
java.lang.String role)
hasRole in interface RealmhasRole in class RealmBaserequest - Request we are processingresponse - Response we are creatingthe - principalthe - role
public boolean hasRole(java.lang.String servletName,
java.security.Principal principal,
java.lang.String role)
public void logout()
logout in interface RealmInitializerpublic java.security.Principal authenticate(javax.servlet.http.HttpServletRequest hreq)
authenticate in interface Realmauthenticate in class RealmBase
public java.security.Principal authenticate(java.lang.String username,
char[] password)
authenticate in interface Realmauthenticate in class RealmBasethe - user name.the - password.
public java.security.Principal authenticate(java.security.cert.X509Certificate[] certs)
authenticate in interface Realmauthenticate in class RealmBasepublic boolean authenticate(WebPrincipal prin)
protected boolean authenticate(java.lang.String username,
char[] password,
java.security.cert.X509Certificate[] certs)
the - username.the - authentication method.the - authentication data.
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(java.lang.String username)
getPassword in class RealmBaseprotected java.security.Principal getPrincipal(java.lang.String username)
getPrincipal in class RealmBasepublic java.security.Principal createFailOveredPrincipal(java.lang.String username)
username -
public boolean hasResourcePermission(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints,
Context context)
throws java.io.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.
java.io.IOException - if an input/output error occurs
public boolean hasUserDataPermission(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints)
throws java.io.IOException
hasUserDataPermission in interface RealmhasUserDataPermission in class RealmBaserequest - Request we are processingresponse - Response we are creatingconstraints - Security constraint being checked
true if this constraint was not violated and
processing should continue, or false if we have created
a response already
java.io.IOException - if an input/output error occurs
public boolean hasUserDataPermission(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints,
java.lang.String uri,
java.lang.String method)
throws java.io.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 check
java.io.IOExceptionprotected java.lang.String getName()
getName in class RealmBasepublic java.lang.String getRealmName()
getRealmName in interface RealmgetRealmName in class RealmBasepublic void setRealmName(java.lang.String realmName)
public SecurityConstraint[] findSecurityConstraints(HttpRequest request,
Context context)
findSecurityConstraints in interface RealmfindSecurityConstraints in class RealmBase
public SecurityConstraint[] findSecurityConstraints(java.lang.String requestPathMB,
java.lang.String httpMethod,
Context context)
findSecurityConstraints in interface RealmfindSecurityConstraints in class RealmBase
public int preAuthenticateCheck(HttpRequest request,
HttpResponse response,
SecurityConstraint[] constraints,
boolean disableProxyCaching,
boolean securePagesWithPragma,
boolean ssoEnabled)
throws java.io.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 enabled
java.io.IOException - if an input/output error occurs
public boolean invokeAuthenticateDelegate(HttpRequest request,
HttpResponse response,
Context context,
Authenticator authenticator,
boolean calledFromAuthenticate)
throws java.io.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.authenticantion - the current authenticator.
java.io.IOException - if an input/output error occurs
public boolean invokePostAuthenticateDelegate(HttpRequest request,
HttpResponse response,
Context context)
throws java.io.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.
java.io.IOException - if an input/output error occurspublic boolean isSecurityExtensionEnabled()
public void initializeRealm(java.lang.Object descriptor,
boolean isSystemApp,
java.lang.String realmName)
initializeRealm in interface RealmInitializer
protected void configureSecurity(WebBundleDescriptor wbd,
boolean isSystem)
public void setCurrentSecurityContextWithWebPrincipal(java.security.Principal principal)
public void setCurrentSecurityContext(java.security.Principal principal)
public void initConfigHelper()
public void postConstruct()
postConstruct in interface org.jvnet.hk2.component.PostConstruct
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||