/** * Register the assembled configuration against the system wide {@link AuthConfigFactory}. * * @return The registration ID returned by the factory on registration. * @throws IllegalStateException if the configuration has already been registered. */ public String register() { return register(AuthConfigFactory.getFactory()); }
/** * Registers the given SAM using the standard JASPIC {@link AuthConfigFactory} but using a small set of wrappers that just * pass the calls through to the SAM. * * @param serverAuthModule */ public static void registerSAM(ServletContext context, ServerAuthModule serverAuthModule) { AuthConfigFactory.getFactory().registerConfigProvider(new TestAuthConfigProvider(serverAuthModule), "HttpServlet", getAppContextID(context), "Test authentication config provider"); }
/** * <p> * JASPIC 1.1 specification: if there is an {@code AuthConfigProvider} for the {@code HttpServlet} layer and * application context, then @{@code login} must throw a {@code ServletException} which may convey that the * exception was caused by an incompatibility between the {@code login} method and the configured authentication * mechanism. If there is no such provider, then the container must proceed with the regular {@code login} processing. * </p> * * @param username The username * @param password The password * @return <code>true</code> if the login succeeded, false otherwise * @throws SecurityException if login is called when JASPIC is enabled for application context and layer. */ @Override public boolean login(final String username, final String password) { // if there is an AuthConfigProvider for the HttpServlet layer and appContext, this method must throw an exception. String appContext = this.buildAppContext(); AuthConfigProvider provider = AuthConfigFactory.getFactory().getConfigProvider(layer, appContext, null); if (provider != null) { ServletException se = new ServletException("login is not supported by the JASPIC mechanism"); throw new SecurityException(se); } return super.login(username, password); }
/** * <p> * JASPIC 1.1 specification: if there is an {@code AuthConfigProvider} for the {@code HttpServlet} layer and * application context, then @{@code logout} must acquire a {@code ServerAuthContext} and call {@code cleanSubject} * on the acquired context. * </p> * <p> * The specified {@code Subject} should be non-null and should be the {@code Subject} returning from the most recent * call to {@code validateRequest}. In our case, that {@code Subject} is set in the underlying security context, so * we must retrieve it from there before calling {@code cleanSubject}. * </p> * <p> * Once {@code cleanSubject} returns, {@code logout} must perform the regular (non-JASPIC) {@code logout} processing. * </p> */ @Override public void logout() { if (!isAuthenticated()) return; // call cleanSubject() if there is an AuthConfigProvider for the HttpServlet layer and appContext. String appContext = this.buildAppContext(); if (AuthConfigFactory.getFactory().getConfigProvider(layer, appContext, null) != null) { Subject authenticatedSubject = this.getAuthenticatedSubject(); MessageInfo messageInfo = this.buildMessageInfo(); this.manager.cleanSubject(messageInfo, authenticatedSubject, layer, appContext, handler); } // following the return from cleanSubject(), logout must perform the regular logout processing. super.logout(); }
private static AuthConfigFactory getAuthConfigFactory() { try { // TODO - PermissionCheck return AuthConfigFactory.getFactory(); } catch (Exception e) { // Logged at TRACE as this will be per request. log.trace("Unable to get AuthConfigFactory", e); } return null; }
private Optional<AuthConfigProvider> findJaspicProvider() { AuthConfigFactory factory = AuthConfigFactory.getFactory(); Optional<AuthConfigProvider> provider; if (factory == null) { provider = Optional.empty(); } else { provider = Optional.ofNullable( factory.getConfigProvider("HttpServlet", jaspicAppContextID, this)); } jaspicProvider = provider; return provider; }
private Optional<AuthConfigProvider> findJaspicProvider() { AuthConfigFactory factory = AuthConfigFactory.getFactory(); Optional<AuthConfigProvider> provider; if (factory == null) { provider = Optional.empty(); } else { provider = Optional.ofNullable( factory.getConfigProvider("HttpServlet", jaspicAppContextID, this)); } jaspicProvider = provider; return provider; }
/** * Register the assembled configuration against the system wide {@link AuthConfigFactory}. * * @return The registration ID returned by the factory on registration. * @throws IllegalStateException if the configuration has already been registered. */ public String register() { return register(AuthConfigFactory.getFactory()); }
/** * Register the assembled configuration against the system wide {@link AuthConfigFactory}. * * @return The registration ID returned by the factory on registration. * @throws IllegalStateException if the configuration has already been registered. */ public String register() { return register(AuthConfigFactory.getFactory()); }
private static AuthConfigFactory getAuthConfigFactory() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(ElytronDefinition.class.getClassLoader()); return AuthConfigFactory.getFactory(); } catch (Exception e) { ROOT_LOGGER.trace("Unable to load default AuthConfigFactory.", e); return null; } finally { Thread.currentThread().setContextClassLoader(classLoader); } }
private static void removeRegistration(final OperationContext context) { final String registrationId = REGISTRATION_MAP.remove(context.getCurrentAddressValue()); if (registrationId != null) { AuthConfigFactory authConfigFactory = AuthConfigFactory.getFactory(); authConfigFactory.removeRegistration(registrationId); } }
public String run() { return AuthConfigFactory.getFactory().registerConfigProvider( new DefaultAuthConfigProvider(serverAuthModule), "HttpServlet", getAppContextID(servletContext), "Default single SAM authentication config provider"); } });
public String run() { return AuthConfigFactory.getFactory().registerConfigProvider( new DefaultAuthConfigProvider(serverAuthModule), "HttpServlet", getAppContextID(servletContext), "Default single SAM authentication config provider"); } });
public static String registerAuthConfigProvider(Reader config, String messageLayer, String appContext) throws ConfigException { try { ConfigProviderType configProviderType = JaspiXmlUtil.loadConfigProvider(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapAuthConfigProvider(configProviderType); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, messageLayer, appContext, null); } catch (Exception e) { throw new ConfigException(e); } }
public static String registerClientAuthModule(String messageLayer, String appContext, String authenticationContextID, Reader config, boolean _protected) throws ConfigException { try { AuthModuleType<ClientAuthModule> clientAuthModuleType = JaspiXmlUtil.loadClientAuthModule(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapClientAuthModule(messageLayer, appContext, authenticationContextID, clientAuthModuleType, _protected); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, messageLayer, appContext, null); } catch (Exception e) { throw new ConfigException(e); } }
public static String registerServerAuthModule(String messageLayer, String appContext, String authenticationContextID, Reader config, boolean _protected) throws ConfigException { try { AuthModuleType<ServerAuthModule> serverAuthModuleType = JaspiXmlUtil.loadServerAuthModule(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapServerAuthModule(messageLayer, appContext, authenticationContextID, serverAuthModuleType, _protected); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, messageLayer, appContext, null); } catch (Exception e) { throw new ConfigException(e); } }
public static String registerClientAuthConfig(Reader config) throws ConfigException { try { ClientAuthConfigType clientAuthConfigType = JaspiXmlUtil.loadClientAuthConfig(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapClientAuthConfig(clientAuthConfigType); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, clientAuthConfigType.getMessageLayer(), clientAuthConfigType.getAppContext(), null); } catch (Exception e) { throw new ConfigException(e); } }
public static String registerServerAuthContext(Reader config, boolean _protected) throws ConfigException { try { ServerAuthContextType serverAuthContextType = JaspiXmlUtil.loadServerAuthContext(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapServerAuthContext(serverAuthContextType, _protected); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, serverAuthContextType.getMessageLayer(), serverAuthContextType.getAppContext(), null); } catch (Exception e) { throw new ConfigException(e); } }
public static String registerClientAuthContext(Reader config, boolean _protected) throws ConfigException { try { ClientAuthContextType clientAuthContextType = JaspiXmlUtil.loadClientAuthContext(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapClientAuthContext(clientAuthContextType, _protected); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, clientAuthContextType.getMessageLayer(), clientAuthContextType.getAppContext(), null); } catch (Exception e) { throw new ConfigException(e); } }
public static String registerServerAuthConfig(Reader config) throws ConfigException { try { ServerAuthConfigType serverAuthConfigType = JaspiXmlUtil.loadServerAuthConfig(config); AuthConfigProvider authConfigProvider = JaspiUtil.wrapServerAuthConfig(serverAuthConfigType); return AuthConfigFactory.getFactory().registerConfigProvider(authConfigProvider, serverAuthConfigType.getMessageLayer(), serverAuthConfigType.getAppContext(), null); } catch (Exception e) { throw new ConfigException(e); } }