javax.security.auth.message.config.ServerAuthContext Java Examples
The following examples show how to use
javax.security.auth.message.config.ServerAuthContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TomEESecurityContext.java From tomee with Apache License 2.0 | 6 votes |
@Override public AuthenticationStatus authenticate(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationParameters parameters) { try { final MessageInfo messageInfo = new TomEEMessageInfo(request, response, true, parameters); final ServerAuthContext serverAuthContext = getServerAuthContext(request); final AuthStatus authStatus = serverAuthContext.validateRequest(messageInfo, new Subject(), null); return mapToAuthenticationStatus(authStatus); } catch (final AuthException e) { return AuthenticationStatus.SEND_FAILURE; } }
Example #2
Source File: AuthenticatorBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
@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, CallbackHandlerImpl.getInstance()); 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); }
Example #3
Source File: TestSimpleServerAuthConfig.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testConfigOnServerAuthConfig() throws Exception { ServerAuthConfig serverAuthConfig = new SimpleServerAuthConfig(null, null, null, CONFIG_PROPERTIES); ServerAuthContext serverAuthContext = serverAuthConfig.getAuthContext(null, null, null); validateServerAuthContext(serverAuthContext); }
Example #4
Source File: TestSimpleServerAuthConfig.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testConfigOnGetAuthContext() throws Exception { ServerAuthConfig serverAuthConfig = new SimpleServerAuthConfig(null, null, null, null); ServerAuthContext serverAuthContext = serverAuthConfig.getAuthContext(null, null, CONFIG_PROPERTIES); validateServerAuthContext(serverAuthContext); }
Example #5
Source File: TomEESecurityContext.java From tomee with Apache License 2.0 | 5 votes |
private ServerAuthContext getServerAuthContext(final HttpServletRequest request) throws AuthException { final String appContext = request.getServletContext().getVirtualServerName() + " " + request.getContextPath(); final AuthConfigProvider authConfigProvider = AuthConfigFactory.getFactory().getConfigProvider("HttpServlet", appContext, null); final ServerAuthConfig serverAuthConfig = authConfigProvider.getServerAuthConfig("HttpServlet", appContext, CallbackHandlerImpl.getInstance()); return serverAuthConfig.getAuthContext(null, null, null); }
Example #6
Source File: SimpleServerAuthConfig.java From Tomcat8-Source-Read with MIT License | 4 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) // JASPIC API uses raw types @Override public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException { ServerAuthContext serverAuthContext = this.serverAuthContext; if (serverAuthContext == null) { synchronized (this) { if (this.serverAuthContext == null) { Map<String,String> mergedProperties = new HashMap<>(); if (this.properties != null) { mergedProperties.putAll(this.properties); } if (properties != null) { mergedProperties.putAll(properties); } List<ServerAuthModule> modules = new ArrayList<>(); int moduleIndex = 1; String key = SERVER_AUTH_MODULE_KEY_PREFIX + moduleIndex; String moduleClassName = mergedProperties.get(key); while (moduleClassName != null) { try { Class<?> clazz = Class.forName(moduleClassName); ServerAuthModule module = (ServerAuthModule) clazz.getConstructor().newInstance(); module.initialize(null, null, handler, mergedProperties); modules.add(module); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { AuthException ae = new AuthException(); ae.initCause(e); throw ae; } // Look for the next module moduleIndex++; key = SERVER_AUTH_MODULE_KEY_PREFIX + moduleIndex; moduleClassName = mergedProperties.get(key); } if (modules.size() == 0) { throw new AuthException(sm.getString("simpleServerAuthConfig.noModules")); } this.serverAuthContext = createServerAuthContext(modules); } serverAuthContext = this.serverAuthContext; } } return serverAuthContext; }
Example #7
Source File: SimpleServerAuthConfig.java From Tomcat8-Source-Read with MIT License | 4 votes |
protected ServerAuthContext createServerAuthContext(List<ServerAuthModule> modules) { return new SimpleServerAuthContext(modules); }
Example #8
Source File: TestSimpleServerAuthConfig.java From Tomcat8-Source-Read with MIT License | 4 votes |
private void validateServerAuthContext(ServerAuthContext serverAuthContext) throws Exception { MessageInfo msgInfo = new TesterMessageInfo(); serverAuthContext.cleanSubject(msgInfo, null); Assert.assertEquals("init()-cleanSubject()-", msgInfo.getMap().get("trace")); }
Example #9
Source File: CustomServerAuthConfig.java From eplmp with Eclipse Public License 1.0 | 4 votes |
@Override public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException { return new CustomServerAuthContext(serverAuthModules); }
Example #10
Source File: TomEESecurityServerAuthConfig.java From tomee with Apache License 2.0 | 4 votes |
@Override public ServerAuthContext getAuthContext(final String authContextID, final Subject serviceSubject, final Map properties) throws AuthException { return new TomEESecurityServerAuthContext(handler); }
Example #11
Source File: TheServerAuthConfig.java From tomee with Apache License 2.0 | 4 votes |
@Override public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, @SuppressWarnings("rawtypes") Map properties) throws AuthException { return new TheServerAuthContext(handler, serverAuthModule); }