@SuppressWarnings("unchecked") IdentityConfiguration(String name, List<? extends IdentityStoreConfiguration> identityStores, RelationshipPolicy relationshipPolicy) { if (name == null) { throw new SecurityConfigurationException("You must specify a name for the IdentityConfiguration."); } this.name = name; this.storeConfiguration = unmodifiableList(identityStores); this.relationshipPolicy = relationshipPolicy; }
@Override protected void validate() { if (this.supportedTypes.isEmpty()) { throw new SecurityConfigurationException("The store configuration must have at least one supported type."); } }
@SuppressWarnings("unchecked") IdentityConfiguration(String name, List<? extends IdentityStoreConfiguration> identityStores, RelationshipPolicy relationshipPolicy) { if (name == null) { throw new SecurityConfigurationException("You must specify a name for the IdentityConfiguration."); } this.name = name; this.storeConfiguration = unmodifiableList(identityStores); this.relationshipPolicy = relationshipPolicy; }
@Override protected void validate() { if (this.supportedTypes.isEmpty()) { throw new SecurityConfigurationException("The store configuration must have at least one supported type."); } }
private EntityManagerFactory lookupEntityManagerFactory() { try { return (EntityManagerFactory) new InitialContext().lookup(this.entityManagerFactoryJndiName); } catch (NamingException e) { throw new SecurityConfigurationException("Could not lookup EntityManagerFactory [" + this.entityManagerFactoryJndiName + "]."); } }
@Override protected void validate() { super.validate(); if (this.asyncWriteThreadPool <= 0) { throw new SecurityConfigurationException("The thread pool size must be greater than zero."); } }
@Override protected void validate() { super.validate(); if (this.asyncWriteThreadPool <= 0) { throw new SecurityConfigurationException("The thread pool size must be greater than zero."); } }
/** * {@inheritDoc} */ @Override public V resolveProperty(Object propertyValueFromConfiguration, Class<V> propertyClass) { if (propertyValueFromConfiguration instanceof String) { String stringValue = (String)propertyValueFromConfiguration; // Handle null cases if ("null".equals(stringValue)) { return null; } return resolvePropertyFromString(stringValue, propertyClass); } else { throw new SecurityConfigurationException("Unknown type of propertyValue: " + propertyValueFromConfiguration); } }
@Override public void setup(S store) { super.setup(store); Object configuredTokenConsumers = store.getConfig().getCredentialHandlerProperties().get(TOKEN_CONSUMER); if (configuredTokenConsumers != null) { try { if (Consumer.class.isInstance(configuredTokenConsumers)) { this.tokenConsumers.add((Consumer) configuredTokenConsumers); } else if (configuredTokenConsumers.getClass().isArray()) { this.tokenConsumers.addAll(Arrays.asList((Consumer[]) configuredTokenConsumers)); } else if (List.class.isInstance(configuredTokenConsumers)) { this.tokenConsumers.addAll((List<Consumer>) configuredTokenConsumers); } } catch (ClassCastException cce) { throw new SecurityConfigurationException("Token consumer is not a " + Consumer.class.getName() + " instance. You provided " + configuredTokenConsumers); } } }
@Override public final SecurityConfigurationException idmJpaStartFailed(final Throwable e) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaStartFailed$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmJpaEMFLookupFailed = "WFLYPL0052: Could not lookup EntityManagerFactory [%s].";
@Override public final SecurityConfigurationException idmJpaFailedCreateTransactionEntityManager(final Exception e) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaFailedCreateTransactionEntityManager$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmNoIdentityConfigurationProvided = "WFLYPL0054: You must provide at least one identity configuration.";
@Override public final SecurityConfigurationException idmJpaEntityModuleNotFound(final String entityModuleName) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaEntityModuleNotFound$str(), entityModuleName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmJpaStartFailed = "WFLYPL0051: Could not configure JPA store.";
@Override public final SecurityConfigurationException idmJpaEMFLookupFailed(final String entityManagerFactoryJndiName) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaEMFLookupFailed$str(), entityManagerFactoryJndiName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmJpaFailedCreateTransactionEntityManager = "WFLYPL0053: Could not create transactional EntityManager.";
@Override public final SecurityConfigurationException idmJpaEntityModuleNotFound(final String entityModuleName) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaEntityModuleNotFound$str(), entityModuleName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmJpaStartFailed = "WFLYPL0051: Could not configure JPA store.";
@Override public final SecurityConfigurationException idmJpaStartFailed(final Throwable e) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaStartFailed$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmJpaEMFLookupFailed = "WFLYPL0052: Could not lookup EntityManagerFactory [%s].";
@Override public final SecurityConfigurationException idmJpaFailedCreateTransactionEntityManager(final Exception e) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaFailedCreateTransactionEntityManager$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmNoIdentityConfigurationProvided = "WFLYPL0054: You must provide at least one identity configuration.";
@Override public final SecurityConfigurationException idmJpaEMFLookupFailed(final String entityManagerFactoryJndiName) { final SecurityConfigurationException result = new SecurityConfigurationException(String.format(getLoggingLocale(), idmJpaEMFLookupFailed$str(), entityManagerFactoryJndiName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String idmJpaFailedCreateTransactionEntityManager = "WFLYPL0053: Could not create transactional EntityManager.";
public IDMType parseIDMConfiguration(InputStream inputStream) { try { PicketLinkConfigParser parser = new PicketLinkConfigParser(); PicketLinkType plType = (PicketLinkType) parser.parse(inputStream); return plType.getIdmType(); } catch (ParsingException pe) { throw new SecurityConfigurationException("Could not parse picketlink configuration", pe); } }
@Override public boolean supports(Class<?> entityType) { if (entityType.isAnnotationPresent(IdentityManaged.class)) { Property<Object> result = PropertyQueries.createQuery(entityType) .addCriteria(new AnnotatedPropertyCriteria(IdentityClass.class)).getFirstResult(); if (result != null) { if (!result.getJavaClass().equals(String.class)) { throw new SecurityConfigurationException("IdentityType entities should be mapped with String valued @IdentityClass property."); } return true; } } return false; }
@Override public boolean supports(Class<?> entityType) { if (entityType.isAnnotationPresent(IdentityManaged.class)) { Property<Object> result = PropertyQueries.createQuery(entityType) .addCriteria(new AnnotatedPropertyCriteria(IdentityClass.class)).getFirstResult(); if (result != null) { if (!result.getJavaClass().equals(String.class)) { throw new SecurityConfigurationException("IdentityType entities should be mapped with String valued @IdentityClass property."); } return true; } } return false; }