use of org.jboss.as.connector.metadata.resourceadapter.WorkManagerSecurityImpl 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);
String transactionSupportResolved = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, operation, TRANSACTION_SUPPORT);
TransactionSupportEnum transactionSupport = operation.hasDefined(TRANSACTION_SUPPORT.getName()) ? TransactionSupportEnum.valueOf(ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, operation, TRANSACTION_SUPPORT)) : 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.as.connector.metadata.resourceadapter.WorkManagerSecurityImpl in project wildfly by wildfly.
the class ResourceAdapterParser method parseWorkManagerSecurity.
protected WorkManagerSecurity parseWorkManagerSecurity(final ModelNode operation, final XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException {
boolean mappingRequired = false;
String domain = null;
String defaultPrincipal = null;
List<String> defaultGroups = null;
Map<String, String> userMappings = null;
Map<String, String> groupMappings = null;
boolean userMappingEnabled = false;
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (WorkManager.Tag.forName(reader.getLocalName()) == WorkManager.Tag.SECURITY) {
return new WorkManagerSecurityImpl(mappingRequired, domain, false, defaultPrincipal, defaultGroups, userMappings, groupMappings);
} else {
if (WorkManagerSecurity.Tag.forName(reader.getLocalName()) == WorkManagerSecurity.Tag.UNKNOWN) {
throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
}
}
break;
}
case START_ELEMENT:
{
switch(WorkManagerSecurity.Tag.forName(reader.getLocalName())) {
case DEFAULT_GROUPS:
case MAPPINGS:
{
// Skip
break;
}
case MAPPING_REQUIRED:
{
String value = rawElementText(reader);
WM_SECURITY_MAPPING_REQUIRED.parseAndSetParameter(value, operation, reader);
break;
}
case DOMAIN:
{
String value = domain = rawElementText(reader);
WM_SECURITY_DOMAIN.parseAndSetParameter(value, operation, reader);
break;
}
case DEFAULT_PRINCIPAL:
{
String value = rawElementText(reader);
WM_SECURITY_DEFAULT_PRINCIPAL.parseAndSetParameter(value, operation, reader);
break;
}
case GROUP:
{
String value = rawElementText(reader);
operation.get(WM_SECURITY_DEFAULT_GROUPS.getName()).add(WM_SECURITY_DEFAULT_GROUP.parse(value, reader));
break;
}
case USERS:
{
userMappingEnabled = true;
break;
}
case GROUPS:
{
userMappingEnabled = false;
break;
}
case MAP:
{
if (userMappingEnabled) {
String from = rawAttributeText(reader, WorkManagerSecurity.Attribute.FROM.getLocalName());
if (from == null || from.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.FROM.getLocalName(), reader.getLocalName()));
String to = rawAttributeText(reader, WorkManagerSecurity.Attribute.TO.getLocalName());
if (to == null || to.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.TO.getLocalName(), reader.getLocalName()));
ModelNode object = new ModelNode();
WM_SECURITY_MAPPING_FROM.parseAndSetParameter(from, object, reader);
WM_SECURITY_MAPPING_TO.parseAndSetParameter(to, object, reader);
operation.get(WM_SECURITY_MAPPING_USERS.getName()).add(object);
} else {
String from = rawAttributeText(reader, WorkManagerSecurity.Attribute.FROM.getLocalName());
if (from == null || from.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.FROM.getLocalName(), reader.getLocalName()));
String to = rawAttributeText(reader, WorkManagerSecurity.Attribute.TO.getLocalName());
if (to == null || to.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.TO.getLocalName(), reader.getLocalName()));
ModelNode object = new ModelNode();
WM_SECURITY_MAPPING_FROM.parseAndSetParameter(from, object, reader);
WM_SECURITY_MAPPING_TO.parseAndSetParameter(to, object, reader);
operation.get(WM_SECURITY_MAPPING_GROUPS.getName()).add(object);
}
break;
}
default:
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
break;
}
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
}
use of org.jboss.as.connector.metadata.resourceadapter.WorkManagerSecurityImpl in project wildfly by wildfly.
the class ResourceAdapterParser method parseWorkManagerSecurity_5_0.
protected WorkManagerSecurity parseWorkManagerSecurity_5_0(final ModelNode operation, final XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException {
boolean mappingRequired = false;
String domain = null;
boolean elytronEnabled = false;
String defaultPrincipal = null;
List<String> defaultGroups = null;
Map<String, String> userMappings = null;
Map<String, String> groupMappings = null;
boolean userMappingEnabled = false;
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (WorkManager.Tag.forName(reader.getLocalName()) == WorkManager.Tag.SECURITY) {
return new WorkManagerSecurityImpl(mappingRequired, domain, elytronEnabled, defaultPrincipal, defaultGroups, userMappings, groupMappings);
} else {
if (WorkManagerSecurity.Tag.forName(reader.getLocalName()) == WorkManagerSecurity.Tag.UNKNOWN) {
throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
}
}
break;
}
case START_ELEMENT:
{
switch(WorkManagerSecurity.Tag.forName(reader.getLocalName())) {
case DEFAULT_GROUPS:
case MAPPINGS:
{
// Skip
break;
}
case MAPPING_REQUIRED:
{
String value = rawElementText(reader);
WM_SECURITY_MAPPING_REQUIRED.parseAndSetParameter(value, operation, reader);
break;
}
case DOMAIN:
{
String value = domain = rawElementText(reader);
WM_SECURITY_DOMAIN.parseAndSetParameter(value, operation, reader);
break;
}
case ELYTRON_SECURITY_DOMAIN:
{
elytronEnabled = true;
String value = domain = rawElementText(reader);
WM_ELYTRON_SECURITY_DOMAIN.parseAndSetParameter(value, operation, reader);
break;
}
case DEFAULT_PRINCIPAL:
{
String value = rawElementText(reader);
WM_SECURITY_DEFAULT_PRINCIPAL.parseAndSetParameter(value, operation, reader);
break;
}
case GROUP:
{
String value = rawElementText(reader);
operation.get(WM_SECURITY_DEFAULT_GROUPS.getName()).add(WM_SECURITY_DEFAULT_GROUP.parse(value, reader));
break;
}
case USERS:
{
userMappingEnabled = true;
break;
}
case GROUPS:
{
userMappingEnabled = false;
break;
}
case MAP:
{
if (userMappingEnabled) {
String from = rawAttributeText(reader, WorkManagerSecurity.Attribute.FROM.getLocalName());
if (from == null || from.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.FROM.getLocalName(), reader.getLocalName()));
String to = rawAttributeText(reader, WorkManagerSecurity.Attribute.TO.getLocalName());
if (to == null || to.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.TO.getLocalName(), reader.getLocalName()));
ModelNode object = new ModelNode();
WM_SECURITY_MAPPING_FROM.parseAndSetParameter(from, object, reader);
WM_SECURITY_MAPPING_TO.parseAndSetParameter(to, object, reader);
operation.get(WM_SECURITY_MAPPING_USERS.getName()).add(object);
} else {
String from = rawAttributeText(reader, WorkManagerSecurity.Attribute.FROM.getLocalName());
if (from == null || from.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.FROM.getLocalName(), reader.getLocalName()));
String to = rawAttributeText(reader, WorkManagerSecurity.Attribute.TO.getLocalName());
if (to == null || to.trim().equals(""))
throw new ParserException(bundle.requiredAttributeMissing(WorkManagerSecurity.Attribute.TO.getLocalName(), reader.getLocalName()));
ModelNode object = new ModelNode();
WM_SECURITY_MAPPING_FROM.parseAndSetParameter(from, object, reader);
WM_SECURITY_MAPPING_TO.parseAndSetParameter(to, object, reader);
operation.get(WM_SECURITY_MAPPING_GROUPS.getName()).add(object);
}
break;
}
default:
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
break;
}
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
}
Aggregations