use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractConfiguredObject method asObjectRecord.
@Override
public final ConfiguredObjectRecord asObjectRecord() {
return new ConfiguredObjectRecord() {
@Override
public UUID getId() {
return AbstractConfiguredObject.this.getId();
}
@Override
public String getType() {
return getCategoryClass().getSimpleName();
}
@Override
public Map<String, Object> getAttributes() {
return Subject.doAs(getSubjectWithAddedSystemRights(), new PrivilegedAction<Map<String, Object>>() {
@Override
public Map<String, Object> run() {
Map<String, Object> attributes = new LinkedHashMap<>();
Map<String, Object> actualAttributes = getActualAttributes();
for (ConfiguredObjectAttribute<?, ?> attr : _attributeTypes.values()) {
if (attr.isPersisted() && !ID.equals(attr.getName())) {
if (attr.isDerived()) {
Object value = getAttribute(attr.getName());
attributes.put(attr.getName(), toRecordedForm(attr, value));
} else if (actualAttributes.containsKey(attr.getName())) {
Object value = actualAttributes.get(attr.getName());
attributes.put(attr.getName(), toRecordedForm(attr, value));
}
}
}
return attributes;
}
});
}
public Object toRecordedForm(final ConfiguredObjectAttribute<?, ?> attr, Object value) {
if (value instanceof ConfiguredObject) {
value = ((ConfiguredObject) value).getId();
}
if (attr.isSecure() && _encrypter != null && value != null) {
if (value instanceof Collection || value instanceof Map) {
ObjectMapper mapper = ConfiguredObjectJacksonModule.newObjectMapper(false);
try (StringWriter stringWriter = new StringWriter()) {
mapper.writeValue(stringWriter, value);
value = _encrypter.encrypt(stringWriter.toString());
} catch (IOException e) {
throw new IllegalConfigurationException("Failure when encrypting a secret value", e);
}
} else {
value = _encrypter.encrypt(value.toString());
}
}
return value;
}
@Override
public Map<String, UUID> getParents() {
Map<String, UUID> parents = new LinkedHashMap<>();
Class<? extends ConfiguredObject> parentClass = getModel().getParentType(getCategoryClass());
ConfiguredObject parent = (ConfiguredObject) getParent();
if (parent != null) {
parents.put(parentClass.getSimpleName(), parent.getId());
}
return parents;
}
@Override
public String toString() {
return AbstractConfiguredObject.this.getClass().getSimpleName() + "[name=" + getName() + ", categoryClass=" + getCategoryClass() + ", type=" + getType() + ", id=" + getId() + ", attributes=" + getAttributes() + "]";
}
};
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractContainer method updateEncrypter.
private void updateEncrypter(final String encryptionProviderType) {
if (encryptionProviderType != null && !"".equals(encryptionProviderType.trim())) {
PluggableFactoryLoader<ConfigurationSecretEncrypterFactory> factoryLoader = new PluggableFactoryLoader<>(ConfigurationSecretEncrypterFactory.class);
ConfigurationSecretEncrypterFactory factory = factoryLoader.get(encryptionProviderType);
if (factory == null) {
throw new IllegalConfigurationException("Unknown Configuration Secret Encryption method " + encryptionProviderType);
}
setEncrypter(factory.createEncrypter(this));
} else {
setEncrypter(null);
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManager method validateOnCreate.
@Override
protected void validateOnCreate() {
super.validateOnCreate();
File passwordFile = new File(_path);
if (passwordFile.exists() && !passwordFile.canRead()) {
throw new IllegalConfigurationException(String.format("Cannot read password file '%s'. Please check permissions.", _path));
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManager method onCreate.
@Override
protected void onCreate() {
super.onCreate();
File passwordFile = new File(_path);
if (!passwordFile.exists()) {
try {
Path path = new FileHelper().createNewFile(passwordFile, getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS));
if (!Files.exists(path)) {
throw new IllegalConfigurationException(String.format("Cannot create password file at '%s'", _path));
}
} catch (IOException e) {
throw new IllegalConfigurationException(String.format("Cannot create password file at '%s'", _path), e);
}
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class SimpleLDAPAuthenticationManagerImpl method validateInitialDirContext.
private void validateInitialDirContext(final SimpleLDAPAuthenticationManager<?> authenticationProvider) {
final TrustStore truststore = authenticationProvider.getTrustStore();
final Class<? extends SocketFactory> sslSocketFactoryOverrideClass = createSslSocketFactoryOverrideClass(truststore);
final Hashtable<String, Object> env = createInitialDirContextEnvironment(authenticationProvider.getProviderUrl());
setAuthenticationProperties(env, authenticationProvider.getSearchUsername(), authenticationProvider.getSearchPassword(), authenticationProvider.getAuthenticationMethod());
InitialDirContext ctx = null;
try {
Subject gssapiIdentity = null;
if (LdapAuthenticationMethod.GSSAPI.equals(authenticationProvider.getAuthenticationMethod())) {
gssapiIdentity = doGssApiLogin(authenticationProvider.getLoginConfigScope());
}
ctx = createInitialDirContext(env, sslSocketFactoryOverrideClass, gssapiIdentity);
} catch (NamingException e) {
LOGGER.debug("Failed to establish connectivity to the ldap server for '{}'", authenticationProvider.getProviderUrl(), e);
throw new IllegalConfigurationException("Failed to establish connectivity to the ldap server.", e);
} catch (LoginException e) {
LOGGER.debug("JAAS login failed ", e);
throw new IllegalConfigurationException("JAAS login failed.", e);
} finally {
closeSafely(ctx);
}
}
Aggregations