Search in sources :

Example 1 with GenericPrincipal

use of org.apache.catalina.realm.GenericPrincipal in project geode by apache.

the class DeltaSession7 method getSerializedPrincipal.

private byte[] getSerializedPrincipal() {
    if (this.serializedPrincipal == null) {
        if (this.principal != null && this.principal instanceof GenericPrincipal) {
            GenericPrincipal gp = (GenericPrincipal) this.principal;
            this.serializedPrincipal = serialize(gp);
            if (manager != null) {
                DeltaSessionManager mgr = (DeltaSessionManager) getManager();
                if (mgr.getLogger().isDebugEnabled()) {
                    mgr.getLogger().debug(this + ": Serialized principal: " + gp);
                }
            }
        }
    }
    return this.serializedPrincipal;
}
Also used : GenericPrincipal(org.apache.catalina.realm.GenericPrincipal)

Example 2 with GenericPrincipal

use of org.apache.catalina.realm.GenericPrincipal in project geode by apache.

the class DeltaSession8 method getSerializedPrincipal.

private byte[] getSerializedPrincipal() {
    if (this.serializedPrincipal == null) {
        if (this.principal != null && this.principal instanceof GenericPrincipal) {
            GenericPrincipal gp = (GenericPrincipal) this.principal;
            this.serializedPrincipal = serialize(gp);
            if (manager != null) {
                DeltaSessionManager mgr = (DeltaSessionManager) getManager();
                if (mgr.getLogger().isDebugEnabled()) {
                    mgr.getLogger().debug(this + ": Serialized principal: " + gp);
                }
            }
        }
    }
    return this.serializedPrincipal;
}
Also used : GenericPrincipal(org.apache.catalina.realm.GenericPrincipal)

Example 3 with GenericPrincipal

use of org.apache.catalina.realm.GenericPrincipal in project geode by apache.

the class DeltaSession method getSerializedPrincipal.

private byte[] getSerializedPrincipal() {
    if (this.serializedPrincipal == null) {
        if (this.principal != null && this.principal instanceof GenericPrincipal) {
            GenericPrincipal gp = (GenericPrincipal) this.principal;
            SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp);
            this.serializedPrincipal = serialize(sp);
            if (manager != null) {
                DeltaSessionManager mgr = (DeltaSessionManager) getManager();
                if (mgr.getLogger().isDebugEnabled()) {
                    mgr.getLogger().debug(this + ": Serialized principal: " + sp);
                // mgr.logCurrentStack();
                }
            }
        }
    }
    return this.serializedPrincipal;
}
Also used : GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) SerializablePrincipal(org.apache.catalina.ha.session.SerializablePrincipal)

Example 4 with GenericPrincipal

use of org.apache.catalina.realm.GenericPrincipal in project oxCore by GluuFederation.

the class WantSslRealm method getPrincipal.

@Override
protected Principal getPrincipal(X509Certificate usercert) {
    if (this.x509UsernameRetriever == null) {
        return new GenericPrincipal(null, null, null);
    }
    String username = this.x509UsernameRetriever.getUsername(usercert);
    Principal principal = new GenericPrincipal(username, null, null);
    return principal;
}
Also used : GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) Principal(java.security.Principal) GenericPrincipal(org.apache.catalina.realm.GenericPrincipal)

Example 5 with GenericPrincipal

use of org.apache.catalina.realm.GenericPrincipal in project tomcat70 by apache.

the class AuthenticatorBase method checkForCachedAuthentication.

/**
 * Check to see if the user has already been authenticated earlier in the
 * processing chain or if there is enough information available to
 * authenticate the user without requiring further user interaction.
 *
 * @param request The current request
 * @param response The current response
 * @param useSSO  Should information available from SSO be used to attempt
 *                to authenticate the current user?
 *
 * @return <code>true</code> if the user was authenticated via the cache,
 *         otherwise <code>false</code>
 */
protected boolean checkForCachedAuthentication(Request request, HttpServletResponse response, boolean useSSO) {
    // Has the user already been authenticated?
    Principal principal = request.getUserPrincipal();
    String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
    if (principal != null) {
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("authenticator.check.found", principal.getName()));
        }
        // invalidation at log out.
        if (ssoId != null) {
            associate(ssoId, request.getSessionInternal(true));
        }
        return true;
    }
    // Is there an SSO session against which we can try to reauthenticate?
    if (useSSO && ssoId != null) {
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("authenticator.check.sso", ssoId));
        }
        /* Try to reauthenticate using data cached by SSO.  If this fails,
               either the original SSO logon was of DIGEST or SSL (which
               we can't reauthenticate ourselves because there is no
               cached username and password), or the realm denied
               the user's reauthentication for some reason.
               In either case we have to prompt the user for a logon */
        if (reauthenticateFromSSO(ssoId, request)) {
            return true;
        }
    }
    // needs to be authorized?
    if (request.getCoyoteRequest().getRemoteUserNeedsAuthorization()) {
        String username = request.getCoyoteRequest().getRemoteUser().toString();
        if (username != null) {
            if (log.isDebugEnabled()) {
                log.debug(sm.getString("authenticator.check.authorize", username));
            }
            Principal authorized = context.getRealm().authenticate(username);
            if (authorized == null) {
                // from the authenticated user name
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString("authenticator.check.authorizeFail", username));
                }
                authorized = new GenericPrincipal(username, null, null);
            }
            String authType = request.getAuthType();
            if (authType == null || authType.length() == 0) {
                authType = getAuthMethod();
            }
            register(request, response, authorized, authType, username, null);
            return true;
        }
    }
    return false;
}
Also used : GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) Principal(java.security.Principal)

Aggregations

GenericPrincipal (org.apache.catalina.realm.GenericPrincipal)25 Principal (java.security.Principal)10 Test (org.junit.Test)9 Subject (javax.security.auth.Subject)7 CdiEventRealm (org.apache.tomee.catalina.realm.CdiEventRealm)4 CallerPrincipalCallback (jakarta.security.auth.message.callback.CallerPrincipalCallback)3 ArrayList (java.util.ArrayList)3 CallbackHandler (javax.security.auth.callback.CallbackHandler)3 GroupPrincipalCallback (jakarta.security.auth.message.callback.GroupPrincipalCallback)2 PasswordValidationCallback (jakarta.security.auth.message.callback.PasswordValidationCallback)2 IOException (java.io.IOException)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 Callback (javax.security.auth.callback.Callback)2 CallerPrincipal (org.apache.openejb.spi.CallerPrincipal)2 AuthException (jakarta.security.auth.message.AuthException)1 AuthStatus (jakarta.security.auth.message.AuthStatus)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1