Search in sources :

Example 1 with MessageInfo

use of jakarta.security.auth.message.MessageInfo in project tomcat by apache.

the class AuthenticatorBase method logout.

@Override
public void logout(Request request) {
    AuthConfigProvider provider = getJaspicProvider();
    if (provider != null) {
        MessageInfo messageInfo = new MessageInfoImpl(request, request.getResponse(), true);
        Subject client = (Subject) request.getNote(Constants.REQ_JASPIC_SUBJECT_NOTE);
        if (client != null) {
            ServerAuthContext serverAuthContext;
            try {
                ServerAuthConfig serverAuthConfig = provider.getServerAuthConfig("HttpServlet", jaspicAppContextID, getCallbackHandler());
                String authContextID = serverAuthConfig.getAuthContextID(messageInfo);
                serverAuthContext = serverAuthConfig.getAuthContext(authContextID, null, null);
                serverAuthContext.cleanSubject(messageInfo, client);
            } catch (AuthException e) {
                log.debug(sm.getString("authenticator.jaspicCleanSubjectFail"), e);
            }
        }
    }
    Principal p = request.getPrincipal();
    if (p instanceof TomcatPrincipal) {
        try {
            ((TomcatPrincipal) p).logout();
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            log.debug(sm.getString("authenticator.tomcatPrincipalLogoutFail"), t);
        }
    }
    register(request, request.getResponse(), null, null, null, null);
}
Also used : AuthConfigProvider(jakarta.security.auth.message.config.AuthConfigProvider) MessageInfoImpl(org.apache.catalina.authenticator.jaspic.MessageInfoImpl) AuthException(jakarta.security.auth.message.AuthException) Subject(javax.security.auth.Subject) ServerAuthConfig(jakarta.security.auth.message.config.ServerAuthConfig) Principal(java.security.Principal) TomcatPrincipal(org.apache.catalina.TomcatPrincipal) GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) MessageInfo(jakarta.security.auth.message.MessageInfo) ServerAuthContext(jakarta.security.auth.message.config.ServerAuthContext) TomcatPrincipal(org.apache.catalina.TomcatPrincipal)

Example 2 with MessageInfo

use of jakarta.security.auth.message.MessageInfo in project tomcat by apache.

the class TestSimpleServerAuthConfig method validateServerAuthContext.

private void validateServerAuthContext(ServerAuthContext serverAuthContext) throws Exception {
    MessageInfo msgInfo = new TesterMessageInfo();
    serverAuthContext.cleanSubject(msgInfo, null);
    Assert.assertEquals("init()-cleanSubject()-", msgInfo.getMap().get("trace"));
}
Also used : MessageInfo(jakarta.security.auth.message.MessageInfo)

Aggregations

MessageInfo (jakarta.security.auth.message.MessageInfo)2 AuthException (jakarta.security.auth.message.AuthException)1 AuthConfigProvider (jakarta.security.auth.message.config.AuthConfigProvider)1 ServerAuthConfig (jakarta.security.auth.message.config.ServerAuthConfig)1 ServerAuthContext (jakarta.security.auth.message.config.ServerAuthContext)1 Principal (java.security.Principal)1 Subject (javax.security.auth.Subject)1 TomcatPrincipal (org.apache.catalina.TomcatPrincipal)1 MessageInfoImpl (org.apache.catalina.authenticator.jaspic.MessageInfoImpl)1 GenericPrincipal (org.apache.catalina.realm.GenericPrincipal)1