use of org.jboss.jca.common.api.metadata.resourceadapter.AdminObject in project wildfly by wildfly.
the class RaOperationUtil method buildResourceAdaptersObject.
public static ModifiableResourceAdapter buildResourceAdaptersObject(final String id, final OperationContext context, ModelNode operation, String archiveOrModule) throws OperationFailedException {
Map<String, String> configProperties = new HashMap<>(0);
List<ConnectionDefinition> connectionDefinitions = new ArrayList<>(0);
List<AdminObject> adminObjects = new ArrayList<>(0);
TransactionSupportEnum transactionSupport = operation.hasDefined(TRANSACTION_SUPPORT.getName()) ? TransactionSupportEnum.valueOf(operation.get(TRANSACTION_SUPPORT.getName()).asString()) : null;
String bootstrapContext = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, operation, BOOTSTRAP_CONTEXT);
List<String> beanValidationGroups = BEANVALIDATION_GROUPS.unwrap(context, operation);
boolean wmSecurity = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, operation, WM_SECURITY);
WorkManager workManager = null;
if (wmSecurity) {
final boolean mappingRequired = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, operation, WM_SECURITY_MAPPING_REQUIRED);
String domain;
final String elytronDomain = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, operation, WM_ELYTRON_SECURITY_DOMAIN);
if (elytronDomain != null) {
domain = elytronDomain;
} else {
domain = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, operation, WM_SECURITY_DOMAIN);
}
final String defaultPrincipal = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, operation, WM_SECURITY_DEFAULT_PRINCIPAL);
final List<String> defaultGroups = WM_SECURITY_DEFAULT_GROUPS.unwrap(context, operation);
final Map<String, String> groups = ModelNodeUtil.extractMap(operation, WM_SECURITY_MAPPING_GROUPS, WM_SECURITY_MAPPING_FROM, WM_SECURITY_MAPPING_TO);
final Map<String, String> users = ModelNodeUtil.extractMap(operation, WM_SECURITY_MAPPING_USERS, WM_SECURITY_MAPPING_FROM, WM_SECURITY_MAPPING_TO);
workManager = new WorkManagerImpl(new WorkManagerSecurityImpl(mappingRequired, domain, elytronDomain != null, defaultPrincipal, defaultGroups, users, groups));
}
ModifiableResourceAdapter ra;
ra = new ModifiableResourceAdapter(id, archiveOrModule, transactionSupport, connectionDefinitions, adminObjects, configProperties, beanValidationGroups, bootstrapContext, workManager);
return ra;
}
use of org.jboss.jca.common.api.metadata.resourceadapter.AdminObject in project wildfly by wildfly.
the class IronJacamarResourceCreator method addResourceAdapter.
private void addResourceAdapter(final Resource parent, String name, Activation ironJacamarMetadata) {
final Resource ijResourceAdapter = new IronJacamarResource.IronJacamarRuntimeResource();
final ModelNode model = ijResourceAdapter.getModel();
model.get(Constants.ARCHIVE.getName()).set(name);
setAttribute(model, Constants.BOOTSTRAP_CONTEXT, ironJacamarMetadata.getBootstrapContext());
if (ironJacamarMetadata.getTransactionSupport() != null)
model.get(Constants.TRANSACTION_SUPPORT.getName()).set(ironJacamarMetadata.getTransactionSupport().name());
if (ironJacamarMetadata.getWorkManager() != null && ironJacamarMetadata.getWorkManager().getSecurity() != null) {
org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity security = ironJacamarMetadata.getWorkManager().getSecurity();
model.get(Constants.WM_SECURITY.getName()).set(true);
if (security.getDefaultGroups() != null) {
for (String group : security.getDefaultGroups()) {
model.get(Constants.WM_SECURITY_DEFAULT_GROUPS.getName()).add(group);
}
}
if (security.getDefaultPrincipal() != null)
model.get(Constants.WM_SECURITY_DEFAULT_PRINCIPAL.getName()).set(security.getDefaultPrincipal());
model.get(Constants.WM_SECURITY_MAPPING_REQUIRED.getName()).set(security.isMappingRequired());
if (security instanceof WorkManagerSecurity && ((WorkManagerSecurity) security).isElytronEnabled()) {
model.get(Constants.WM_ELYTRON_SECURITY_DOMAIN.getName()).set(security.getDomain());
} else {
model.get(Constants.WM_SECURITY_DOMAIN.getName()).set(security.getDomain());
}
if (security.getGroupMappings() != null) {
for (Map.Entry<String, String> entry : security.getGroupMappings().entrySet()) {
final Resource mapping = new IronJacamarResource.IronJacamarRuntimeResource();
final ModelNode subModel = mapping.getModel();
subModel.get(Constants.WM_SECURITY_MAPPING_FROM.getName()).set(entry.getKey());
subModel.get(Constants.WM_SECURITY_MAPPING_TO.getName()).set(entry.getKey());
final PathElement element = PathElement.pathElement(Constants.WM_SECURITY_MAPPING_GROUPS.getName(), WM_SECURITY_MAPPING_GROUP.getName());
ijResourceAdapter.registerChild(element, mapping);
}
}
if (security.getUserMappings() != null) {
for (Map.Entry<String, String> entry : security.getUserMappings().entrySet()) {
final Resource mapping = new IronJacamarResource.IronJacamarRuntimeResource();
final ModelNode subModel = mapping.getModel();
subModel.get(Constants.WM_SECURITY_MAPPING_FROM.getName()).set(entry.getKey());
subModel.get(Constants.WM_SECURITY_MAPPING_TO.getName()).set(entry.getKey());
final PathElement element = PathElement.pathElement(Constants.WM_SECURITY_MAPPING_USERS.getName(), WM_SECURITY_MAPPING_USER.getName());
ijResourceAdapter.registerChild(element, mapping);
}
}
}
if (ironJacamarMetadata.getBeanValidationGroups() != null) {
for (String bv : ironJacamarMetadata.getBeanValidationGroups()) {
model.get(Constants.BEANVALIDATION_GROUPS.getName()).add(new ModelNode().set(bv));
}
}
if (ironJacamarMetadata.getConfigProperties() != null) {
for (Map.Entry<String, String> config : ironJacamarMetadata.getConfigProperties().entrySet()) {
addConfigProperties(ijResourceAdapter, config.getKey(), config.getValue());
}
}
if (ironJacamarMetadata.getConnectionDefinitions() != null) {
for (ConnectionDefinition connDef : ironJacamarMetadata.getConnectionDefinitions()) {
addConnectionDefinition(ijResourceAdapter, connDef);
}
}
if (ironJacamarMetadata.getAdminObjects() != null) {
for (AdminObject adminObject : ironJacamarMetadata.getAdminObjects()) {
addAdminObject(ijResourceAdapter, adminObject);
}
}
final Resource statsResource = new IronJacamarResource.IronJacamarRuntimeResource();
ijResourceAdapter.registerChild(PathElement.pathElement(Constants.STATISTICS_NAME, "local"), statsResource);
final PathElement element = PathElement.pathElement(Constants.RESOURCEADAPTER_NAME, name);
parent.registerChild(element, ijResourceAdapter);
}
Aggregations