RegistrationContext toRegistrationContext() { // We return a new instance to avoid state changes being detected by stale references. return activeRegistration() ? new ElytronRegistrationContext(messageLayer, appContext, description, persistent) : null; }
/** * @see javax.security.auth.message.config.AuthConfigFactory#registerConfigProvider(javax.security.auth.message.config.AuthConfigProvider, java.lang.String, java.lang.String, java.lang.String) */ @Override public String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description) { checkPermission(providerRegistrationSecurityPermission); return registerConfigProvider(provider, layer, appContext, description, false); }
/** * Add a {@link Supplier<ServerAuthModule>} to be used to create a {@link ServerAuthModule} instance for this message layer * and application context combination. * * @param serverAuthModuleFactory the {@link Supplier<ServerAuthModule>} to be added to the list of module factories. * @return this {@link JaspiConfigurationBuilder} to allow chaining of commands. * @throws IllegalStateException if the configuration has already been registered. */ public JaspiConfigurationBuilder addAuthModuleFactory(final Supplier<ServerAuthModule> serverAuthModuleFactory) { return addAuthModuleFactory(serverAuthModuleFactory, Flag.REQUIRED, Collections.EMPTY_MAP); }
@Override public String[] detachListener(RegistrationListener listener, String layer, String appContext) { String[] elytronRegistrationIds = elytronAuthConfigFactory.detachListener(listener, layer, appContext); String[] backupRegistrationIds = backupAuthConfigFactory.detachListener(listener, layer, appContext); return combine(elytronRegistrationIds, backupRegistrationIds); }
@Override public String[] getRegistrationIDs(AuthConfigProvider provider) { String[] elytronRegistrationIds = elytronAuthConfigFactory.getRegistrationIDs(provider); String[] backupRegistrationIds = backupAuthConfigFactory.getRegistrationIDs(provider); return combine(elytronRegistrationIds, backupRegistrationIds); }
boolean matchesRegistration(final String layer, final String appContext) { synchronized (layerContextRegistration) { // Step 1 - Exact Match Registration registration = layerContextRegistration.get(new LayerContextKey(layer, appContext)); if (registration != null && registration.activeRegistration()) { return true; } // Step 2 - appContext only registration = layerContextRegistration.get(new LayerContextKey(null, appContext)); if (registration != null && registration.activeRegistration()) { return true; } // Step 3 - layer only registration = layerContextRegistration.get(new LayerContextKey(layer, null)); if (registration != null && registration.activeRegistration()) { return true; } // Step 4 - No appContext or layer registration = layerContextRegistration.get(new LayerContextKey(null, null)); if (registration != null && registration.activeRegistration()) { return true; } } return false; }
/** * Add a {@link Supplier<ServerAuthModule>} to be used to create a {@link ServerAuthModule} instance for this message layer * and application context combination. * * @param serverAuthModuleFactory the {@link Supplier<ServerAuthModule>} to be added to the list of module factories. * @param flag the flag to control the handling of the auth module. * @param options the configuration options to pass to the module during initialisation. * @return this {@link JaspiConfigurationBuilder} to allow chaining of commands. * @throws IllegalStateException if the configuration has already been registered. */ public JaspiConfigurationBuilder addAuthModuleFactory(final Supplier<ServerAuthModule> serverAuthModuleFactory, final Flag flag, final Map options) { assertNotRegistered(); serverAuthModules.add(new AuthenticationModuleDefinition(serverAuthModuleFactory, flag, options)); return this; }
/** * @see javax.security.auth.message.config.AuthConfigFactory#getRegistrationContext(java.lang.String) */ @Override public RegistrationContext getRegistrationContext(String registrationID) { synchronized (layerContextRegistration) { for (Registration current : layerContextRegistration.values()) { if (current.getRegistrationId().equals(registrationID)) { return current.toRegistrationContext(); } } } return null; }
@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); }
/** * 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); }
/** * 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()); }
@Override public String registerConfigProvider(String className, Map properties, String layer, String appContext, String description) { return elytronAuthConfigFactory.registerConfigProvider(className, properties, layer, appContext, description); }
/** * Set the description to be used for the provider once registered. * * @param description the description to be used for the provider once registered. * @return this {@link JaspiConfigurationBuilder} to allow chaining of commands. * @throws IllegalStateException if the configuration has already been registered. */ public JaspiConfigurationBuilder setDescription(final String description) { assertNotRegistered(); this.description = description; return this; }
/** * @see javax.security.auth.message.config.AuthConfigFactory#refresh() */ @Override public void refresh() { // [ELY-1538] Dynamic loading not presently supported, once supported refresh will reload the configuration. checkPermission(providerRegistrationSecurityPermission); }
public static JaspiConfigurationBuilder builder(final String messageLayer, final String applicationContext) { return new JaspiConfigurationBuilder(messageLayer, applicationContext); }
@Override public boolean equals(Object other) { return other instanceof LayerContextKey ? equals((LayerContextKey) other) : false; }
@Override public RegistrationContext getRegistrationContext(String registrationID) { RegistrationContext registrationContext = elytronAuthConfigFactory.getRegistrationContext(registrationID); if (registrationContext == null) { registrationContext = backupAuthConfigFactory.getRegistrationContext(registrationID); } return registrationContext; }
@Override public void refresh() { elytronAuthConfigFactory.refresh(); backupAuthConfigFactory.refresh(); }
@Override public boolean removeRegistration(String registrationID) { return elytronAuthConfigFactory.removeRegistration(registrationID) || backupAuthConfigFactory.removeRegistration(registrationID); }
@Override public String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description) { return elytronAuthConfigFactory.registerConfigProvider(provider, layer, appContext, description); }