Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFLY-19078 [Community] - Update the elytron-oidc-client subsystem par…
…ser to enumerate schema versions
- Loading branch information
1 parent
6308993
commit 7426070
Showing
28 changed files
with
1,935 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ent/src/main/java/org/wildfly/extension/elytron/oidc/ElytronOidcClientSubsystemModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.extension.elytron.oidc; | ||
|
||
import org.jboss.as.controller.ModelVersion; | ||
import org.jboss.as.controller.SubsystemModel; | ||
|
||
/** | ||
* Enumeration of elytron-oidc-client subsystem model versions. | ||
* @author <a href="mailto:prpaul@redhat.com">Prarthona Paul</a> | ||
*/ | ||
|
||
enum ElytronOidcClientSubsystemModel implements SubsystemModel { | ||
VERSION_1_0_0(1, 0, 0), | ||
VERSION_2_0_0(2, 0, 0), | ||
VERSION_3_0_0(3, 0, 0), | ||
; | ||
static final ElytronOidcClientSubsystemModel CURRENT = VERSION_3_0_0; | ||
|
||
private final ModelVersion version; | ||
|
||
ElytronOidcClientSubsystemModel(int major, int minor, int micro) { | ||
this.version = ModelVersion.create(major, minor, micro); | ||
} | ||
|
||
@Override | ||
public ModelVersion getVersion() { | ||
return this.version; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...src/main/java/org/wildfly/extension/elytron/oidc/ElytronOidcClientSubsystemRegistrar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.extension.elytron.oidc; | ||
|
||
import org.jboss.as.controller.AttributeDefinition; | ||
import org.jboss.as.controller.AttributeMarshaller; | ||
import org.jboss.as.controller.AttributeParser; | ||
import org.jboss.as.controller.PathElement; | ||
import org.jboss.as.controller.SimpleAttributeDefinition; | ||
import org.jboss.as.controller.parsing.ParseUtils; | ||
import org.jboss.dmr.ModelNode; | ||
import org.jboss.staxmapper.XMLExtendedStreamReader; | ||
import org.wildfly.subsystem.resource.SubsystemResourceDefinitionRegistrar; | ||
import javax.xml.stream.XMLStreamException; | ||
import javax.xml.stream.XMLStreamWriter; | ||
import java.util.Collections; | ||
/** | ||
* @author <a href="mailto:prpaul@redhat.com">Prarthona Paul</a> | ||
*/ | ||
|
||
public class ElytronOidcClientSubsystemRegistrar { | ||
|
||
static final String NAME = "elytron-oidc-client"; | ||
static final PathElement PATH = SubsystemResourceDefinitionRegistrar.pathElement(NAME); | ||
static final AttributeParser SIMPLE_ATTRIBUTE_PARSER = new AttributeElementParser(); | ||
static final AttributeMarshaller SIMPLE_ATTRIBUTE_MARSHALLER = new AttributeElementMarshaller(); | ||
|
||
static class AttributeElementMarshaller extends AttributeMarshaller.AttributeElementMarshaller { | ||
@Override | ||
public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException { | ||
writer.writeStartElement(attribute.getXmlName()); | ||
marshallElementContent(resourceModel.get(attribute.getName()).asString(), writer); | ||
writer.writeEndElement(); | ||
} | ||
} | ||
|
||
static class AttributeElementParser extends AttributeParser { | ||
|
||
@Override | ||
public boolean isParseAsElement() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void parseElement(AttributeDefinition attribute, XMLExtendedStreamReader reader, ModelNode operation) throws XMLStreamException { | ||
assert attribute instanceof SimpleAttributeDefinition; | ||
if (operation.hasDefined(attribute.getName())) { | ||
throw ParseUtils.unexpectedElement(reader); | ||
} else if (attribute.getXmlName().equals(reader.getLocalName())) { | ||
((SimpleAttributeDefinition) attribute).parseAndSetParameter(reader.getElementText(), operation, reader); | ||
} else { | ||
throw ParseUtils.unexpectedElement(reader, Collections.singleton(attribute.getXmlName())); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.