use of org.jboss.security.config.ControlFlag in project wildfly by wildfly.
the class SecurityDomainAdd method processAuthorization.
private boolean processAuthorization(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
node = peek(node, AUTHORIZATION, CLASSIC, POLICY_MODULE);
if (node == null) {
return false;
}
AuthorizationInfo authzInfo = new AuthorizationInfo(securityDomain);
for (Property moduleProperty : node.asPropertyList()) {
ModelNode module = moduleProperty.getValue();
String codeName = extractCode(context, module, ModulesMap.AUTHORIZATION_MAP);
String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString();
ControlFlag controlFlag = ControlFlag.valueOf(flag);
Map<String, Object> options = extractOptions(context, module);
AuthorizationModuleEntry authzModuleEntry = new AuthorizationModuleEntry(codeName, options);
authzModuleEntry.setControlFlag(controlFlag);
authzInfo.add(authzModuleEntry);
ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module);
if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
authzInfo.addJBossModuleName(moduleName.asString());
} else {
authzInfo.addJBossModuleName(DEFAULT_MODULE);
}
}
applicationPolicy.setAuthorizationInfo(authzInfo);
return true;
}
use of org.jboss.security.config.ControlFlag in project wildfly by wildfly.
the class SecurityDomainAdd method processACL.
private boolean processACL(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
node = peek(node, ACL, CLASSIC, ACL_MODULE);
if (node == null) {
return false;
}
ACLInfo aclInfo = new ACLInfo(securityDomain);
for (Property moduleProperty : node.asPropertyList()) {
ModelNode module = moduleProperty.getValue();
String codeName = LoginModuleResourceDefinition.CODE.resolveModelAttribute(context, module).asString();
String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString();
ControlFlag controlFlag = ControlFlag.valueOf(flag);
Map<String, Object> options = extractOptions(context, module);
ACLProviderEntry entry = new ACLProviderEntry(codeName, options);
entry.setControlFlag(controlFlag);
aclInfo.add(entry);
ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module);
if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
aclInfo.addJBossModuleName(moduleName.asString());
} else {
aclInfo.addJBossModuleName(DEFAULT_MODULE);
}
}
applicationPolicy.setAclInfo(aclInfo);
return true;
}
use of org.jboss.security.config.ControlFlag in project wildfly by wildfly.
the class SecurityDomainAdd method processIdentityTrust.
private boolean processIdentityTrust(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
node = peek(node, IDENTITY_TRUST, CLASSIC, TRUST_MODULE);
if (node == null) {
return false;
}
IdentityTrustInfo identityTrustInfo = new IdentityTrustInfo(securityDomain);
for (Property moduleProperty : node.asPropertyList()) {
ModelNode module = moduleProperty.getValue();
String codeName = LoginModuleResourceDefinition.CODE.resolveModelAttribute(context, module).asString();
String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString();
ControlFlag controlFlag = ControlFlag.valueOf(flag);
Map<String, Object> options = extractOptions(context, module);
IdentityTrustModuleEntry entry = new IdentityTrustModuleEntry(codeName, options);
entry.setControlFlag(controlFlag);
identityTrustInfo.add(entry);
ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module);
if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
identityTrustInfo.addJBossModuleName(moduleName.asString());
} else {
identityTrustInfo.addJBossModuleName(DEFAULT_MODULE);
}
}
applicationPolicy.setIdentityTrustInfo(identityTrustInfo);
return true;
}
use of org.jboss.security.config.ControlFlag in project jbossws-cxf by jbossws.
the class JBossWSClientAuthConfig method getAuthContext.
@SuppressWarnings({ "rawtypes", "unchecked" })
public ClientAuthContext getAuthContext(String authContextID, Subject clientSubject, Map properties) throws AuthException {
List<ControlFlag> controlFlags = new ArrayList<ControlFlag>();
Map<String, Map> mapOptionsByName = new HashMap<String, Map>();
JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) properties.get("jaspi-policy");
AuthModuleEntry[] amearr = jai.getAuthModuleEntry();
ClassLoader moduleCL = null;
String jbossModule = jai.getJBossModuleName();
if (jbossModule != null && !jbossModule.isEmpty()) {
ClassLoaderLocator locator = ClassLoaderLocatorFactory.get();
if (locator != null)
moduleCL = locator.get(jbossModule);
}
for (AuthModuleEntry ame : amearr) {
try {
mapOptionsByName.put(ame.getAuthModuleName(), ame.getOptions());
controlFlags.add(ame.getControlFlag());
ClientAuthModule sam = this.createCAM(moduleCL, ame.getAuthModuleName());
Map options = new HashMap();
sam.initialize(null, null, callbackHandler, options);
modules.add(sam);
} catch (Exception e) {
throw new AuthException(e.getLocalizedMessage());
}
}
JBossWSClientAuthContext clientAuthContext = new JBossWSClientAuthContext(modules, mapOptionsByName, this.callbackHandler);
clientAuthContext.setControlFlags(controlFlags);
return clientAuthContext;
}
use of org.jboss.security.config.ControlFlag in project jbossws-cxf by jbossws.
the class JBossWSServerAuthConfig method getAuthContext.
@SuppressWarnings({ "rawtypes", "unchecked" })
public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException {
List<ControlFlag> controlFlags = new ArrayList<ControlFlag>();
Map<String, Map> mapOptionsByName = new HashMap<String, Map>();
JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) properties.get("jaspi-policy");
AuthModuleEntry[] amearr = jai.getAuthModuleEntry();
ClassLoader moduleCL = null;
String jbossModule = jai.getJBossModuleName();
if (jbossModule != null && !jbossModule.isEmpty()) {
ClassLoaderLocator locator = ClassLoaderLocatorFactory.get();
if (locator != null)
moduleCL = locator.get(jbossModule);
}
for (AuthModuleEntry ame : amearr) {
if (ame.getLoginModuleStackHolderName() != null) {
try {
mapOptionsByName.put(ame.getAuthModuleName(), ame.getOptions());
controlFlags.add(ame.getControlFlag());
ServerAuthModule sam = this.createSAM(moduleCL, ame.getAuthModuleName(), ame.getLoginModuleStackHolderName());
Map options = new HashMap();
Bus bus = (Bus) properties.get(Bus.class);
options.put(Bus.class, bus);
javax.xml.ws.Endpoint endpoint = (javax.xml.ws.Endpoint) properties.get(javax.xml.ws.Endpoint.class);
options.put(javax.xml.ws.Endpoint.class, endpoint);
sam.initialize(null, null, callbackHandler, options);
modules.add(sam);
} catch (Exception e) {
throw new AuthException(e.getLocalizedMessage());
}
} else {
try {
mapOptionsByName.put(ame.getAuthModuleName(), ame.getOptions());
controlFlags.add(ame.getControlFlag());
ServerAuthModule sam = this.createSAM(moduleCL, ame.getAuthModuleName());
Map options = new HashMap();
sam.initialize(null, null, callbackHandler, options);
modules.add(sam);
} catch (Exception e) {
throw new AuthException(e.getLocalizedMessage());
}
}
}
JBossWSServerAuthContext serverAuthContext = new JBossWSServerAuthContext(modules, mapOptionsByName, this.callbackHandler);
serverAuthContext.setControlFlags(controlFlags);
return serverAuthContext;
}
Aggregations