use of org.jboss.as.controller.AbstractAddStepHandler in project wildfly by wildfly.
the class ElytronIntegrationResourceDefinitions method getElytronKeyStoreResourceDefinition.
/**
* Defines a resource that represents an Elytron-compatible key store that can be exported by a JSSE-enabled domain
* in the legacy security subsystem.
*
* To export the key store the resource uses a {@code BasicAddHandler} implementation that registers the elytron key-store
* capability and implements a {@code org.jboss.as.security.elytron.BasicService.ValueSupplier} that uses the injected
* {@code SecurityDomainContext} to obtain a {@code JSSESecurityDomain}. If such domain is found, its configured key
* store is obtained and returned.
*
* The {@code ValueSupplier} implementation throws an exception if the referenced legacy domain is not a JSSE-enabled
* domain or if the domain doesn't contain a key store configuration.
*/
public static ResourceDefinition getElytronKeyStoreResourceDefinition() {
final AttributeDefinition[] attributes = new AttributeDefinition[] { LEGACY_JSSE_CONFIG };
final AbstractAddStepHandler addHandler = new BasicAddHandler<KeyStore>(attributes, KEY_STORE_RUNTIME_CAPABILITY) {
@Override
protected BasicService.ValueSupplier<KeyStore> getValueSupplier(ServiceBuilder<KeyStore> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException {
final String legacyJSSEConfig = asStringIfDefined(context, LEGACY_JSSE_CONFIG, model);
final InjectedValue<SecurityDomainContext> securityDomainContextInjector = new InjectedValue<>();
if (legacyJSSEConfig != null) {
serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(legacyJSSEConfig), SecurityDomainContext.class, securityDomainContextInjector);
}
return () -> {
final SecurityDomainContext domainContext = securityDomainContextInjector.getValue();
final JSSESecurityDomain jsseDomain = domainContext.getJSSE();
if (jsseDomain == null) {
throw SecurityLogger.ROOT_LOGGER.unableToLocateJSSEConfig(legacyJSSEConfig);
}
final KeyStore keyStore = jsseDomain.getKeyStore();
if (keyStore == null) {
throw SecurityLogger.ROOT_LOGGER.unableToLocateComponentInJSSEDomain("key store", legacyJSSEConfig);
}
return keyStore;
};
}
};
return new BasicResourceDefinition(Constants.ELYTRON_KEY_STORE, addHandler, attributes, KEY_STORE_RUNTIME_CAPABILITY);
}
use of org.jboss.as.controller.AbstractAddStepHandler in project wildfly by wildfly.
the class ElytronIntegrationResourceDefinitions method getElytronRealmResourceDefinition.
/**
* Defines a resource that represents an Elytron-compatible realm that can be exported by the legacy security subsystem.
* The constructed {@code SecurityRealm} wraps a legacy {@code SecurityDomainContext} and delegates authentication
* decisions to that context.
*
* To export the realm the resource uses a {@code BasicAddHandler} implementation that registers the security-realm
* capability and implements a {@code org.jboss.as.security.elytron.BasicService.ValueSupplier} that uses the injected
* {@code SecurityDomainContext} to create and return an instance of {@code SecurityDomainContextRealm}.
*/
public static ResourceDefinition getElytronRealmResourceDefinition() {
final AttributeDefinition[] attributes = new AttributeDefinition[] { LEGACY_JAAS_CONFIG };
final AbstractAddStepHandler addHandler = new BasicAddHandler<SecurityRealm>(attributes, SECURITY_REALM_RUNTIME_CAPABILITY) {
@Override
protected BasicService.ValueSupplier<SecurityRealm> getValueSupplier(ServiceBuilder<SecurityRealm> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException {
final String legacyJAASConfig = asStringIfDefined(context, LEGACY_JAAS_CONFIG, model);
final InjectedValue<SecurityDomainContext> securityDomainContextInjector = new InjectedValue<>();
if (legacyJAASConfig != null) {
serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(legacyJAASConfig), SecurityDomainContext.class, securityDomainContextInjector);
}
return () -> {
final SecurityDomainContext domainContext = securityDomainContextInjector.getValue();
return new SecurityDomainContextRealm(domainContext);
};
}
};
return new BasicResourceDefinition(Constants.ELYTRON_REALM, addHandler, attributes, SECURITY_REALM_RUNTIME_CAPABILITY);
}
use of org.jboss.as.controller.AbstractAddStepHandler in project wildfly by wildfly.
the class MappingModuleDefinition method registerOperations.
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
super.registerOperations(resourceRegistration);
super.registerAddOperation(resourceRegistration, new AbstractAddStepHandler() {
@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
for (AttributeDefinition attr : getAttributes()) {
attr.validateAndSet(operation, model);
}
}
}, OperationEntry.Flag.RESTART_NONE);
}
Aggregations