Search in sources :

Example 11 with MessagePolicy

use of javax.security.auth.message.MessagePolicy in project Payara by payara.

the class GFServerConfigProvider method getEntry.

Entry getEntry(String intercept, String id, MessagePolicy requestPolicy, MessagePolicy responsePolicy, String type) {
    // get the parsed module config and DD information
    Map<String, InterceptEntry> configMap;
    try {
        rwLock.readLock().lock();
        configMap = parser.getConfigMap();
    } finally {
        rwLock.readLock().unlock();
    }
    if (configMap == null) {
        return null;
    }
    // get the module config info for this intercept
    InterceptEntry intEntry = configMap.get(intercept);
    if (intEntry == null || intEntry.idMap == null) {
        if (logger.isLoggable(FINE)) {
            logger.fine("module config has no IDs configured for [" + intercept + "]");
        }
        return null;
    }
    // look up the DD's provider ID in the module config
    IDEntry idEntry = null;
    if (id == null || (idEntry = (IDEntry) intEntry.idMap.get(id)) == null) {
        if (logger.isLoggable(FINE)) {
            logger.fine("DD did not specify ID, " + "or DD-specified ID for [" + intercept + "] not found in config -- " + "attempting to look for default ID");
        }
        String defaultID;
        if (CLIENT.equals(type)) {
            defaultID = intEntry.defaultClientID;
        } else {
            defaultID = intEntry.defaultServerID;
        }
        idEntry = (IDEntry) intEntry.idMap.get(defaultID);
        if (idEntry == null) {
            if (logger.isLoggable(FINE)) {
                logger.fine("no default config ID for [" + intercept + "]");
            }
            return null;
        }
    }
    // check provider-type
    if (idEntry.type.indexOf(type) < 0) {
        if (logger.isLoggable(FINE)) {
            logger.fine("request type [" + type + "] does not match config type [" + idEntry.type + "]");
        }
        return null;
    }
    // check whether a policy is set
    // default;
    MessagePolicy reqP = requestPolicy != null || responsePolicy != null ? requestPolicy : idEntry.requestPolicy;
    // default;
    MessagePolicy respP = requestPolicy != null || responsePolicy != null ? responsePolicy : idEntry.responsePolicy;
    // optimization: if policy was not set, return null
    if (reqP == null && respP == null) {
        if (logger.isLoggable(FINE)) {
            logger.fine("no policy applies");
        }
        return null;
    }
    // return the configured modules with the correct policies
    Entry entry = new Entry(idEntry.moduleClassName, reqP, respP, idEntry.options);
    if (logger.isLoggable(FINE)) {
        logger.fine("getEntry for: " + intercept + " -- " + id + "\n    module class: " + entry.moduleClassName + "\n    options: " + entry.options + "\n    request policy: " + entry.requestPolicy + "\n    response policy: " + entry.responsePolicy);
    }
    return entry;
}
Also used : AuthMessagePolicy(com.sun.enterprise.security.jaspic.AuthMessagePolicy) MessagePolicy(javax.security.auth.message.MessagePolicy)

Aggregations

MessagePolicy (javax.security.auth.message.MessagePolicy)11 AuthMessagePolicy (com.sun.enterprise.security.jaspic.AuthMessagePolicy)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)2 MessageDescriptor (com.sun.enterprise.deployment.runtime.common.MessageDescriptor)2 MessageSecurityDescriptor (com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor)2 AuthMessagePolicy (com.sun.enterprise.security.jmac.AuthMessagePolicy)2 TargetPolicy (javax.security.auth.message.MessagePolicy.TargetPolicy)2 Property (org.jvnet.hk2.config.types.Property)2 GFServerConfigProvider (com.sun.enterprise.security.jaspic.config.GFServerConfigProvider)1 Map (java.util.Map)1 Subject (javax.security.auth.Subject)1 AuthException (javax.security.auth.message.AuthException)1 AuthStatus (javax.security.auth.message.AuthStatus)1 MessageInfo (javax.security.auth.message.MessageInfo)1 ClientAuthContext (javax.security.auth.message.config.ClientAuthContext)1 ClientAuthModule (javax.security.auth.message.module.ClientAuthModule)1 PropertyExpander (sun.security.util.PropertyExpander)1