Search in sources :

Example 76 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project keycloak by keycloak.

the class KeycloakSubsystemParser method readSingleLogout.

void readSingleLogout(ModelNode addIdentityProvider, XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode slo = addIdentityProvider.get(Constants.Model.SINGLE_LOGOUT);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);
        SimpleAttributeDefinition attr = SingleLogoutDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, slo, reader);
    }
    ParseUtils.requireNoContent(reader);
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 77 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project keycloak by keycloak.

the class KeycloakSubsystemParser method writeCertificate.

void writeCertificate(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    ModelNode value = model.get(Constants.Model.CERTIFICATE_ALIAS);
    if (!value.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.CERTIFICATE);
    SimpleAttributeDefinition attr = KeyStoreCertificateDefinition.CERTIFICATE_ALIAS;
    attr.getAttributeMarshaller().marshallAsAttribute(attr, model, false, writer);
    writer.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 78 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project keycloak by keycloak.

the class KeycloakSubsystemParser method readSingleSignOn.

void readSingleSignOn(ModelNode addIdentityProvider, XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode sso = addIdentityProvider.get(Constants.Model.SINGLE_SIGN_ON);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);
        SimpleAttributeDefinition attr = SingleSignOnDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, sso, reader);
    }
    ParseUtils.requireNoContent(reader);
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 79 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project keycloak by keycloak.

the class KeycloakSubsystemParser method readKey.

void readKey(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddr) throws XMLStreamException {
    PathAddress addr = PathAddress.pathAddress(parentAddr, PathElement.pathElement(Constants.Model.KEY, "key-" + list.size()));
    ModelNode addKey = Util.createAddOperation(addr);
    list.add(addKey);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);
        SimpleAttributeDefinition attr = KeyDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, addKey, reader);
    }
    Set<String> parsedElements = new HashSet<>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (parsedElements.contains(tagName)) {
            // all sub-elements of the key type should occur only once.
            throw ParseUtils.unexpectedElement(reader);
        }
        if (Constants.XML.KEY_STORE.equals(tagName)) {
            readKeyStore(addKey, reader);
        } else if (Constants.XML.PRIVATE_KEY_PEM.equals(tagName) || Constants.XML.PUBLIC_KEY_PEM.equals(tagName) || Constants.XML.CERTIFICATE_PEM.equals(tagName)) {
            readNoAttrElementContent(KeyDefinition.lookupElement(tagName), addKey, reader);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parsedElements.add(tagName);
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) HashSet(java.util.HashSet)

Example 80 with SimpleAttributeDefinition

use of org.jboss.as.controller.SimpleAttributeDefinition in project keycloak by keycloak.

the class KeycloakSubsystemParser method writeKeys.

void writeKeys(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (!model.isDefined()) {
        return;
    }
    boolean contains = false;
    for (Property key : model.asPropertyList()) {
        if (!contains) {
            writer.writeStartElement(Constants.XML.KEYS);
            contains = true;
        }
        writer.writeStartElement(Constants.XML.KEY);
        ModelNode keyAttributes = key.getValue();
        for (SimpleAttributeDefinition attr : KeyDefinition.ATTRIBUTES) {
            attr.getAttributeMarshaller().marshallAsAttribute(attr, keyAttributes, false, writer);
        }
        for (SimpleAttributeDefinition attr : KeyDefinition.ELEMENTS) {
            attr.getAttributeMarshaller().marshallAsElement(attr, keyAttributes, false, writer);
        }
        writeKeyStore(writer, keyAttributes.get(Constants.Model.KEY_STORE));
        writer.writeEndElement();
    }
    if (contains) {
        writer.writeEndElement();
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)89 ModelNode (org.jboss.dmr.ModelNode)47 PathAddress (org.jboss.as.controller.PathAddress)14 Property (org.jboss.dmr.Property)13 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)9 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)9 HashSet (java.util.HashSet)8 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)8 XMLStreamException (javax.xml.stream.XMLStreamException)7 OperationContext (org.jboss.as.controller.OperationContext)4 ArrayList (java.util.ArrayList)3 AbstractAttributeDefinitionBuilder (org.jboss.as.controller.AbstractAttributeDefinitionBuilder)3 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)3 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)3 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)3 SimpleMapAttributeDefinition (org.jboss.as.controller.SimpleMapAttributeDefinition)3 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)3 ClearWorkManagerStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)2 WorkManagerRuntimeAttributeReadHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler)2