Search in sources :

Example 1 with AuthPolicy

use of com.sun.enterprise.security.jauth.AuthPolicy in project Payara by payara.

the class GFServerConfigProvider method createModuleInfo.

/**
 * Instantiate+initialize module class
 */
static ModuleInfo createModuleInfo(Entry entry, CallbackHandler handler, String type, Map<String, Object> properties) throws AuthException {
    try {
        // instantiate module using no-arg constructor
        Object newModule = entry.newInstance();
        Map<String, Object> map = properties;
        Map<String, Object> entryOptions = entry.getOptions();
        if (entryOptions != null) {
            if (map == null) {
                map = new HashMap<>();
            } else {
                map = new HashMap<>(map);
            }
            map.putAll(entryOptions);
        }
        // No doPrivilege at this point, need to revisit
        if (SERVER.equals(type)) {
            if (newModule instanceof ServerAuthModule) {
                ServerAuthModule sam = (ServerAuthModule) newModule;
                sam.initialize(entry.getRequestPolicy(), entry.getResponsePolicy(), handler, map);
            } else if (newModule instanceof com.sun.enterprise.security.jauth.ServerAuthModule) {
                // TODO REMOVE
                com.sun.enterprise.security.jauth.ServerAuthModule sam0 = (com.sun.enterprise.security.jauth.ServerAuthModule) newModule;
                AuthPolicy requestPolicy = (entry.getRequestPolicy() != null) ? new AuthPolicy(entry.getRequestPolicy()) : null;
                AuthPolicy responsePolicy = (entry.getResponsePolicy() != null) ? new AuthPolicy(entry.getResponsePolicy()) : null;
                sam0.initialize(requestPolicy, responsePolicy, handler, map);
            }
        } else {
            // CLIENT
            if (newModule instanceof ClientAuthModule) {
                ClientAuthModule cam = (ClientAuthModule) newModule;
                cam.initialize(entry.getRequestPolicy(), entry.getResponsePolicy(), handler, map);
            } else if (newModule instanceof com.sun.enterprise.security.jauth.ClientAuthModule) {
                // TODO REMOVE
                com.sun.enterprise.security.jauth.ClientAuthModule cam0 = (com.sun.enterprise.security.jauth.ClientAuthModule) newModule;
                AuthPolicy requestPolicy = new AuthPolicy(entry.getRequestPolicy());
                AuthPolicy responsePolicy = new AuthPolicy(entry.getResponsePolicy());
                cam0.initialize(requestPolicy, responsePolicy, handler, map);
            }
        }
        return new ModuleInfo(newModule, map);
    } catch (Exception e) {
        if (e instanceof AuthException) {
            throw (AuthException) e;
        }
        AuthException ae = new AuthException();
        ae.initCause(e);
        throw ae;
    }
}
Also used : ServerAuthModule(javax.security.auth.message.module.ServerAuthModule) AuthException(javax.security.auth.message.AuthException) PendingException(com.sun.enterprise.security.jauth.PendingException) FailureException(com.sun.enterprise.security.jauth.FailureException) PrivilegedActionException(java.security.PrivilegedActionException) IOException(java.io.IOException) AuthException(javax.security.auth.message.AuthException) AuthPolicy(com.sun.enterprise.security.jauth.AuthPolicy) ClientAuthModule(javax.security.auth.message.module.ClientAuthModule)

Aggregations

AuthPolicy (com.sun.enterprise.security.jauth.AuthPolicy)1 FailureException (com.sun.enterprise.security.jauth.FailureException)1 PendingException (com.sun.enterprise.security.jauth.PendingException)1 IOException (java.io.IOException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 AuthException (javax.security.auth.message.AuthException)1 ClientAuthModule (javax.security.auth.message.module.ClientAuthModule)1 ServerAuthModule (javax.security.auth.message.module.ServerAuthModule)1