use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class ExpressionSupportSmokeTestCase method isAttributeExcluded.
private boolean isAttributeExcluded(PathAddress address, String attrName, ModelNode attrDesc, ModelNode resourceNoDefaults) {
if (!attrDesc.get(ACCESS_TYPE).isDefined() || !attrDesc.get(ACCESS_TYPE).asString().equalsIgnoreCase("read-write")) {
return true;
}
if (attrDesc.get(STORAGE).isDefined() && !attrDesc.get(STORAGE).asString().equalsIgnoreCase("configuration")) {
return true;
}
if (attrDesc.get(ModelDescriptionConstants.DEPRECATED).isDefined()) {
return true;
}
// Special cases
if ("default-web-module".equals(attrName)) {
if (address.size() > 1) {
PathElement subPe = address.getElement(address.size() - 2);
if ("subsystem".equals(subPe.getKey()) && "web".equals(subPe.getValue()) && "virtual-server".equals(address.getLastElement().getKey())) {
// so skip it
return true;
}
}
} else if ("policy-modules".equals(attrName) || "login-modules".equals(attrName)) {
if (address.size() > 2) {
PathElement subPe = address.getElement(address.size() - 3);
if ("subsystem".equals(subPe.getKey()) && "security".equals(subPe.getValue()) && "security-domain".equals(address.getElement(address.size() - 2).getKey())) {
// we could exclude all deprecated attributes, but for now I'd rather be specific
return true;
}
}
} else if ("virtual-nodes".equals(attrName)) {
if (address.size() > 3) {
PathElement subPe = address.getElement(address.size() - 3);
PathElement containerPe = address.getElement(address.size() - 2);
PathElement distPe = address.getElement(address.size() - 1);
if ("subsystem".equals(subPe.getKey()) && "infinispan".equals(subPe.getValue()) && "cache-container".equals(containerPe.getKey()) && "distributed-cache".equals(distPe.getKey())) {
// This is a distributed cache attribute in Infinispan which has been deprecated
return true;
}
}
} else if (address.size() > 0 && "transactions".equals(address.getLastElement().getValue()) && "subsystem".equals(address.getLastElement().getKey())) {
if (attrName.contains("jdbc")) {
// Ignore jdbc store attributes unless jdbc store is enabled
return !resourceNoDefaults.hasDefined("use-jdbc-store") || !resourceNoDefaults.get("use-jdbc-store").asBoolean();
} else if (attrName.contains("journal")) {
// Ignore journal store attributes unless journal store is enabled
return !resourceNoDefaults.hasDefined("use-journal-store") || !resourceNoDefaults.get("use-journal-store").asBoolean();
}
}
return false;
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class SecuritySubsystemParser method parseSecurityDomain.
private void parseSecurityDomain(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddress) throws XMLStreamException {
ModelNode op = Util.createAddOperation();
list.add(op);
PathElement secDomainPath = null;
EnumSet<Attribute> required = EnumSet.of(Attribute.NAME);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch(attribute) {
case NAME:
{
if (value == null || value.length() == 0) {
throw invalidAttributeValue(reader, i);
}
secDomainPath = PathElement.pathElement(SECURITY_DOMAIN, value);
break;
}
case CACHE_TYPE:
{
SecurityDomainResourceDefinition.CACHE_TYPE.parseAndSetParameter(value, op, reader);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
final PathAddress address = parentAddress.append(secDomainPath);
op.get(OP_ADDR).set(address.toModelNode());
final EnumSet<Element> visited = EnumSet.noneOf(Element.class);
moduleNames = new HashMap<String, Integer>();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!visited.add(element)) {
throw unexpectedElement(reader);
}
switch(element) {
case AUTHENTICATION:
{
if (visited.contains(Element.AUTHENTICATION_JASPI)) {
throw SecurityLogger.ROOT_LOGGER.xmlStreamExceptionAuth(reader.getLocation());
}
parseAuthentication(list, address, reader);
break;
}
case AUTHORIZATION:
{
parseAuthorization(list, address, reader);
break;
}
case ACL:
{
parseACL(list, address, reader);
break;
}
case AUDIT:
{
parseAudit(list, address, reader);
break;
}
case IDENTITY_TRUST:
{
parseIdentityTrust(list, address, reader);
break;
}
case MAPPING:
{
parseMapping(list, address, reader);
break;
}
case AUTHENTICATION_JASPI:
{
if (visited.contains(Element.AUTHENTICATION)) {
throw SecurityLogger.ROOT_LOGGER.xmlStreamExceptionAuth(reader.getLocation());
}
parseAuthenticationJaspi(list, address, reader);
break;
}
case JSSE:
{
parseJSSE(list, address, reader);
break;
}
default:
{
throw unexpectedElement(reader);
}
}
}
moduleNames.clear();
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class ACLResourceDefinition method registerChildren.
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
ManagementResourceRegistration moduleReg = resourceRegistration.registerSubModel(new LoginModuleResourceDefinition(Constants.ACL_MODULE));
// https://issues.jboss.org/browse/WFLY-2474 acl-module was wrongly called login-module in 7.2.0
resourceRegistration.registerAlias(PathElement.pathElement(Constants.LOGIN_MODULE), new AliasEntry(moduleReg) {
@Override
public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) {
PathElement element = address.getLastElement();
element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue());
return address.subAddress(0, address.size() - 1).append(element);
}
});
}
use of org.jboss.as.controller.PathElement in project eap-additional-testsuite by jboss-set.
the class ExpressionSupportSmokeTestCase method isAttributeExcluded.
private boolean isAttributeExcluded(PathAddress address, String attrName, ModelNode attrDesc, ModelNode resourceNoDefaults) {
if (!attrDesc.get(ACCESS_TYPE).isDefined() || !attrDesc.get(ACCESS_TYPE).asString().equalsIgnoreCase("read-write")) {
return true;
}
if (attrDesc.get(STORAGE).isDefined() && !attrDesc.get(STORAGE).asString().equalsIgnoreCase("configuration")) {
return true;
}
if (attrDesc.get(ModelDescriptionConstants.DEPRECATED).isDefined()) {
return true;
}
// Special cases
if ("default-web-module".equals(attrName)) {
if (address.size() > 1) {
PathElement subPe = address.getElement(address.size() - 2);
if ("subsystem".equals(subPe.getKey()) && "web".equals(subPe.getValue()) && "virtual-server".equals(address.getLastElement().getKey())) {
// so skip it
return true;
}
}
} else if ("policy-modules".equals(attrName) || "login-modules".equals(attrName)) {
if (address.size() > 2) {
PathElement subPe = address.getElement(address.size() - 3);
if ("subsystem".equals(subPe.getKey()) && "security".equals(subPe.getValue()) && "security-domain".equals(address.getElement(address.size() - 2).getKey())) {
// we could exclude all deprecated attributes, but for now I'd rather be specific
return true;
}
}
} else if ("virtual-nodes".equals(attrName)) {
if (address.size() > 3) {
PathElement subPe = address.getElement(address.size() - 3);
PathElement containerPe = address.getElement(address.size() - 2);
PathElement distPe = address.getElement(address.size() - 1);
if ("subsystem".equals(subPe.getKey()) && "infinispan".equals(subPe.getValue()) && "cache-container".equals(containerPe.getKey()) && "distributed-cache".equals(distPe.getKey())) {
// This is a distributed cache attribute in Infinispan which has been deprecated
return true;
}
}
} else if (address.size() > 0 && "transactions".equals(address.getLastElement().getValue()) && "subsystem".equals(address.getLastElement().getKey())) {
if (attrName.contains("jdbc")) {
// Ignore jdbc store attributes unless jdbc store is enabled
return !resourceNoDefaults.hasDefined("use-jdbc-store") || !resourceNoDefaults.get("use-jdbc-store").asBoolean();
} else if (attrName.contains("journal")) {
// Ignore journal store attributes unless journal store is enabled
return !resourceNoDefaults.hasDefined("use-journal-store") || !resourceNoDefaults.get("use-journal-store").asBoolean();
}
}
return false;
}
Aggregations