/** * <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); }
/** * 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"); }
@Override public boolean removeRegistration(String registrationID) { return elytronAuthConfigFactory.removeRegistration(registrationID) || backupAuthConfigFactory.removeRegistration(registrationID); }
/** * 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()); }
public Boolean run() { return AuthConfigFactory.getFactory().removeRegistration(registrationId); } });
/** * Constructor with signature and implementation that's required by API. * * @param properties * @param factory */ public TestAuthConfigProvider(Map<String, String> properties, AuthConfigFactory factory) { this.providerProperties = properties; // API requires self registration if factory is provided. Not clear // where the "layer" (2nd parameter) // and especially "appContext" (3rd parameter) values have to come from // at this place. if (factory != null) { factory.registerConfigProvider(this, null, null, "Auto registration"); } }
@Override public AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) { AuthConfigProvider authConfigProvider = elytronAuthConfigFactory.getConfigProvider(layer, appContext, listener); if (authConfigProvider != null || elytronAuthConfigFactory.matchesRegistration(layer, appContext) || !delegationAllowed.get()) { return authConfigProvider; } return backupAuthConfigFactory.getConfigProvider(layer, appContext, listener); }
HashSet<String> toBeUnregistered = new HashSet<String>(); String[] regID = getFactory().getRegistrationIDs(this); for (String i : regID) { if (selfRegistered.contains(i)) { RegistrationContext c = getFactory().getRegistrationContext(i); if (c != null && !c.isPersistent()) { toBeUnregistered.add(i); RegistrationContext r = getFactory().getRegistrationContext(i); for (int j = 0; j < contexts.length; j++) { if (contextsAreEqual(contexts[j], r)) { getFactory().removeRegistration(i); String id = getFactory().registerConfigProvider(this, r.getMessageLayer(), r.getAppContext(), r.getDescription());
/** * Check if there is a provider register for a given layer and appCtxt. */ protected boolean hasExactMatchAuthProvider() { boolean exactMatch = false; // XXX this may need to be optimized AuthConfigProvider p = factory.getConfigProvider(layer, appCtxt, null); if (p != null) { String[] IDs = factory.getRegistrationIDs(p); for (String i : IDs) { RegistrationContext c = factory.getRegistrationContext(i); if (layer.equals(c.getMessageLayer()) && appCtxt.equals(c.getAppContext())) { exactMatch = true; break; } } } return exactMatch; }
public Object run() { /*String defaultFactory = Security.getProperty(AuthConfigFactory.DEFAULT_FACTORY_SECURITY_PROPERTY); if (defaultFactory == null || !(JMACAuthConfigFactory.class.getName().equals(defaultFactory))) { Security.setProperty(AuthConfigFactory.DEFAULT_FACTORY_SECURITY_PROPERTY, JMACAuthConfigFactory.class.getName()); }*/ AuthConfigFactory factory = AuthConfigFactory.getFactory(); if (factory == null || !(factory instanceof JMACAuthConfigFactory)) { AuthConfigFactory.setFactory(new JMACAuthConfigFactory(loader)); } return null; // nothing to return } });
if (!layerSet.contains(layer)) { String regisID = layerDefaultRegisIDMap.remove(layer); aFactory.removeRegistration(regisID); String regisID = aFactory.registerConfigProvider (aProvider, layer, null, "GFServerConfigProvider: self registration");
/** * to be called by refresh on provider subclass, and after subclass impl. * has reloaded its underlying configuration system. * Note: Spec is silent as to whether self-registrations should be reprocessed. */ public void oldRefresh() { if (getFactory() != null) { String[] regID = getFactory().getRegistrationIDs(this); for (String i : regID) { if (selfRegistered.contains(i)) { RegistrationContext c = getFactory().getRegistrationContext(i); if (c != null && !c.isPersistent()) { getFactory().removeRegistration(i); } } } } epochCarrier.increment(); selfRegister(); }
public static synchronized void setFactory(AuthConfigFactory factory) { checkPermission(setFactorySecurityPermission); AuthConfigFactory.factory = factory; }
public void disable() { this.wLock.lock(); try { setEnabled(false); } finally { data = null; this.wLock.unlock(); } if (factory != null) { String[] ids = factory.detachListener(this.listener,layer,appCtxt); // if (ids != null) { // for (int i=0; i < ids.length; i++) { // factory.removeRegistration(ids[i]); // } // } if (getJmacProviderRegisID() != null) { factory.removeRegistration(getJmacProviderRegisID()); } } }
@Override public RegistrationContext getRegistrationContext(String registrationID) { RegistrationContext registrationContext = elytronAuthConfigFactory.getRegistrationContext(registrationID); if (registrationContext == null) { registrationContext = backupAuthConfigFactory.getRegistrationContext(registrationID); } return registrationContext; }
@Override public String[] getRegistrationIDs(AuthConfigProvider provider) { String[] elytronRegistrationIds = elytronAuthConfigFactory.getRegistrationIDs(provider); String[] backupRegistrationIds = backupAuthConfigFactory.getRegistrationIDs(provider); return combine(elytronRegistrationIds, backupRegistrationIds); }
public static AuthConfigFactory getFactory() { checkPermission(getFactorySecurityPermission); if (factory != null) { return factory; final String className = getFactoryClassName(); try { factory = AccessController.doPrivileged(
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; }
public Boolean run() { return AuthConfigFactory.getFactory().removeRegistration(registrationId); } });
/** * Register the assembled configuration against the supplied {@link AuthConfigFactory}. * * @param authConfigFactory the {@link AuthConfigFactory} to register the configuration against. * @return The registration ID returned by the factory on registration. * @throws IllegalStateException if the configuration has already been registered. */ public String register(AuthConfigFactory authConfigFactory) { assertNotRegistered(); registered = true; return authConfigFactory.registerConfigProvider( new ElytronAuthConfigProvider(messageLayer, applicationContext, serverAuthModules), messageLayer, applicationContext, description); }