@Override public void setup(C config) { IDENTITY_STORE_LOGGER.storeInitializing(getClass()); this.configuration = config; if (IDENTITY_STORE_LOGGER.isDebugEnabled()) { IDENTITY_STORE_LOGGER.debugf("[%s]: [", this.configuration); IDENTITY_STORE_LOGGER.debugf(" Type: %s", this.configuration.getIdentityStoreType()); IDENTITY_STORE_LOGGER.debugf(" Supports partition: %s", this.configuration.supportsPartition()); IDENTITY_STORE_LOGGER.debugf(" Supports attribute: %s", this.configuration.supportsAttribute()); IDENTITY_STORE_LOGGER.debugf(" Supports credential: %s", this.configuration.supportsCredential()); IDENTITY_STORE_LOGGER.debugf(" Credential Handlers: %s", this.configuration.getCredentialHandlers()); IDENTITY_STORE_LOGGER.debugf(" Supported types: %s", this.configuration.getSupportedTypes().keySet()); IDENTITY_STORE_LOGGER.debugf(" Unsupported types: %s", this.configuration.getUnsupportedTypes().keySet()); IDENTITY_STORE_LOGGER.debugf(" Context Initializers: %s", this.configuration.getContextInitializers()); IDENTITY_STORE_LOGGER.debug("]"); } if (config.supportsCredential()) { initializeCredentialHandlers(); } }
@Override protected Builder<T> readFrom(T configuration) { for (Class<? extends CredentialHandler> credentialHandler : configuration.getCredentialHandlers()) { addCredentialHandler(credentialHandler); } for (String credentialProperty : configuration.getCredentialHandlerProperties().keySet()) { Object value = configuration.getCredentialHandlerProperties().get(credentialProperty); setCredentialHandlerProperty(credentialProperty, value); } for (Class<? extends AttributedType> supportedType : configuration.getSupportedTypes().keySet()) { supportType(supportedType); if (Relationship.class.isAssignableFrom(supportedType)) { supportGlobalRelationship((Class<? extends Relationship>) supportedType); } } for (Class<? extends AttributedType> unsupportedType : configuration.getUnsupportedTypes().keySet()) { unsupportType(unsupportedType); } for (ContextInitializer contextInitializer : configuration.getContextInitializers()) { addContextInitializer(contextInitializer); } supportAttributes(configuration.supportsAttribute()); supportCredentials(configuration.supportsCredential()); supportPermissions(configuration.supportsPermissions()); return this; }
public <T extends IdentityStore<?>> T lookupStore(IdentityContext context, IdentityConfiguration configuration, Class<? extends AttributedType> type, IdentityOperation operation) { for (IdentityStoreConfiguration storeConfig : configuration.getStoreConfiguration()) { if (storeConfig.supportsType(type, operation)) { return getIdentityStoreAndInitializeContext(context, configuration, storeConfig); } } return null; }
@Override public Set<CredentialStore<?>> getStoresForCredentialStorage(final IdentityContext context, Class<? extends CredentialStorage> storageClass) { IdentityConfiguration identityConfiguration = getConfigurationForPartition(context, context.getPartition()); Map<IdentityStoreConfiguration, IdentityStore<?>> storesConfig = this.stores.get(identityConfiguration); Set<CredentialStore<?>> credentialStores = new HashSet<CredentialStore<?>>(); if (storesConfig != null) { for (IdentityStoreConfiguration storeConfig : storesConfig.keySet()) { if (storeConfig.supportsCredential()) { for (Class<? extends CredentialHandler> credentialHandler : storeConfig.getCredentialHandlers()) { SupportsCredentials supportedCredentials = credentialHandler.getAnnotation(SupportsCredentials.class); if (supportedCredentials != null) { if (supportedCredentials.credentialStorage().equals(storageClass)) { CredentialStore<?> credentialStore = (CredentialStore<?>) getIdentityStoreAndInitializeContext(context, identityConfiguration, storeConfig); credentialStores.add(credentialStore); } } } } } } return credentialStores; }
if (storeConfig.supportsPartition()) { partitionCfg = config; if (storeConfig.supportsAttribute()) { attributeCfg = config; for (IdentityStoreConfiguration storeConfig : config.getStoreConfiguration()) { for (Class<? extends AttributedType> supportedType : storeConfig.getSupportedTypes().keySet()) { if (Relationship.class.isAssignableFrom(supportedType)) { this.privilegeChainQuery.registerRelationshipType((Class<Relationship>) supportedType);
/** * <p>Returns a set containing all {@link org.picketlink.idm.model.AttributedType} supported by this configuration. * The resulting set is a combination of the supported types of each identity store supported by this configuration.</p> * * @return */ public Set<Class<? extends AttributedType>> getSupportedTypes() { HashSet<Class<? extends AttributedType>> supportedTypes = new HashSet<Class<? extends AttributedType>>(); for (IdentityStoreConfiguration storeConfiguration : getStoreConfiguration()) { supportedTypes.addAll(storeConfiguration.getSupportedTypes().keySet()); } return supportedTypes; } }
private void initializeCredentialHandlers() { for (Class<? extends CredentialHandler> handlerType : configuration.getCredentialHandlers()) { CredentialHandler credentialHandler = null; try { credentialHandler = handlerType.newInstance(); credentialHandler.setup(this); } catch (Exception e) { throw MESSAGES.instantiationError(handlerType, e); } this.credentialHandlers.put(handlerType, credentialHandler); } }
public boolean supportsPartition() { for (IdentityStoreConfiguration storeConfiguration : getStoreConfiguration()) { if (storeConfiguration.supportsPartition()) { return true; } } return false; }
/** * <p>Check if the configuration supports credential management.</p> * * <p>Credential management is supported if any of the configured identity stores support it.</p> * * @return True if the configuration supports credential. Otherwise is false. */ public boolean supportsCredential() { for (IdentityStoreConfiguration storeConfiguration: getStoreConfiguration()) { if (storeConfiguration.supportsCredential()) { return true; } } return false; }
/** * <p>Check if the configuration supports credential management.</p> * * <p>Credential management is supported if any of the configured identity stores support it.</p> * * @return True if the configuration supports credential. Otherwise is false. */ public boolean supportsAttribute() { for (IdentityStoreConfiguration storeConfiguration: getStoreConfiguration()) { if (storeConfiguration.supportsAttribute()) { return true; } } return false; }
/** * <p>Check if the configuration supports credential management.</p> * * <p>Permission management is supported if any of the configured identity stores support it.</p> * * @return */ public boolean supportsPermission() { for (IdentityStoreConfiguration storeConfiguration: getStoreConfiguration()) { if (storeConfiguration.supportsPermissions()) { return true; } } return false; }
private String getConfigurationProperty(CredentialStore<?> store, String key, String defaultValue) { Object value = store.getConfig().getCredentialHandlerProperties().get(key); if (value != null) { return String.valueOf(value); } return defaultValue; }
if (storeConfig.supportsPartition()) { partitionCfg = config; if (storeConfig.supportsAttribute()) { attributeCfg = config; for (IdentityStoreConfiguration storeConfig : config.getStoreConfiguration()) { for (Class<? extends AttributedType> supportedType : storeConfig.getSupportedTypes().keySet()) { if (Relationship.class.isAssignableFrom(supportedType)) { this.privilegeChainQuery.registerRelationshipType((Class<Relationship>) supportedType);
/** * <p>Returns a set containing all {@link org.picketlink.idm.model.AttributedType} supported by this configuration. * The resulting set is a combination of the supported types of each identity store supported by this configuration.</p> * * @return */ public Set<Class<? extends AttributedType>> getSupportedTypes() { HashSet<Class<? extends AttributedType>> supportedTypes = new HashSet<Class<? extends AttributedType>>(); for (IdentityStoreConfiguration storeConfiguration : getStoreConfiguration()) { supportedTypes.addAll(storeConfiguration.getSupportedTypes().keySet()); } return supportedTypes; } }
@Override public Set<CredentialStore<?>> getStoresForCredentialStorage(final IdentityContext context, Class<? extends CredentialStorage> storageClass) { IdentityConfiguration identityConfiguration = getConfigurationForPartition(context, context.getPartition()); Map<IdentityStoreConfiguration, IdentityStore<?>> storesConfig = this.stores.get(identityConfiguration); Set<CredentialStore<?>> credentialStores = new HashSet<CredentialStore<?>>(); if (storesConfig != null) { for (IdentityStoreConfiguration storeConfig : storesConfig.keySet()) { if (storeConfig.supportsCredential()) { for (Class<? extends CredentialHandler> credentialHandler : storeConfig.getCredentialHandlers()) { SupportsCredentials supportedCredentials = credentialHandler.getAnnotation(SupportsCredentials.class); if (supportedCredentials != null) { if (supportedCredentials.credentialStorage().equals(storageClass)) { CredentialStore<?> credentialStore = (CredentialStore<?>) getIdentityStoreAndInitializeContext(context, identityConfiguration, storeConfig); credentialStores.add(credentialStore); } } } } } } return credentialStores; }
private void initializeCredentialHandlers() { for (Class<? extends CredentialHandler> handlerType : configuration.getCredentialHandlers()) { CredentialHandler credentialHandler = null; try { credentialHandler = handlerType.newInstance(); credentialHandler.setup(this); } catch (Exception e) { throw MESSAGES.instantiationError(handlerType, e); } this.credentialHandlers.put(handlerType, credentialHandler); } }
public boolean supportsPartition() { for (IdentityStoreConfiguration storeConfiguration : getStoreConfiguration()) { if (storeConfiguration.supportsPartition()) { return true; } } return false; }
/** * <p>Check if the configuration supports credential management.</p> * * <p>Credential management is supported if any of the configured identity stores support it.</p> * * @return True if the configuration supports credential. Otherwise is false. */ public boolean supportsCredential() { for (IdentityStoreConfiguration storeConfiguration: getStoreConfiguration()) { if (storeConfiguration.supportsCredential()) { return true; } } return false; }
/** * <p>Check if the configuration supports credential management.</p> * * <p>Credential management is supported if any of the configured identity stores support it.</p> * * @return True if the configuration supports credential. Otherwise is false. */ public boolean supportsAttribute() { for (IdentityStoreConfiguration storeConfiguration: getStoreConfiguration()) { if (storeConfiguration.supportsAttribute()) { return true; } } return false; }
/** * <p>Check if the configuration supports credential management.</p> * * <p>Permission management is supported if any of the configured identity stores support it.</p> * * @return */ public boolean supportsPermission() { for (IdentityStoreConfiguration storeConfiguration: getStoreConfiguration()) { if (storeConfiguration.supportsPermissions()) { return true; } } return false; }