repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
null
wildfly-main/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemAdd.java
/* * JBoss, Home of Professional Open Source. * * Copyright 2021 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wildfly.extension.opentelemetry; import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemDefinition.CONFIG_SUPPLIER; import org.jboss.as.controller.AbstractBoottimeAddStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.server.AbstractDeploymentChainStep; import org.jboss.as.server.DeploymentProcessorTarget; import org.jboss.as.server.deployment.Phase; import org.jboss.dmr.ModelNode; import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig; /** * Handler responsible for adding the subsystem resource to the model * * @author <a href="jasondlee@redhat.com">Jason Lee</a> */ class OpenTelemetrySubsystemAdd extends AbstractBoottimeAddStepHandler { OpenTelemetrySubsystemAdd() { super(OpenTelemetrySubsystemDefinition.ATTRIBUTES); } /** * {@inheritDoc} */ @Override protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { super.performBoottime(context, operation, model); final WildFlyOpenTelemetryConfig config = new WildFlyOpenTelemetryConfig( OpenTelemetrySubsystemDefinition.SERVICE_NAME.resolveModelAttribute(context, model).asStringOrNull(), OpenTelemetrySubsystemDefinition.EXPORTER.resolveModelAttribute(context, model).asString(), OpenTelemetrySubsystemDefinition.ENDPOINT.resolveModelAttribute(context, model).asStringOrNull(), OpenTelemetrySubsystemDefinition.BATCH_DELAY.resolveModelAttribute(context, model).asLongOrNull(), OpenTelemetrySubsystemDefinition.MAX_QUEUE_SIZE.resolveModelAttribute(context, model).asLongOrNull(), OpenTelemetrySubsystemDefinition.MAX_EXPORT_BATCH_SIZE.resolveModelAttribute(context, model).asLongOrNull(), OpenTelemetrySubsystemDefinition.EXPORT_TIMEOUT.resolveModelAttribute(context, model).asLongOrNull(), OpenTelemetrySubsystemDefinition.SAMPLER.resolveModelAttribute(context, model).asStringOrNull(), OpenTelemetrySubsystemDefinition.RATIO.resolveModelAttribute(context, model).asDoubleOrNull() ); CONFIG_SUPPLIER.accept(config); boolean mpTelemetryInstalled = context.getCapabilityServiceSupport().hasCapability("org.wildfly.extension.microprofile.telemetry"); context.addStep(new AbstractDeploymentChainStep() { @Override public void execute(DeploymentProcessorTarget processorTarget) { processorTarget.addDeploymentProcessor( OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, 0x1910, new OpenTelemetryDependencyProcessor() ); processorTarget.addDeploymentProcessor( OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, 0x3810, new OpenTelemetryDeploymentProcessor(!mpTelemetryInstalled, config)); } }, OperationContext.Stage.RUNTIME); } }
3,968
45.694118
139
java
null
wildfly-main/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDeploymentProcessor.java
/* * JBoss, Home of Professional Open Source. * * Copyright 2022 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wildfly.extension.opentelemetry; import static org.jboss.as.weld.Capabilities.WELD_CAPABILITY_NAME; import static org.wildfly.extension.opentelemetry.OpenTelemetryExtensionLogger.OTEL_LOGGER; import java.util.HashMap; import java.util.Map; import io.smallrye.opentelemetry.implementation.cdi.OpenTelemetryExtension; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.ee.structure.DeploymentType; import org.jboss.as.ee.structure.DeploymentTypeMarker; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.as.weld.WeldCapability; import org.wildfly.extension.opentelemetry.api.OpenTelemetryCdiExtension; import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig; class OpenTelemetryDeploymentProcessor implements DeploymentUnitProcessor { private final boolean useServerConfig; private final WildFlyOpenTelemetryConfig serverConfig; public OpenTelemetryDeploymentProcessor(boolean useServerConfig, WildFlyOpenTelemetryConfig serverConfig) { this.useServerConfig = useServerConfig; this.serverConfig = serverConfig; } @Override public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws DeploymentUnitProcessingException { OTEL_LOGGER.debug("OpenTelemetry Subsystem is processing deployment"); final DeploymentUnit deploymentUnit = deploymentPhaseContext.getDeploymentUnit(); if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) { return; } try { final WeldCapability weldCapability = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT) .getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class); if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) { // Jakarta RESTful Web Services require Jakarta Contexts and Dependency Injection. Without Jakarta // Contexts and Dependency Injection, there's no integration needed OTEL_LOGGER.debug("The deployment does not have Jakarta Contexts and Dependency Injection enabled. Skipping OpenTelemetry integration."); return; } Map<String, String> config = new HashMap<>(serverConfig.properties()); config.put(WildFlyOpenTelemetryConfig.OTEL_SERVICE_NAME, getServiceName(deploymentUnit)); weldCapability.registerExtensionInstance(new OpenTelemetryCdiExtension(useServerConfig, config), deploymentUnit); weldCapability.registerExtensionInstance(new OpenTelemetryExtension(), deploymentUnit); } catch (CapabilityServiceSupport.NoSuchCapabilityException e) { // We should not be here since the subsystem depends on weld capability. Just in case ... throw OTEL_LOGGER.deploymentRequiresCapability(deploymentPhaseContext.getDeploymentUnit().getName(), WELD_CAPABILITY_NAME); } } private String getServiceName(DeploymentUnit deploymentUnit) { String serviceName = deploymentUnit.getServiceName().getSimpleName(); if (null != deploymentUnit.getParent()) { serviceName = deploymentUnit.getParent().getServiceName().getSimpleName() + "!" + serviceName; } return serviceName; } }
4,299
47.863636
153
java
null
wildfly-main/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryConfigurationConstants.java
/* * JBoss, Home of Professional Open Source. * * Copyright 2021 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wildfly.extension.opentelemetry; import java.util.Optional; import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig; final class OpenTelemetryConfigurationConstants { private OpenTelemetryConfigurationConstants() {} private String INSTRUMENTATION_NAME = "io.smallrye.opentelemetry"; private String INSTRUMENTATION_VERSION = Optional.ofNullable(WildFlyOpenTelemetryConfig.class.getPackage().getImplementationVersion()) .orElse("SNAPSHOT"); static final String SERVICE_NAME = "service-name"; static final String EXPORTER_TYPE = "exporter-type"; static final String ENDPOINT = "endpoint"; static final String SPAN_PROCESSOR_TYPE = "span-processor-type"; static final String BATCH_DELAY = "batch-delay"; static final String MAX_QUEUE_SIZE = "max-queue-size"; static final String MAX_EXPORT_BATCH_SIZE = "max-export-batch-size"; static final String EXPORT_TIMEOUT = "export-timeout"; static final String SAMPLER_TYPE = "sampler-type"; static final String RATIO = "ratio"; static final String TYPE = "type"; // Groups static final String GROUP_EXPORTER = "exporter"; static final String GROUP_SPAN_PROCESSOR = "span-processor"; static final String GROUP_SAMPLER = "sampler"; static final String OPENTELEMETRY_CAPABILITY_NAME = "org.wildfly.extension.opentelemetry"; }
2,098
39.365385
138
java
null
wildfly-main/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemDefinition.java
/* * JBoss, Home of Professional Open Source. * * Copyright 2021 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wildfly.extension.opentelemetry; import static org.jboss.as.weld.Capabilities.WELD_CAPABILITY_NAME; import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.GROUP_EXPORTER; import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.GROUP_SAMPLER; import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.GROUP_SPAN_PROCESSOR; import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.OPENTELEMETRY_CAPABILITY_NAME; import java.util.Arrays; import java.util.Collection; import java.util.function.Consumer; import java.util.function.Supplier; import io.smallrye.opentelemetry.api.OpenTelemetryConfig; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PersistentResourceDefinition; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.validation.StringAllowedValuesValidator; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /* * For future reference: https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#jaeger-exporter */ class OpenTelemetrySubsystemDefinition extends PersistentResourceDefinition { static final String OPENTELEMETRY_MODULE = "org.wildfly.extension.opentelemetry"; private static final String[] ALLOWED_EXPORTERS = {"jaeger", "otlp"}; private static final String[] ALLOWED_SAMPLERS = {"on", "off", "ratio"}; private static final String[] ALLOWED_SPAN_PROCESSORS = {"batch", "simple"}; public static final String DEFAULT_ENDPOINT = "http://localhost:14250"; public static final String API_MODULE = "org.wildfly.extension.opentelemetry-api"; public static final String[] EXPORTED_MODULES = { "io.opentelemetry.api", "io.opentelemetry.context", "io.opentelemetry.exporter", "io.opentelemetry.sdk", "io.smallrye.opentelemetry" }; static final RuntimeCapability<Void> OPENTELEMETRY_CAPABILITY = RuntimeCapability.Builder.of(OPENTELEMETRY_CAPABILITY_NAME) .addRequirements(WELD_CAPABILITY_NAME) .build(); public static final WildFlyOpenTelemetryConfigSupplier CONFIG_SUPPLIER = new WildFlyOpenTelemetryConfigSupplier(); static final RuntimeCapability<WildFlyOpenTelemetryConfigSupplier> OPENTELEMETRY_CONFIG_CAPABILITY = RuntimeCapability.Builder.of(OPENTELEMETRY_MODULE + ".config", false, CONFIG_SUPPLIER).build(); @Deprecated public static final SimpleAttributeDefinition SERVICE_NAME = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.SERVICE_NAME, ModelType.STRING, true) .setAllowExpression(true) .setRestartAllServices() .build(); public static final SimpleAttributeDefinition EXPORTER = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.EXPORTER_TYPE, ModelType.STRING, true) .setAllowExpression(true) .setAttributeGroup(GROUP_EXPORTER) .setXmlName(OpenTelemetryConfigurationConstants.TYPE) .setDefaultValue(new ModelNode("jaeger")) .setValidator(new StringAllowedValuesValidator(ALLOWED_EXPORTERS)) .setRestartAllServices() .build(); public static final SimpleAttributeDefinition ENDPOINT = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.ENDPOINT, ModelType.STRING, true) .setAllowExpression(true) .setAttributeGroup(GROUP_EXPORTER) .setRestartAllServices() .setDefaultValue(new ModelNode(DEFAULT_ENDPOINT)) .build(); @Deprecated public static final SimpleAttributeDefinition SPAN_PROCESSOR_TYPE = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.SPAN_PROCESSOR_TYPE, ModelType.STRING, true) .setAllowExpression(true) .setXmlName(OpenTelemetryConfigurationConstants.TYPE) .setAttributeGroup(GROUP_SPAN_PROCESSOR) .setRestartAllServices() .setDefaultValue(new ModelNode("batch")) .setValidator(new StringAllowedValuesValidator(ALLOWED_SPAN_PROCESSORS)) .build(); public static final SimpleAttributeDefinition BATCH_DELAY = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.BATCH_DELAY, ModelType.LONG, true) .setAllowExpression(true) .setAttributeGroup(GROUP_SPAN_PROCESSOR) .setRestartAllServices() .setDefaultValue(new ModelNode(5000)) .build(); public static final SimpleAttributeDefinition MAX_QUEUE_SIZE = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.MAX_QUEUE_SIZE, ModelType.LONG, true) .setAllowExpression(true) .setAttributeGroup(GROUP_SPAN_PROCESSOR) .setRestartAllServices() .setDefaultValue(new ModelNode(2048)) .build(); public static final SimpleAttributeDefinition MAX_EXPORT_BATCH_SIZE = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.MAX_EXPORT_BATCH_SIZE, ModelType.LONG, true) .setAllowExpression(true) .setAttributeGroup(GROUP_SPAN_PROCESSOR) .setRestartAllServices() .setDefaultValue(new ModelNode(512)) .build(); public static final SimpleAttributeDefinition EXPORT_TIMEOUT = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.EXPORT_TIMEOUT, ModelType.LONG, true) .setAllowExpression(true) .setAttributeGroup(GROUP_SPAN_PROCESSOR) .setRestartAllServices() .setDefaultValue(new ModelNode(30000)) .build(); public static final SimpleAttributeDefinition SAMPLER = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.SAMPLER_TYPE, ModelType.STRING, true) .setAllowExpression(true) .setXmlName(OpenTelemetryConfigurationConstants.TYPE) .setAttributeGroup(GROUP_SAMPLER) .setValidator(new StringAllowedValuesValidator(ALLOWED_SAMPLERS)) .setRestartAllServices() .build(); public static final SimpleAttributeDefinition RATIO = SimpleAttributeDefinitionBuilder .create(OpenTelemetryConfigurationConstants.RATIO, ModelType.DOUBLE, true) .setAllowExpression(true) .setAttributeGroup(GROUP_SAMPLER) .setValidator((parameterName, value) -> { if (value.isDefined() && value.getType() != ModelType.EXPRESSION) { double val = value.asDouble(); if (val < 0.0 || val > 1.0) { throw new OperationFailedException(OpenTelemetryExtensionLogger.OTEL_LOGGER.invalidRatio()); } } }) .setRestartAllServices() .build(); public static final AttributeDefinition[] ATTRIBUTES = { SERVICE_NAME, EXPORTER, ENDPOINT, SPAN_PROCESSOR_TYPE, BATCH_DELAY, MAX_QUEUE_SIZE, MAX_EXPORT_BATCH_SIZE, EXPORT_TIMEOUT, SAMPLER, RATIO }; protected OpenTelemetrySubsystemDefinition() { super(new SimpleResourceDefinition.Parameters(OpenTelemetrySubsystemExtension.SUBSYSTEM_PATH, OpenTelemetrySubsystemExtension.SUBSYSTEM_RESOLVER) .setAddHandler(new OpenTelemetrySubsystemAdd()) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setCapabilities(OPENTELEMETRY_CAPABILITY, OPENTELEMETRY_CONFIG_CAPABILITY) ); } @Override public Collection<AttributeDefinition> getAttributes() { return Arrays.asList(ATTRIBUTES); } static class WildFlyOpenTelemetryConfigSupplier implements Supplier<OpenTelemetryConfig>, Consumer<OpenTelemetryConfig> { private OpenTelemetryConfig config; @Override public void accept(OpenTelemetryConfig openTelemetryConfig) { this.config = openTelemetryConfig; } @Override public OpenTelemetryConfig get() { return config; } } }
9,430
46.631313
132
java
null
wildfly-main/ee-dist/src/test/java/org/wildfly/dist/subsystem/xml/XSDValidationUnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.dist.subsystem.xml; import org.junit.Test; import org.wildfly.test.distribution.validation.AbstractValidationUnitTest; /** * A XSDValidationUnitTestCase. * * @author <a href="alex@jboss.com">Alexey Loubyansky</a> * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> * @version $Revision: 1.1 $ */ public class XSDValidationUnitTestCase extends AbstractValidationUnitTest { @Test public void testJBossXsds() throws Exception { jbossXsdsTest(); } }
1,534
36.439024
75
java
null
wildfly-main/ee-dist/src/test/java/org/wildfly/dist/subsystem/xml/StandardConfigsXMLValidationUnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.dist.subsystem.xml; import org.junit.Test; import org.wildfly.test.distribution.validation.AbstractValidationUnitTest; /** * Performs validation against their xsd of the server configuration files in the distribution. * * @author Brian Stansberry */ public class StandardConfigsXMLValidationUnitTestCase extends AbstractValidationUnitTest { @Test public void testHost() throws Exception { parseXml("domain/configuration/host.xml"); } @Test public void testHostSecondary() throws Exception { parseXml("domain/configuration/host-secondary.xml"); } @Test public void testHostPrimary() throws Exception { parseXml("domain/configuration/host-primary.xml"); } @Test public void testDomain() throws Exception { parseXml("domain/configuration/domain.xml"); } @Test public void testStandalone() throws Exception { parseXml("standalone/configuration/standalone.xml"); } @Test public void testStandaloneHA() throws Exception { parseXml("standalone/configuration/standalone-ha.xml"); } @Test public void testStandaloneFull() throws Exception { parseXml("standalone/configuration/standalone-full.xml"); } //TODO Leave commented out until domain-jts.xml is definitely removed from the configuration // @Test // public void testDomainJTS() throws Exception { // parseXml("docs/examples/configs/domain-jts.xml"); // } // @Test public void testStandaloneEC2HA() throws Exception { parseXml("docs/examples/configs/standalone-ec2-ha.xml"); } @Test public void testStandaloneEC2FullHA() throws Exception { parseXml("docs/examples/configs/standalone-ec2-full-ha.xml"); } @Test public void testStandaloneGossipHA() throws Exception { parseXml("docs/examples/configs/standalone-gossip-ha.xml"); } @Test public void testStandaloneGossipFullHA() throws Exception { parseXml("docs/examples/configs/standalone-gossip-full-ha.xml"); } @Test public void testStandaloneJTS() throws Exception { parseXml("docs/examples/configs/standalone-jts.xml"); } @Test public void testStandaloneMinimalistic() throws Exception { parseXml("docs/examples/configs/standalone-minimalistic.xml"); } @Test public void testStandaloneXTS() throws Exception { parseXml("docs/examples/configs/standalone-xts.xml"); } @Test public void testStandaloneRTS() throws Exception { parseXml("docs/examples/configs/standalone-rts.xml"); } @Test public void testStandaloneGenericJMS() throws Exception { parseXml("docs/examples/configs/standalone-genericjms.xml"); } }
3,821
30.586777
96
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/IDMSubsystem_2_0_UnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Set; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.as.subsystem.test.KernelServicesBuilder; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; import org.wildfly.extension.picketlink.idm.IDMExtension; /** * @author Pedro Igor */ public class IDMSubsystem_2_0_UnitTestCase extends AbstractSubsystemBaseTest { public IDMSubsystem_2_0_UnitTestCase() { super(IDMExtension.SUBSYSTEM_NAME, new IDMExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("identity-management-subsystem-2.0.xml"); } @Override protected String getSubsystemXsdPath() throws Exception { return "schema/wildfly-picketlink-idm_2_0.xsd"; } @Test public void testExpressions() throws Exception { standardSubsystemTest("identity-management-subsystem-expressions-2.0.xml"); } @Test public void testValidation() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); assertTrue(mainServices.isSuccessfulBoot()); // LDAP identity store must have a mapping ModelNode op = Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/mapping=Agent")); mainServices.executeForResult(op); // removing 1 is ok op = Util.createEmptyOperation("composite", PathAddress.EMPTY_ADDRESS); ModelNode steps = op.get("steps"); steps.add(Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/mapping=User"))); steps.add(Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/mapping=Role"))); steps.add(Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/mapping=Group"))); steps.add(Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/mapping=Grant"))); executeForFailure(mainServices, op, "WFLYPL0057"); // removing all is not ok // identity store must have a supported type (removal) op = Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/supported-types=supported-types/supported-type=IdentityType")); mainServices.executeForResult(op); // removing 1 is ok op = Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager/identity-configuration=ldap.config/ldap-store=ldap-store/supported-types=supported-types/supported-type=Relationship")); executeForFailure(mainServices, op, "WFLYPL0056"); // removing all is not ok // identity store must have a supported type (not supports all) op = Util.getWriteAttributeOperation(getAddress("partition-manager=file.based.partition.manager/identity-configuration=file.config/file-store=file-store/supported-types=supported-types"), "supports-all", "false"); executeForFailure(mainServices, op, "WFLYPL0056"); // PM must have an identity config op = Util.createRemoveOperation(getAddress("partition-manager=file.based.partition.manager/identity-configuration=file.config")); executeForFailure(mainServices, op, "WFLYPL0054"); // complete PM removal works op = Util.createRemoveOperation(getAddress("partition-manager=ldap.based.partition.manager")); mainServices.executeForResult(op); op = Util.getReadResourceOperation(getAddress("partition-manager=ldap.based.partition.manager")); executeForFailure(mainServices, op, "WFLYCTL0216"); // confirm it's gone } @Override protected void assertRemoveSubsystemResources(KernelServices kernelServices, Set<PathAddress> ignoredChildAddresses) { // we can not remove resources and leave subsystem in invalid state } private static PathAddress getAddress(String cliStyleAddress) { return PathAddress.parseCLIStyleAddress("/subsystem=picketlink-identity-management/" + cliStyleAddress); } private static void executeForFailure(KernelServices services, ModelNode op, String expectedFailureCode) { ModelNode resp = services.executeOperation(op); Assert.assertEquals(resp.toString(), "failed", resp.get("outcome").asString()); String failDesc = resp.get("failure-description").asString(); Assert.assertTrue(resp.toString(), failDesc.contains(expectedFailureCode)); } protected AdditionalInitialization createAdditionalInitialization() { return AdditionalInitialization.ADMIN_ONLY_HC; } }
6,435
50.079365
221
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/FederationSubsystem_2_0_UnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import java.io.IOException; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.junit.Test; import org.wildfly.extension.picketlink.federation.FederationExtension; /** * @author Pedro Igor */ public class FederationSubsystem_2_0_UnitTestCase extends AbstractSubsystemBaseTest { public FederationSubsystem_2_0_UnitTestCase() { super(FederationExtension.SUBSYSTEM_NAME, new FederationExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("federation-subsystem-2.0.xml"); } @Override protected String getSubsystemXsdPath() throws Exception { return "schema/wildfly-picketlink-federation_2_0.xsd"; } @Test public void testExpressions() throws Exception { standardSubsystemTest("federation-subsystem-expressions-2.0.xml"); } protected AdditionalInitialization createAdditionalInitialization() { return AdditionalInitialization.ADMIN_ONLY_HC; } }
2,150
34.262295
85
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/MigrateOperationTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.wildfly.extension.picketlink.federation.FederationExtension.SUBSYSTEM_NAME; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ProcessType; import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry; import org.jboss.as.controller.descriptions.common.ControllerResolver; import org.jboss.as.controller.extension.ExtensionRegistry; import org.jboss.as.controller.extension.ExtensionRegistryType; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; import org.jboss.as.model.test.ModelTestUtils; import org.jboss.as.subsystem.test.AbstractSubsystemTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Test; import org.keycloak.subsystem.adapter.saml.extension.KeycloakSamlExtension; import org.wildfly.extension.picketlink.federation.FederationExtension; /** * Test case for the picketlink-federation migrate op. * * @author <a href="mailto:fjuma@redhat.com">Farah Juma</a> */ public class MigrateOperationTestCase extends AbstractSubsystemTest { public static final String KEYCLOAK_SAML_SUBSYSTEM_NAME = "keycloak-saml"; public MigrateOperationTestCase() { super(SUBSYSTEM_NAME, new FederationExtension()); } @Test public void testMigrateDefaultPicketLinkFederationConfig() throws Exception { String subsystemXml = readResource("federation-subsystem-migration-default-config.xml"); NewSubsystemAdditionalInitialization additionalInitialization = new NewSubsystemAdditionalInitialization(); KernelServices services = createKernelServicesBuilder(additionalInitialization).setSubsystemXml(subsystemXml).build(); ModelNode model = services.readWholeModel(); assertFalse(additionalInitialization.extensionAdded); assertTrue(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined()); assertFalse(model.get(SUBSYSTEM, KEYCLOAK_SAML_SUBSYSTEM_NAME).isDefined()); ModelNode migrateOp = new ModelNode(); migrateOp.get(OP).set("migrate"); migrateOp.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME); ModelNode response = services.executeOperation(migrateOp); checkOutcome(response); ModelNode warnings = response.get(RESULT, "migration-warnings"); assertEquals(warnings.toString(), 0, warnings.asList().size()); model = services.readWholeModel(); assertTrue(additionalInitialization.extensionAdded); assertFalse(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined()); assertTrue(model.get(SUBSYSTEM, KEYCLOAK_SAML_SUBSYSTEM_NAME).isDefined()); ModelNode newSubsystem = model.get(SUBSYSTEM, KEYCLOAK_SAML_SUBSYSTEM_NAME); ModelNode secureDeployment = newSubsystem.get("secure-deployment"); assertFalse(secureDeployment.isDefined()); } @Test public void testMigrateNonEmptyPicketLinkFederationConfig() throws Exception { String subsystemXml = readResource("federation-subsystem-migration-non-empty-config.xml"); NewSubsystemAdditionalInitialization additionalInitialization = new NewSubsystemAdditionalInitialization(); KernelServices services = createKernelServicesBuilder(additionalInitialization).setSubsystemXml(subsystemXml).build(); ModelNode model = services.readWholeModel(); assertFalse(additionalInitialization.extensionAdded); assertTrue(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined()); assertFalse(model.get(SUBSYSTEM, KEYCLOAK_SAML_SUBSYSTEM_NAME).isDefined()); ModelNode migrateOp = new ModelNode(); migrateOp.get(OP).set("migrate"); migrateOp.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME); ModelNode response = services.executeOperation(migrateOp); ModelTestUtils.checkFailed(response); model = services.readWholeModel(); assertTrue(additionalInitialization.extensionAdded); // op failed so legacy subsystem config still present assertTrue(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined()); assertFalse(model.get(SUBSYSTEM, KEYCLOAK_SAML_SUBSYSTEM_NAME).isDefined()); } private static class NewSubsystemAdditionalInitialization extends AdditionalInitialization { KeycloakSamlExtension newSubsystem = new KeycloakSamlExtension(); boolean extensionAdded = false; @Override protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) { rootRegistration.registerSubModel(new SimpleResourceDefinition(PathElement.pathElement(EXTENSION), ControllerResolver.getResolver(EXTENSION), new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { extensionAdded = true; newSubsystem.initialize(extensionRegistry.getExtensionContext("org.keycloak.keycloak-saml-adapter-subsystem", rootRegistration, ExtensionRegistryType.SERVER)); } }, null)); } @Override protected ProcessType getProcessType() { return ProcessType.HOST_CONTROLLER; } @Override protected RunningMode getRunningMode() { return RunningMode.ADMIN_ONLY; } } }
7,511
46.847134
212
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/InvalidAttributeManagerDeclarationUnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import static org.junit.Assert.assertFalse; import java.io.IOException; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.as.subsystem.test.KernelServicesBuilder; import org.junit.Test; import org.wildfly.extension.picketlink.federation.FederationExtension; /** * @author Pedro Igor */ public class InvalidAttributeManagerDeclarationUnitTestCase extends AbstractSubsystemBaseTest { public InvalidAttributeManagerDeclarationUnitTestCase() { super(FederationExtension.SUBSYSTEM_NAME, new FederationExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("federation-subsystem-invalid-attribute-manager.xml"); } @Test public void testSubsystem() throws Exception { System.setProperty("jboss.server.data.dir", System.getProperty("java.io.tmpdir")); System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir")); System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir")); KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); assertFalse(mainServices.isSuccessfulBoot()); } protected AdditionalInitialization createAdditionalInitialization() { return AdditionalInitialization.ADMIN_ONLY_HC; } }
2,640
38.41791
137
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/RoleGeneratorDeclarationUnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import static org.junit.Assert.assertFalse; import java.io.IOException; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.as.subsystem.test.KernelServicesBuilder; import org.junit.Test; import org.wildfly.extension.picketlink.federation.FederationExtension; /** * @author Pedro Igor */ public class RoleGeneratorDeclarationUnitTestCase extends AbstractSubsystemBaseTest { public RoleGeneratorDeclarationUnitTestCase() { super(FederationExtension.SUBSYSTEM_NAME, new FederationExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("federation-subsystem-invalid-role-generator.xml"); } @Test public void testSubsystem() throws Exception { System.setProperty("jboss.server.data.dir", System.getProperty("java.io.tmpdir")); System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir")); System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir")); KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); assertFalse(mainServices.isSuccessfulBoot()); } protected AdditionalInitialization createAdditionalInitialization() { return AdditionalInitialization.ADMIN_ONLY_HC; } }
2,617
38.074627
137
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/FederationSubsystem_1_0_UnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import org.jboss.as.subsystem.test.AbstractSubsystemTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Test; import org.wildfly.extension.picketlink.federation.FederationExtension; /** * @author Pedro Igor */ public class FederationSubsystem_1_0_UnitTestCase extends AbstractSubsystemTest { public FederationSubsystem_1_0_UnitTestCase() { super(FederationExtension.SUBSYSTEM_NAME, new FederationExtension()); } @Test public void testParseAndMarshalModel() throws Exception { //Parse the subsystem xml and install into the first controller String subsystemXml = readResource("federation-subsystem-1.0.xml"); KernelServices servicesA = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC) .setSubsystemXml(subsystemXml) .build(); //Get the model and the persisted xml from the first controller ModelNode modelA = servicesA.readWholeModel(); String marshalled = servicesA.getPersistedSubsystemXml(); servicesA.shutdown(); //Install the persisted xml from the first controller into a second controller KernelServices servicesB = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC) .setSubsystemXml(marshalled) .build(); ModelNode modelB = servicesB.readWholeModel(); //Make sure the models from the two controllers are identical super.compare(modelA, modelB); assertRemoveSubsystemResources(servicesB); } }
2,732
40.409091
102
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/IDMSubsystem_1_0_UnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import org.jboss.as.subsystem.test.AbstractSubsystemTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Test; import org.wildfly.extension.picketlink.idm.IDMExtension; /** * @author Pedro Igor */ public class IDMSubsystem_1_0_UnitTestCase extends AbstractSubsystemTest { public IDMSubsystem_1_0_UnitTestCase() { super(IDMExtension.SUBSYSTEM_NAME, new IDMExtension()); } @Test public void testParseAndMarshalModel() throws Exception { //Parse the subsystem xml and install into the first controller String subsystemXml = readResource("identity-management-subsystem-1.0.xml"); KernelServices servicesA = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC) .setSubsystemXml(subsystemXml) .build(); //Get the model and the persisted xml from the first controller ModelNode modelA = servicesA.readWholeModel(); String marshalled = servicesA.getPersistedSubsystemXml(); servicesA.shutdown(); //Install the persisted xml from the first controller into a second controller KernelServices servicesB = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC) .setSubsystemXml(marshalled) .build(); ModelNode modelB = servicesB.readWholeModel(); //Make sure the models from the two controllers are identical super.compare(modelA, modelB); } }
2,647
40.375
102
java
null
wildfly-main/picketlink/src/test/java/org/wildfly/extension/picketlink/subsystem/IDMSubsystemExampleConfigurationUnitTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.subsystem; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Set; import org.jboss.as.controller.PathAddress; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.as.subsystem.test.KernelServicesBuilder; import org.junit.Test; import org.wildfly.extension.picketlink.idm.IDMExtension; /** * @author Pedro Igor */ public class IDMSubsystemExampleConfigurationUnitTestCase extends AbstractSubsystemBaseTest { public IDMSubsystemExampleConfigurationUnitTestCase() { super(IDMExtension.SUBSYSTEM_NAME, new IDMExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("identity-management-subsystem-example-2.0.xml"); } @Test public void testRuntime() throws Exception { System.setProperty("jboss.server.data.dir", System.getProperty("java.io.tmpdir")); System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir")); System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir")); KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); assertTrue(mainServices.isSuccessfulBoot()); } @Override protected void assertRemoveSubsystemResources(KernelServices kernelServices, Set<PathAddress> ignoredChildAddresses) { // we can not remove resources and leave subsystem in invalid state } protected AdditionalInitialization createAdditionalInitialization() { return AdditionalInitialization.ADMIN_ONLY_HC; } }
2,885
38
137
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/IDMSubsystemRootResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.ModelOnlyRemoveStepHandler; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.wildfly.extension.picketlink.idm.model.PartitionManagerResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class IDMSubsystemRootResourceDefinition extends SimpleResourceDefinition { public static final IDMSubsystemRootResourceDefinition INSTANCE = new IDMSubsystemRootResourceDefinition(); private IDMSubsystemRootResourceDefinition() { super(new Parameters(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, IDMExtension.SUBSYSTEM_NAME), IDMExtension.getResourceDescriptionResolver(IDMExtension.SUBSYSTEM_NAME)) .setAddHandler(new ModelOnlyAddStepHandler()) .setAddRestartLevel(OperationEntry.Flag.RESTART_NONE) .setRemoveHandler(ModelOnlyRemoveStepHandler.INSTANCE) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) ); setDeprecated(IDMExtension.DEPRECATED_SINCE); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { resourceRegistration.registerSubModel(PartitionManagerResourceDefinition.INSTANCE); } }
2,660
45.684211
119
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/Namespace.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.persistence.SubsystemMarshallingContext; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLElementWriter; import org.wildfly.extension.picketlink.idm.model.parser.IDMSubsystemReader_1_0; import org.wildfly.extension.picketlink.idm.model.parser.IDMSubsystemReader_2_0; import org.wildfly.extension.picketlink.idm.model.parser.IDMSubsystemWriter; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public enum Namespace { PICKETLINK_IDENTITY_MANAGEMENT_1_0(1, 0, 0, "1.0", new IDMSubsystemReader_1_0(), new IDMSubsystemWriter()), PICKETLINK_IDENTITY_MANAGEMENT_1_1(1, 1, 0, "1.1", new IDMSubsystemReader_2_0(), new IDMSubsystemWriter()), PICKETLINK_IDENTITY_MANAGEMENT_2_0(2, 0, 0, "2.0", new IDMSubsystemReader_2_0(), new IDMSubsystemWriter()), PICKETLINK_IDENTITY_MANAGEMENT_3_0(2, 0, 0, "2.0", new IDMSubsystemReader_2_0(), new IDMSubsystemWriter()); public static final Namespace CURRENT = PICKETLINK_IDENTITY_MANAGEMENT_3_0; public static final String BASE_URN = "urn:jboss:domain:picketlink-identity-management:"; private static final Map<String, Namespace> namespaces; static { final Map<String, Namespace> map = new HashMap<String, Namespace>(); for (Namespace namespace : values()) { final String name = namespace.getUri(); if (name != null) { map.put(name, namespace); } } namespaces = map; } private final int major; private final int minor; private final int patch; private final String urnSuffix; private final XMLElementReader<List<ModelNode>> reader; private final XMLElementWriter<SubsystemMarshallingContext> writer; Namespace(int major, int minor, int patch, String urnSuffix, XMLElementReader<List<ModelNode>> reader, XMLElementWriter<SubsystemMarshallingContext> writer) { this.major = major; this.minor = minor; this.patch = patch; this.urnSuffix = urnSuffix; this.reader = reader; this.writer = writer; } /** * Converts the specified uri to a {@link org.wildfly.extension.picketlink.idm.Namespace}. * * @param uri a namespace uri * * @return the matching namespace enum. */ public static Namespace forUri(String uri) { return namespaces.get(uri) == null ? null : namespaces.get(uri); } /** * @return the major */ public int getMajor() { return this.major; } /** * @return the minor */ public int getMinor() { return this.minor; } /** * * @return the patch */ public int getPatch() { return patch; } /** * Get the URI of this namespace. * * @return the URI */ public String getUri() { return BASE_URN + this.urnSuffix; } /** * Returns a xml reader for a specific namespace version. * * @return */ public XMLElementReader<List<ModelNode>> getXMLReader() { return this.reader; } /** * Returns a xml writer for a specific namespace version. * * @return */ public XMLElementWriter<SubsystemMarshallingContext> getXMLWriter() { return this.writer; } public ModelVersion getModelVersion() { if (this.patch > 0) { return ModelVersion.create(getMajor(), getMinor(), getPatch()); } return ModelVersion.create(getMajor(), getMinor()); } }
4,785
30.486842
111
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/IDMExtension.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm; import static org.wildfly.extension.picketlink.idm.Namespace.CURRENT; import static org.wildfly.extension.picketlink.idm.Namespace.PICKETLINK_IDENTITY_MANAGEMENT_1_0; import static org.wildfly.extension.picketlink.idm.Namespace.PICKETLINK_IDENTITY_MANAGEMENT_1_1; import java.util.Collections; import java.util.Set; import org.jboss.as.controller.ExtensionContext; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.DeprecatedResourceDescriptionResolver; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.extension.AbstractLegacyExtension; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.transform.ExtensionTransformerRegistration; import org.jboss.as.controller.transform.SubsystemTransformerRegistration; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.TransformationDescription.Tools; import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; import org.wildfly.extension.picketlink.idm.model.IdentityConfigurationResourceDefinition; import org.wildfly.extension.picketlink.idm.model.LDAPStoreResourceDefinition; import org.wildfly.extension.picketlink.idm.model.PartitionManagerResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class IDMExtension extends AbstractLegacyExtension { public static final String SUBSYSTEM_NAME = "picketlink-identity-management"; private static final String RESOURCE_NAME = IDMExtension.class.getPackage().getName() + ".LocalDescriptions"; private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(CURRENT.getMajor(), CURRENT.getMinor()); //deprecated in EAP 6.4 public static final ModelVersion DEPRECATED_SINCE = ModelVersion.create(2,0,0); public IDMExtension() { super("org.wildfly.extension.picketlink", SUBSYSTEM_NAME); } public static ResourceDescriptionResolver getResourceDescriptionResolver(final String keyPrefix) { return new DeprecatedResourceDescriptionResolver(SUBSYSTEM_NAME, keyPrefix, RESOURCE_NAME, IDMExtension.class.getClassLoader(), true, true); } @Override protected Set<ManagementResourceRegistration> initializeLegacyModel(ExtensionContext context) { SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION, true); ManagementResourceRegistration mrr = subsystem.registerSubsystemModel(IDMSubsystemRootResourceDefinition.INSTANCE); subsystem.registerXMLElementWriter(Namespace.CURRENT.getXMLWriter()); return Collections.singleton(mrr); } @Override protected void initializeLegacyParsers(ExtensionParsingContext context) { context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.CURRENT.getUri(), Namespace.CURRENT::getXMLReader); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, PICKETLINK_IDENTITY_MANAGEMENT_1_1.getUri(), PICKETLINK_IDENTITY_MANAGEMENT_1_1::getXMLReader); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, PICKETLINK_IDENTITY_MANAGEMENT_1_0.getUri(), PICKETLINK_IDENTITY_MANAGEMENT_1_0::getXMLReader); } public static final class TransformerRegistration implements ExtensionTransformerRegistration { @Override public String getSubsystemName() { return SUBSYSTEM_NAME; } @Override public void registerTransformers(SubsystemTransformerRegistration subsystemRegistration) { ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance(); ResourceTransformationDescriptionBuilder partitionManagerResourceBuilder = builder .addChildResource(PartitionManagerResourceDefinition.INSTANCE); ResourceTransformationDescriptionBuilder identityConfigResourceBuilder = partitionManagerResourceBuilder .addChildResource(IdentityConfigurationResourceDefinition.INSTANCE); ResourceTransformationDescriptionBuilder ldapTransfDescBuilder = identityConfigResourceBuilder .addChildResource(LDAPStoreResourceDefinition.INSTANCE); ldapTransfDescBuilder.getAttributeBuilder() .addRejectCheck(RejectAttributeChecker.DEFINED, LDAPStoreResourceDefinition.ACTIVE_DIRECTORY) .setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, LDAPStoreResourceDefinition.ACTIVE_DIRECTORY); ldapTransfDescBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, LDAPStoreResourceDefinition.UNIQUE_ID_ATTRIBUTE_NAME) .setDiscard(DiscardAttributeChecker.UNDEFINED, LDAPStoreResourceDefinition.UNIQUE_ID_ATTRIBUTE_NAME); Tools.register(builder.build(), subsystemRegistration, ModelVersion.create(1, 0)); } } }
6,388
52.689076
150
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/SupportedTypesResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class SupportedTypesResourceDefinition extends AbstractIDMResourceDefinition { public static final SimpleAttributeDefinition SUPPORTS_ALL = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SUPPORTS_ALL.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SupportedTypesResourceDefinition INSTANCE = new SupportedTypesResourceDefinition(SUPPORTS_ALL); private SupportedTypesResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.SUPPORTED_TYPES, address -> address.getParent().getParent().getParent(), attributes); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(SupportedTypeResourceDefinition.INSTANCE, resourceRegistration); } }
2,388
44.075472
170
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/IdentityConfigurationResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.NotEmptyResourceValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class IdentityConfigurationResourceDefinition extends AbstractIDMResourceDefinition { public static final IdentityConfigurationResourceDefinition INSTANCE = new IdentityConfigurationResourceDefinition(); private IdentityConfigurationResourceDefinition() { super(ModelElement.IDENTITY_CONFIGURATION, getModelValidators(), PathAddress::getParent); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(JPAStoreResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(FileStoreResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(LDAPStoreResourceDefinition.INSTANCE, resourceRegistration); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { NotEmptyResourceValidationStepHandler.INSTANCE }; } }
2,524
44.089286
121
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/CredentialHandlerResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.UniqueTypeValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class CredentialHandlerResourceDefinition extends AbstractIDMResourceDefinition { public static final SimpleAttributeDefinition CLASS_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CLASS_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CODE.getName()) .build(); public static final SimpleAttributeDefinition CODE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CODE.getName(), ModelType.STRING, true) .setValidator(EnumValidator.create(CredentialTypeEnum.class)) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_MODULE.getName(), ModelType.STRING, true) .setAllowExpression(true) .setRequires(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final CredentialHandlerResourceDefinition INSTANCE = new CredentialHandlerResourceDefinition(CLASS_NAME, CODE, MODULE); private CredentialHandlerResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.IDENTITY_STORE_CREDENTIAL_HANDLER, getModelValidators(), address -> address.getParent().getParent().getParent(), attributes); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { new UniqueTypeValidationStepHandler(ModelElement.IDENTITY_STORE_CREDENTIAL_HANDLER) { @Override protected String getType(OperationContext context, ModelNode model) throws OperationFailedException { return getCredentialType(context, model); } } }; } private static String getCredentialType(OperationContext context, ModelNode elementNode) throws OperationFailedException { ModelNode classNameNode = CLASS_NAME.resolveModelAttribute(context, elementNode); ModelNode codeNode = CODE.resolveModelAttribute(context, elementNode); if (classNameNode.isDefined()) { return classNameNode.asString(); } return CredentialTypeEnum.forType(codeNode.asString()); } }
4,100
48.409639
165
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/IDMConfigWriteAttributeHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.util.function.Function; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ModelOnlyWriteAttributeHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; /** * @author Pedro Silva */ public class IDMConfigWriteAttributeHandler extends ModelOnlyWriteAttributeHandler { private final ModelValidationStepHandler[] modelValidators; private final Function<PathAddress, PathAddress> partitionAddressProvider; IDMConfigWriteAttributeHandler(final ModelValidationStepHandler[] modelValidators, final Function<PathAddress, PathAddress> partitionAddressProvider, final AttributeDefinition... attributes) { super(attributes); this.modelValidators = modelValidators; this.partitionAddressProvider = partitionAddressProvider; } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (modelValidators != null) { for (ModelValidationStepHandler validator : modelValidators) { context.addStep(validator, OperationContext.Stage.MODEL); } } if (partitionAddressProvider != null) { context.addStep((context1, operation1) -> PartitionManagerResourceDefinition.validateModel(context, partitionAddressProvider.apply(context1.getCurrentAddress())), OperationContext.Stage.MODEL); } super.execute(context, operation); } }
2,790
40.656716
174
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/DefaultAddStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; /** * @author Pedro Silva */ public class DefaultAddStepHandler extends ModelOnlyAddStepHandler { private final List<ModelValidationStepHandler> modelValidators = new ArrayList<>(); private final Function<PathAddress, PathAddress> partitionAddressProvider; DefaultAddStepHandler(ModelValidationStepHandler[] modelValidators, final Function<PathAddress, PathAddress> partitionAddressProvider, final AttributeDefinition... attributes) { super(attributes); this.partitionAddressProvider = partitionAddressProvider; configureModelValidators(modelValidators); } private void configureModelValidators(ModelValidationStepHandler[] modelValidators) { if (modelValidators != null) { this.modelValidators.addAll(Arrays.asList(modelValidators)); } if (partitionAddressProvider != null) { this.modelValidators.add(new ModelValidationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PartitionManagerResourceDefinition.validateModel(context, partitionAddressProvider.apply(context.getCurrentAddress())); } }); } } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { performValidation(context); super.execute(context, operation); } protected void performValidation(OperationContext context) { for (ModelValidationStepHandler validatonStepHandler : this.modelValidators) { context.addStep(validatonStepHandler, OperationContext.Stage.MODEL); } } }
3,350
39.865854
139
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/LDAPStoreMappingResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.UniqueTypeValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class LDAPStoreMappingResourceDefinition extends AbstractIDMResourceDefinition { public static final SimpleAttributeDefinition CLASS_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CLASS_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CODE.getName()) .build(); public static final SimpleAttributeDefinition CODE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CODE.getName(), ModelType.STRING, true) .setValidator(EnumValidator.create(AttributedTypeEnum.class)) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_MODULE.getName(), ModelType.STRING, true) .setAllowExpression(true) .setRequires(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition BASE_DN = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_MAPPING_BASE_DN.getName(), ModelType.STRING, true) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition OBJECT_CLASSES = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_MAPPING_OBJECT_CLASSES.getName(), ModelType.STRING, true) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition PARENT_ATTRIBUTE = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_MAPPING_PARENT_ATTRIBUTE_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition RELATES_TO = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_MAPPING_RELATES_TO.getName(), ModelType.STRING, true) .setAllowExpression(true) .build(); public static final LDAPStoreMappingResourceDefinition INSTANCE = new LDAPStoreMappingResourceDefinition(CLASS_NAME, CODE, MODULE, BASE_DN, OBJECT_CLASSES, PARENT_ATTRIBUTE, RELATES_TO); private LDAPStoreMappingResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.LDAP_STORE_MAPPING, getModelValidators(), address -> address.getParent().getParent().getParent(), attributes); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(LDAPStoreAttributeResourceDefinition.INSTANCE, resourceRegistration); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { new UniqueTypeValidationStepHandler(ModelElement.LDAP_STORE_MAPPING) { @Override protected String getType(OperationContext context, ModelNode model) throws OperationFailedException { return getMappingType(context, model); } } }; } private static String getMappingType(OperationContext context, ModelNode elementNode) throws OperationFailedException { ModelNode classNameNode = CLASS_NAME.resolveModelAttribute(context, elementNode); ModelNode codeNode = CODE.resolveModelAttribute(context, elementNode); if (classNameNode.isDefined()) { return classNameNode.asString(); } return AttributedTypeEnum.forType(codeNode.asString()); } }
5,374
51.184466
194
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/AbstractIDMResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.util.function.Function; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.SimpleAttributeDefinition; import org.wildfly.extension.picketlink.common.model.AbstractResourceDefinition; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.idm.IDMExtension; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 18, 2012 */ public abstract class AbstractIDMResourceDefinition extends AbstractResourceDefinition { private final ModelValidationStepHandler[] modelValidators; private final Function<PathAddress, PathAddress> partitionAddressProvider; protected AbstractIDMResourceDefinition(final ModelElement modelElement, final Function<PathAddress, PathAddress> partitionAddressProvider, final SimpleAttributeDefinition... attributes) { this(modelElement, null, partitionAddressProvider, attributes); } protected AbstractIDMResourceDefinition(final ModelElement modelElement, final ModelValidationStepHandler[] modelValidators, final Function<PathAddress, PathAddress> partitionAddressProvider, final SimpleAttributeDefinition... attributes) { super(modelElement, new DefaultAddStepHandler(modelValidators, partitionAddressProvider, attributes), new DefaultRemoveStepHandler(partitionAddressProvider), IDMExtension.getResourceDescriptionResolver(modelElement.getName()), attributes); this.modelValidators = modelValidators; this.partitionAddressProvider = partitionAddressProvider; } @Override protected OperationStepHandler createAttributeWriterHandler() { return new IDMConfigWriteAttributeHandler(modelValidators, partitionAddressProvider, getAttributes().toArray(new AttributeDefinition[0])); } }
3,337
48.088235
146
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/LDAPStoreAttributeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class LDAPStoreAttributeResourceDefinition extends AbstractIDMResourceDefinition { public static final SimpleAttributeDefinition NAME = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_ATTRIBUTE_NAME.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition LDAP_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_ATTRIBUTE_LDAP_NAME.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition IS_IDENTIFIER = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_ATTRIBUTE_IS_IDENTIFIER.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAlternatives(ModelElement.LDAP_STORE_ATTRIBUTE_READ_ONLY.getName()) .build(); public static final SimpleAttributeDefinition READ_ONLY = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_ATTRIBUTE_READ_ONLY.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAlternatives(ModelElement.LDAP_STORE_ATTRIBUTE_IS_IDENTIFIER.getName()) .build(); public static final LDAPStoreAttributeResourceDefinition INSTANCE = new LDAPStoreAttributeResourceDefinition(NAME, LDAP_NAME, IS_IDENTIFIER, READ_ONLY); private LDAPStoreAttributeResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.LDAP_STORE_ATTRIBUTE, address->address.getParent().getParent().getParent().getParent(), attributes); } }
3,004
51.719298
186
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/AbstractIdentityStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; public abstract class AbstractIdentityStoreResourceDefinition extends AbstractIDMResourceDefinition { public static final SimpleAttributeDefinition SUPPORT_ATTRIBUTE = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_STORE_SUPPORT_ATTRIBUTE.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SUPPORT_CREDENTIAL = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_STORE_SUPPORT_CREDENTIAL.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setAllowExpression(true) .build(); protected AbstractIdentityStoreResourceDefinition(ModelElement modelElement, ModelValidationStepHandler[] modelValidators, SimpleAttributeDefinition... attributes) { super(modelElement, modelValidators, address -> address.getParent().getParent(), attributes); } }
2,374
48.479167
190
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/DefaultRemoveStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.util.function.Function; import org.jboss.as.controller.ModelOnlyRemoveStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.dmr.ModelNode; /** * <p>This remove handler is used during the removal of all partition-manager resources.</p> * * @author Pedro Silva */ public class DefaultRemoveStepHandler extends ModelOnlyRemoveStepHandler { private final Function<PathAddress, PathAddress> partitionAddressProvider; DefaultRemoveStepHandler(final Function<PathAddress, PathAddress> partitionAddressProvider) { this.partitionAddressProvider = partitionAddressProvider; } @Override protected void performRemove(OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException { context.addStep(((context1, operation1) -> PartitionManagerResourceDefinition.validateModel(context1, partitionAddressProvider.apply(context1.getCurrentAddress()))), OperationContext.Stage.MODEL); super.performRemove(context, operation, model); } @Override protected boolean removeChildRecursively(PathElement child) { // children only represent configuration details of the parent, and are not independent entities return false; } }
2,489
40.5
204
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/JPAStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.NotEmptyResourceValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.RequiredChildValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class JPAStoreResourceDefinition extends AbstractIdentityStoreResourceDefinition { public static final SimpleAttributeDefinition DATA_SOURCE = new SimpleAttributeDefinitionBuilder(ModelElement.JPA_STORE_DATASOURCE.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives( ModelElement.JPA_STORE_ENTITY_MANAGER_FACTORY.getName(), ModelElement.JPA_STORE_ENTITY_MODULE_UNIT_NAME.getName()) .build(); public static final SimpleAttributeDefinition ENTITY_MODULE = new SimpleAttributeDefinitionBuilder(ModelElement.JPA_STORE_ENTITY_MODULE.getName(), ModelType.STRING, true) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition ENTITY_MODULE_UNIT_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.JPA_STORE_ENTITY_MODULE_UNIT_NAME.getName(), ModelType.STRING, true) .setDefaultValue(new ModelNode("identity")) .setAllowExpression(true) .setAlternatives( ModelElement.JPA_STORE_ENTITY_MANAGER_FACTORY.getName(), ModelElement.JPA_STORE_DATASOURCE.getName()) .setRequires(ModelElement.JPA_STORE_ENTITY_MODULE_UNIT_NAME.getName()) .build(); public static final SimpleAttributeDefinition ENTITY_MANAGER_FACTORY = new SimpleAttributeDefinitionBuilder(ModelElement.JPA_STORE_ENTITY_MANAGER_FACTORY.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives( ModelElement.JPA_STORE_DATASOURCE.getName(), ModelElement.JPA_STORE_ENTITY_MODULE_UNIT_NAME.getName()) .build(); public static final JPAStoreResourceDefinition INSTANCE = new JPAStoreResourceDefinition(DATA_SOURCE, ENTITY_MODULE, ENTITY_MODULE_UNIT_NAME, ENTITY_MANAGER_FACTORY, SUPPORT_CREDENTIAL, SUPPORT_ATTRIBUTE); private JPAStoreResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.JPA_STORE, getModelValidators(), attributes); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(SupportedTypesResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(CredentialHandlerResourceDefinition.INSTANCE, resourceRegistration); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { NotEmptyResourceValidationStepHandler.INSTANCE, new RequiredChildValidationStepHandler(ModelElement.SUPPORTED_TYPES) }; } }
4,390
51.903614
209
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/CredentialTypeEnum.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.util.HashMap; import java.util.Map; /** * <p>Enum defining alias for each supported built-in {@code org.picketlink.idm.credential.handler.CredentialHandler} provided by * PicketLink. The alias is used in the configuration without using the full qualified name of a type.</p> * * @author Pedro Igor */ public enum CredentialTypeEnum { // credential types PASSWORD_CREDENTIAL_HANDLER("PasswordHandler", "org.picketlink.idm.credential.handler.PasswordCredentialHandler"), LDAP_PASSWORD_CREDENTIAL_HANDLER("LDAPPasswordHandler", "org.picketlink.idm.ldap.internal.LDAPPlainTextPasswordCredentialHandler"), DIGEST_CREDENTIAL_HANDLER("DigestHandler", "org.picketlink.idm.credential.handler.DigestCredentialHandler"), X509_CERT_CREDENTIAL_HANDLER("X509CertHandler", "org.picketlink.idm.credential.handler.X509CertificateCredentialHandler"); private static final Map<String, CredentialTypeEnum> types = new HashMap<String, CredentialTypeEnum>(); static { for (CredentialTypeEnum element : values()) { types.put(element.getAlias(), element); } } private final String alias; private final String type; CredentialTypeEnum(String alias, String type) { this.alias = alias; this.type = type; } public static String forType(String alias) { CredentialTypeEnum resolvedType = types.get(alias); if (resolvedType != null) { return resolvedType.getType(); } return null; } @Override public String toString() { return this.alias; } String getAlias() { return this.alias; } String getType() { return this.type; } }
2,794
33.506173
135
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/AttributedTypeEnum.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.util.HashMap; import java.util.Map; /** * <p>Enum defining alias for each supported built-in {@code org.picketlink.idm.model.AttributedType} provided by PicketLink. The * alias is used in the configuration without using the full qualified name of a type.</p> * * @author Pedro Igor */ public enum AttributedTypeEnum { // base types PARTITION("Partition", "org.picketlink.idm.model.Partition"), IDENTITY_TYPE("IdentityType", "org.picketlink.idm.model.IdentityType"), ACCOUNT("Account", "org.picketlink.idm.model.Account"), RELATIONSHIP("Relationship", "org.picketlink.idm.model.Relationship"), PERMISSION("Permission", "org.picketlink.idm.permission.Permission"), // basic model types REALM("Realm", "org.picketlink.idm.model.basic.Realm"), TIER("Tier", "org.picketlink.idm.model.basic.Tier"), AGENT("Agent", "org.picketlink.idm.model.basic.Agent"), USER("User", "org.picketlink.idm.model.basic.User"), ROLE("Role", "org.picketlink.idm.model.basic.Role"), GROUP("Group", "org.picketlink.idm.model.basic.Group"), GRANT("Grant", "org.picketlink.idm.model.basic.Grant"), GROUP_ROLE("GroupRole", "org.picketlink.idm.model.basic.GroupRole"), GROUP_MEMBERSHIP("GroupMembership", "org.picketlink.idm.model.basic.GroupMembership"); private static final Map<String, AttributedTypeEnum> types = new HashMap<String, AttributedTypeEnum>(); static { for (AttributedTypeEnum element : values()) { types.put(element.getAlias(), element); } } private final String alias; private final String type; AttributedTypeEnum(String alias, String type) { this.alias = alias; this.type = type; } public static String forType(String alias) { AttributedTypeEnum resolvedType = types.get(alias); if (resolvedType != null) { return resolvedType.getType(); } return null; } @Override public String toString() { return this.alias; } public String getAlias() { return this.alias; } String getType() { return this.type; } }
3,236
33.806452
129
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/PartitionManagerResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_CONFIGURATION; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_MAPPING; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPE; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPES; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.access.constraint.SensitivityClassification; import org.jboss.as.controller.access.management.AccessConstraintDefinition; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.dmr.Property; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.idm.IDMExtension; import java.util.List; import java.util.function.Function; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class PartitionManagerResourceDefinition extends AbstractIDMResourceDefinition { private static final List<AccessConstraintDefinition> CONSTRAINTS = new SensitiveTargetAccessConstraintDefinition( new SensitivityClassification(IDMExtension.SUBSYSTEM_NAME, "partition-manager", false, true, true) ).wrapAsList(); public static final SimpleAttributeDefinition IDENTITY_MANAGEMENT_JNDI_URL = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_MANAGEMENT_JNDI_NAME.getName(), ModelType.STRING, false).setAllowExpression(true).build(); public static final PartitionManagerResourceDefinition INSTANCE = new PartitionManagerResourceDefinition(); private PartitionManagerResourceDefinition() { super(ModelElement.PARTITION_MANAGER, Function.identity(), IDENTITY_MANAGEMENT_JNDI_URL); setDeprecated(IDMExtension.DEPRECATED_SINCE); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(IdentityConfigurationResourceDefinition.INSTANCE, resourceRegistration); } @Override public List<AccessConstraintDefinition> getAccessConstraints() { return CONSTRAINTS; } // This method encapsulates the aspects of the old PartitionManagerAddHandler's validateModel method that // are relevant to Stage.MODEL execution, dropping the parts that involved Stage.RUNTIME service creation public static void validateModel(final OperationContext context, final PathAddress partitionAddress) throws OperationFailedException { ModelNode partitionManager = getPartitionManagerModel(context, partitionAddress); if (partitionManager == null) { // removed; nothing to validate return; } ModelNode identityConfigurationNode = partitionManager.get(IDENTITY_CONFIGURATION.getName()); if (!identityConfigurationNode.isDefined()) { throw ROOT_LOGGER.idmNoIdentityConfigurationProvided(); } for (Property identityConfiguration : identityConfigurationNode.asPropertyList()) { String configurationName = identityConfiguration.getName(); if (!identityConfiguration.getValue().isDefined()) { throw ROOT_LOGGER.idmNoIdentityStoreProvided(configurationName); } List<ModelNode> identityStores = identityConfiguration.getValue().asList(); for (ModelNode store : identityStores) { configureIdentityStore(context, store); } } } private static ModelNode getPartitionManagerModel(final OperationContext context, final PathAddress partitionAddress) { try { Resource resource = context.readResourceFromRoot(partitionAddress); return Resource.Tools.readModel(resource); } catch (Resource.NoSuchResourceException e) { return null; } } private static void configureIdentityStore(OperationContext context, ModelNode modelNode) throws OperationFailedException { Property prop = modelNode.asProperty(); String storeType = prop.getName(); ModelNode identityStore = prop.getValue().asProperty().getValue(); if (storeType.equals(LDAP_STORE.getName())) { if (!identityStore.hasDefined(LDAP_STORE_MAPPING.getName())) { throw ROOT_LOGGER.idmLdapNoMappingDefined(); } } validateSupportedTypes(context, identityStore); } private static void validateSupportedTypes(OperationContext context, ModelNode identityStore) throws OperationFailedException { boolean hasSupportedType = identityStore.hasDefined(SUPPORTED_TYPES.getName()); if (hasSupportedType) { ModelNode featuresSetNode = identityStore.get(SUPPORTED_TYPES.getName()).asProperty().getValue(); try { ModelNode supportsAllNode = SupportedTypesResourceDefinition.SUPPORTS_ALL .resolveModelAttribute(context, featuresSetNode); hasSupportedType = supportsAllNode.asBoolean(); } catch (OperationFailedException ofe) { if (featuresSetNode.get(SupportedTypesResourceDefinition.SUPPORTS_ALL.getName()).getType() == ModelType.EXPRESSION) { // We just tried to resolve an expression is Stage.MODEL. That's not reliable. // Just assume it would resolve to true and don't fail validation. // If it's invalid it will be caught on a server hasSupportedType = true; } else { throw ofe; } } if (featuresSetNode.hasDefined(SUPPORTED_TYPE.getName())) { for (Property supportedTypeNode : featuresSetNode.get(SUPPORTED_TYPE.getName()).asPropertyList()) { ModelNode supportedType = supportedTypeNode.getValue(); if (!supportedType.hasDefined(SupportedTypeResourceDefinition.CLASS_NAME.getName()) && !supportedType.hasDefined(SupportedTypeResourceDefinition.CODE.getName())) { throw ROOT_LOGGER.typeNotProvided(SUPPORTED_TYPE.getName()); } hasSupportedType = true; } } } if (!hasSupportedType) { throw ROOT_LOGGER.idmNoSupportedTypesDefined(); } } }
8,145
45.548571
230
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/SupportedTypeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.UniqueTypeValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class SupportedTypeResourceDefinition extends AbstractIDMResourceDefinition { public static final SimpleAttributeDefinition CLASS_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CLASS_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CODE.getName()) .build(); public static final SimpleAttributeDefinition CODE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CODE.getName(), ModelType.STRING, true) .setValidator(EnumValidator.create(AttributedTypeEnum.class)) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_MODULE.getName(), ModelType.STRING, true) .setAllowExpression(true) .setRequires(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SupportedTypeResourceDefinition INSTANCE = new SupportedTypeResourceDefinition(CLASS_NAME, CODE, MODULE); private SupportedTypeResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.SUPPORTED_TYPE, getModelValidators(), address -> address.getParent().getParent().getParent().getParent(), attributes); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { new UniqueTypeValidationStepHandler(ModelElement.SUPPORTED_TYPE) { @Override protected String getType(OperationContext context, ModelNode model) throws OperationFailedException { return getSupportedType(context, model); } } }; } private static String getSupportedType(OperationContext context, ModelNode elementNode) throws OperationFailedException { ModelNode classNameNode = CLASS_NAME.resolveModelAttribute(context, elementNode); ModelNode codeNode = CODE.resolveModelAttribute(context, elementNode); if (classNameNode.isDefined()) { return classNameNode.asString(); } else if (codeNode.isDefined()) { return AttributedTypeEnum.forType(codeNode.asString()); } else { throw ROOT_LOGGER.idmNoSupportedTypesDefined(); } } }
4,267
48.057471
165
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/FileStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import java.io.File; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.server.ServerEnvironment; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.NotEmptyResourceValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.RequiredChildValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class FileStoreResourceDefinition extends AbstractIdentityStoreResourceDefinition { public static final SimpleAttributeDefinition WORKING_DIR = new SimpleAttributeDefinitionBuilder(ModelElement.FILE_STORE_WORKING_DIR.getName(), ModelType.STRING, true) .setDefaultValue(new ModelNode().set("picketlink" + File.separatorChar + "idm")) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition RELATIVE_TO = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_RELATIVE_TO.getName(), ModelType.STRING, true) .setDefaultValue(new ModelNode().set(ServerEnvironment.SERVER_DATA_DIR)) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition ALWAYS_CREATE_FILE = new SimpleAttributeDefinitionBuilder(ModelElement.FILE_STORE_ALWAYS_CREATE_FILE.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition ASYNC_WRITE = new SimpleAttributeDefinitionBuilder(ModelElement.FILE_STORE_ASYNC_WRITE.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition ASYNC_WRITE_THREAD_POOL = new SimpleAttributeDefinitionBuilder(ModelElement.FILE_STORE_ASYNC_THREAD_POOL.getName(), ModelType.INT, true) .setDefaultValue(new ModelNode(5)) .setAllowExpression(true) .build(); public static final FileStoreResourceDefinition INSTANCE = new FileStoreResourceDefinition(WORKING_DIR, RELATIVE_TO, ALWAYS_CREATE_FILE, ASYNC_WRITE, ASYNC_WRITE_THREAD_POOL, SUPPORT_ATTRIBUTE, SUPPORT_CREDENTIAL); private FileStoreResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.FILE_STORE, getModelValidators(), attributes); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(SupportedTypesResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(CredentialHandlerResourceDefinition.INSTANCE, resourceRegistration); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { NotEmptyResourceValidationStepHandler.INSTANCE, new RequiredChildValidationStepHandler(ModelElement.SUPPORTED_TYPES) }; } }
4,372
51.059524
218
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/LDAPStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.access.constraint.SensitivityClassification; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.NotEmptyResourceValidationStepHandler; import org.wildfly.extension.picketlink.common.model.validator.RequiredChildValidationStepHandler; import org.wildfly.extension.picketlink.idm.IDMExtension; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class LDAPStoreResourceDefinition extends AbstractIdentityStoreResourceDefinition { public static final SensitiveTargetAccessConstraintDefinition BASE_DN_SUFFIX_CONSTRAINT = new SensitiveTargetAccessConstraintDefinition(new SensitivityClassification(IDMExtension.SUBSYSTEM_NAME, "base-dn-suffix", false, true, true)); public static final SimpleAttributeDefinition URL = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_URL.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition BIND_DN = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_BIND_DN.getName(), ModelType.STRING, false) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.CREDENTIAL) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition BIND_CREDENTIAL = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_BIND_CREDENTIAL.getName(), ModelType.STRING, false) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.CREDENTIAL) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition BASE_DN_SUFFIX = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_BASE_DN_SUFFIX.getName(), ModelType.STRING, false) .setAccessConstraints(BASE_DN_SUFFIX_CONSTRAINT) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition ACTIVE_DIRECTORY = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_ACTIVE_DIRECTORY.getName(), ModelType.BOOLEAN, true) .setAllowExpression(true) .setDefaultValue(ModelNode.FALSE) .build(); public static final SimpleAttributeDefinition UNIQUE_ID_ATTRIBUTE_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.LDAP_STORE_UNIQUE_ID_ATTRIBUTE_NAME .getName(), ModelType.STRING, true) .setAllowExpression(true) .build(); public static final LDAPStoreResourceDefinition INSTANCE = new LDAPStoreResourceDefinition(URL, BIND_DN, BIND_CREDENTIAL, BASE_DN_SUFFIX, SUPPORT_ATTRIBUTE, SUPPORT_CREDENTIAL, ACTIVE_DIRECTORY, UNIQUE_ID_ATTRIBUTE_NAME); private LDAPStoreResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.LDAP_STORE, getModelValidators(), attributes); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(LDAPStoreMappingResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(SupportedTypesResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(CredentialHandlerResourceDefinition.INSTANCE, resourceRegistration); } private static ModelValidationStepHandler[] getModelValidators() { return new ModelValidationStepHandler[] { NotEmptyResourceValidationStepHandler.INSTANCE, new RequiredChildValidationStepHandler(ModelElement.SUPPORTED_TYPES) }; } }
5,124
54.706522
237
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/parser/IDMSubsystemReader_1_0.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model.parser; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.idm.model.AttributedTypeEnum; import org.wildfly.extension.picketlink.idm.model.CredentialHandlerResourceDefinition; import org.wildfly.extension.picketlink.idm.model.CredentialTypeEnum; import org.wildfly.extension.picketlink.idm.model.LDAPStoreAttributeResourceDefinition; import org.wildfly.extension.picketlink.idm.model.LDAPStoreMappingResourceDefinition; import org.wildfly.extension.picketlink.idm.model.SupportedTypeResourceDefinition; import javax.xml.stream.XMLStreamException; import java.util.List; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_CLASS_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_CODE; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_STORE_CREDENTIAL_HANDLER; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_ATTRIBUTE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_MAPPING; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPE; /** * <p> XML Reader for the subsystem schema, version 1.0. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class IDMSubsystemReader_1_0 extends AbstractIDMSubsystemReader { @Override protected void parseLDAPMappingConfig(final XMLExtendedStreamReader reader, final ModelNode identityProviderNode, final List<ModelNode> addOperations) throws XMLStreamException { String name = reader.getAttributeValue("", COMMON_CLASS_NAME.getName()); if (name == null) { name = reader.getAttributeValue("", COMMON_CODE.getName()); if (name != null) { name = AttributedTypeEnum.forType(name); } } ModelNode ldapMappingConfig = parseConfig(reader, LDAP_STORE_MAPPING, name, identityProviderNode, LDAPStoreMappingResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case LDAP_STORE_ATTRIBUTE: parseConfig(reader, LDAP_STORE_ATTRIBUTE, LDAPStoreAttributeResourceDefinition.NAME.getName(), parentNode, LDAPStoreAttributeResourceDefinition.INSTANCE.getAttributes(), addOperations); break; } } }, LDAP_STORE_MAPPING, ldapMappingConfig, reader, addOperations); } @Override protected ModelNode parseCredentialHandlerConfig(XMLExtendedStreamReader reader, ModelNode identityProviderNode, List<ModelNode> addOperations) throws XMLStreamException { String name = reader.getAttributeValue("", COMMON_CLASS_NAME.getName()); if (name == null) { name = reader.getAttributeValue("", COMMON_CODE.getName()); if (name != null) { name = CredentialTypeEnum.forType(name); } } return parseConfig(reader, IDENTITY_STORE_CREDENTIAL_HANDLER, name, identityProviderNode, CredentialHandlerResourceDefinition.INSTANCE.getAttributes(), addOperations); } @Override protected void parseSupportedTypeConfig(XMLExtendedStreamReader reader, ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { String name = reader.getAttributeValue("", COMMON_CLASS_NAME.getName()); if (name == null) { name = reader.getAttributeValue("", COMMON_CODE.getName()); if (name != null) { name = AttributedTypeEnum.forType(name); } } parseConfig(reader, SUPPORTED_TYPE, name, parentNode,SupportedTypeResourceDefinition.INSTANCE.getAttributes(), addOperations); } }
5,546
46.818966
134
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/parser/IDMSubsystemReader_2_0.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model.parser; /** * <p> XML Reader for the subsystem schema, version 1.0. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class IDMSubsystemReader_2_0 extends AbstractIDMSubsystemReader { }
1,295
38.272727
72
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/parser/IDMSubsystemWriter.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model.parser; import org.jboss.as.controller.persistence.SubsystemMarshallingContext; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementWriter; import org.jboss.staxmapper.XMLExtendedStreamWriter; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.XMLElement; import org.wildfly.extension.picketlink.common.parser.ModelXMLElementWriter; import org.wildfly.extension.picketlink.idm.Namespace; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.FILE_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_CONFIGURATION; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_STORE_CREDENTIAL_HANDLER; import static org.wildfly.extension.picketlink.common.model.ModelElement.JPA_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_ATTRIBUTE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_MAPPING; import static org.wildfly.extension.picketlink.common.model.ModelElement.PARTITION_MANAGER; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPE; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPES; /** * <p> XML Writer for the subsystem schema, version 1.0. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class IDMSubsystemWriter implements XMLStreamConstants, XMLElementWriter<SubsystemMarshallingContext> { private static final Map<String, ModelXMLElementWriter> writers = new HashMap<String, ModelXMLElementWriter>(); static { // identity management elements writers registerWriter(PARTITION_MANAGER, COMMON_NAME); registerWriter(IDENTITY_CONFIGURATION, COMMON_NAME); registerWriter(JPA_STORE); registerWriter(FILE_STORE); registerWriter(LDAP_STORE); registerWriter(LDAP_STORE_MAPPING, COMMON_NAME, XMLElement.LDAP_MAPPINGS); registerWriter(LDAP_STORE_ATTRIBUTE); registerWriter(SUPPORTED_TYPES); registerWriter(SUPPORTED_TYPE, COMMON_NAME); registerWriter(IDENTITY_STORE_CREDENTIAL_HANDLER, COMMON_NAME, XMLElement.IDENTITY_STORE_CREDENTIAL_HANDLERS); } @Override public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException { // Start subsystem context.startSubsystemElement(Namespace.CURRENT.getUri(), false); ModelNode subsystemNode = context.getModelNode(); if (subsystemNode.isDefined()) { List<ModelNode> identityManagement = subsystemNode.asList(); for (ModelNode modelNode : identityManagement) { writers.get(PARTITION_MANAGER.getName()).write(writer, modelNode); } } // End subsystem writer.writeEndElement(); } private static void registerWriter(final ModelElement element, final ModelElement keyAttribute) { writers.put(element.getName(), new ModelXMLElementWriter(element, keyAttribute.getName(), writers)); } private static void registerWriter(final ModelElement element) { writers.put(element.getName(), new ModelXMLElementWriter(element, writers)); } private static void registerWriter(final ModelElement element, final ModelElement keyAttribute, final XMLElement parent) { writers.put(element.getName(), new ModelXMLElementWriter(element, keyAttribute.getName(), parent, writers)); } }
4,997
46.150943
126
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/idm/model/parser/AbstractIDMSubsystemReader.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.idm.model.parser; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.XMLElement; import org.wildfly.extension.picketlink.idm.IDMExtension; import org.wildfly.extension.picketlink.idm.Namespace; import org.wildfly.extension.picketlink.idm.model.CredentialHandlerResourceDefinition; import org.wildfly.extension.picketlink.idm.model.FileStoreResourceDefinition; import org.wildfly.extension.picketlink.idm.model.IdentityConfigurationResourceDefinition; import org.wildfly.extension.picketlink.idm.model.JPAStoreResourceDefinition; import org.wildfly.extension.picketlink.idm.model.LDAPStoreAttributeResourceDefinition; import org.wildfly.extension.picketlink.idm.model.LDAPStoreMappingResourceDefinition; import org.wildfly.extension.picketlink.idm.model.LDAPStoreResourceDefinition; import org.wildfly.extension.picketlink.idm.model.PartitionManagerResourceDefinition; import org.wildfly.extension.picketlink.idm.model.SupportedTypeResourceDefinition; import org.wildfly.extension.picketlink.idm.model.SupportedTypesResourceDefinition; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.List; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.FILE_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_CONFIGURATION; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_STORE_CREDENTIAL_HANDLER; import static org.wildfly.extension.picketlink.common.model.ModelElement.JPA_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_ATTRIBUTE; import static org.wildfly.extension.picketlink.common.model.ModelElement.LDAP_STORE_MAPPING; import static org.wildfly.extension.picketlink.common.model.ModelElement.PARTITION_MANAGER; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPE; import static org.wildfly.extension.picketlink.common.model.ModelElement.SUPPORTED_TYPES; /** * <p> XML Reader for the subsystem schema. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public abstract class AbstractIDMSubsystemReader implements XMLStreamConstants, XMLElementReader<List<ModelNode>> { @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> addOperations) throws XMLStreamException { requireNoAttributes(reader); Namespace nameSpace = Namespace.forUri(reader.getNamespaceURI()); ModelNode subsystemNode = createSubsystemRoot(); addOperations.add(subsystemNode); switch (nameSpace) { case PICKETLINK_IDENTITY_MANAGEMENT_1_0: readElement(reader, subsystemNode, addOperations); break; case PICKETLINK_IDENTITY_MANAGEMENT_1_1: case PICKETLINK_IDENTITY_MANAGEMENT_2_0: case PICKETLINK_IDENTITY_MANAGEMENT_3_0: readElement(reader, subsystemNode, addOperations); break; default: throw unexpectedElement(reader); } } private void readElement(XMLExtendedStreamReader reader, ModelNode subsystemNode, List<ModelNode> addOperations) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_DOCUMENT) { if (!reader.isStartElement()) { continue; } // if the current element is supported but is not a model element if (XMLElement.forName(reader.getLocalName()) != null) { continue; } ModelElement modelKey = ModelElement.forName(reader.getLocalName()); if (modelKey == null) { throw unexpectedElement(reader); } switch (modelKey) { case PARTITION_MANAGER: parseIdentityManagementConfig(reader, subsystemNode, addOperations); break; default: throw unexpectedElement(reader); } } } private void parseIdentityManagementConfig(final XMLExtendedStreamReader reader, final ModelNode parentNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode identityManagementNode = parseConfig(reader, PARTITION_MANAGER, COMMON_NAME.getName(), parentNode, PartitionManagerResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case IDENTITY_CONFIGURATION: parseIdentityConfigurationConfig(reader, parentNode, addOperations); break; } } }, PARTITION_MANAGER, identityManagementNode, reader, addOperations); } private void parseIdentityConfigurationConfig(final XMLExtendedStreamReader reader, final ModelNode parentNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode identityConfigurationNode = parseConfig(reader, IDENTITY_CONFIGURATION, COMMON_NAME.getName(), parentNode, IdentityConfigurationResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case JPA_STORE: parseJPAStoreConfig(reader, parentNode, addOperations); break; case FILE_STORE: parseFileStoreConfig(reader, parentNode, addOperations); break; case LDAP_STORE: parseLDAPStoreConfig(reader, addOperations, parentNode); break; } } }, IDENTITY_CONFIGURATION, identityConfigurationNode, reader, addOperations); } private void parseJPAStoreConfig(final XMLExtendedStreamReader reader, final ModelNode identityConfigurationNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode jpaStoreNode = parseConfig(reader, JPA_STORE, null, identityConfigurationNode, JPAStoreResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case IDENTITY_STORE_CREDENTIAL_HANDLER: parseCredentialHandlerConfig(reader, parentNode, addOperations); break; case SUPPORTED_TYPES: parseSupportedTypesConfig(reader, parentNode, addOperations); break; } } }, JPA_STORE, jpaStoreNode, reader, addOperations); } private void parseFileStoreConfig(final XMLExtendedStreamReader reader, final ModelNode identityManagementNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode fileStoreNode = parseConfig(reader, FILE_STORE, null, identityManagementNode, FileStoreResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case IDENTITY_STORE_CREDENTIAL_HANDLER: parseCredentialHandlerConfig(reader, parentNode, addOperations); break; case SUPPORTED_TYPES: parseSupportedTypesConfig(reader, parentNode, addOperations); break; } } }, FILE_STORE, fileStoreNode, reader, addOperations); } private void parseLDAPStoreConfig(final XMLExtendedStreamReader reader, final List<ModelNode> addOperations, final ModelNode identityManagementNode) throws XMLStreamException { ModelNode ldapStoreNode = parseConfig(reader, LDAP_STORE, null, identityManagementNode, LDAPStoreResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case IDENTITY_STORE_CREDENTIAL_HANDLER: parseCredentialHandlerConfig(reader, parentNode, addOperations); break; case LDAP_STORE_MAPPING: parseLDAPMappingConfig(reader, parentNode, addOperations); break; case SUPPORTED_TYPES: parseSupportedTypesConfig(reader, parentNode, addOperations); break; } } }, LDAP_STORE, ldapStoreNode, reader, addOperations); } protected void parseLDAPMappingConfig(final XMLExtendedStreamReader reader, final ModelNode identityProviderNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode ldapMappingConfig = parseConfig(reader, LDAP_STORE_MAPPING, COMMON_NAME.getName(), identityProviderNode, LDAPStoreMappingResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case LDAP_STORE_ATTRIBUTE: parseConfig(reader, LDAP_STORE_ATTRIBUTE, LDAPStoreAttributeResourceDefinition.NAME.getName(), parentNode, LDAPStoreAttributeResourceDefinition.INSTANCE.getAttributes(), addOperations); break; } } }, LDAP_STORE_MAPPING, ldapMappingConfig, reader, addOperations); } protected ModelNode parseCredentialHandlerConfig(XMLExtendedStreamReader reader, ModelNode identityProviderNode, List<ModelNode> addOperations) throws XMLStreamException { return parseConfig(reader, IDENTITY_STORE_CREDENTIAL_HANDLER, COMMON_NAME.getName(), identityProviderNode, CredentialHandlerResourceDefinition.INSTANCE.getAttributes(), addOperations); } private ModelNode parseSupportedTypesConfig(final XMLExtendedStreamReader reader, final ModelNode identityStoreNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode supportedTypesNode = parseConfig(reader, SUPPORTED_TYPES, null, identityStoreNode, SupportedTypesResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case SUPPORTED_TYPE: parseSupportedTypeConfig(reader, parentNode, addOperations); break; } } }, SUPPORTED_TYPES, supportedTypesNode, reader, addOperations); return supportedTypesNode; } protected void parseSupportedTypeConfig(XMLExtendedStreamReader reader, ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { parseConfig(reader, SUPPORTED_TYPE, COMMON_NAME.getName(), parentNode,SupportedTypeResourceDefinition.INSTANCE.getAttributes(), addOperations); } /** * Creates the root subsystem's root address. * * @return */ private ModelNode createSubsystemRoot() { ModelNode subsystemAddress = new ModelNode(); subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, IDMExtension.SUBSYSTEM_NAME); subsystemAddress.protect(); return Util.getEmptyOperation(ADD, subsystemAddress); } /** * Reads a element from the stream considering the parameters. * * @param reader XMLExtendedStreamReader instance from which the elements are read. * @param xmlElement Name of the Model Element to be parsed. * @param key Name of the attribute to be used to as the key for the model. * @param addOperations List of operations. * @param lastNode Parent ModelNode instance. * @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model. * * @return A ModelNode instance populated. * * @throws javax.xml.stream.XMLStreamException */ protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException { if (!reader.getLocalName().equals(xmlElement.getName())) { return null; } ModelNode modelNode = Util.getEmptyOperation(ADD, null); int attributeCount = reader.getAttributeCount(); for (int i = 0; i < attributeCount; i++) { String attributeLocalName = reader.getAttributeLocalName(i); if (ModelElement.forName(attributeLocalName) == null) { throw unexpectedAttribute(reader, i); } } for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) { simpleAttributeDefinition.parseAndSetParameter(reader.getAttributeValue("", simpleAttributeDefinition.getXmlName()), modelNode, reader); } String name = xmlElement.getName(); if (key != null) { name = key; if (modelNode.hasDefined(key)) { name = modelNode.get(key).asString(); } else { String attributeValue = reader.getAttributeValue("", key); if (attributeValue != null) { name = attributeValue; } } } modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name)); addOperations.add(modelNode); return modelNode; } protected void parseElement(final ElementParser parser, ModelElement parentElement, final ModelNode parentNode, final XMLExtendedStreamReader reader, final List<ModelNode> addOperations) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_DOCUMENT) { if (!reader.isStartElement()) { if (reader.isEndElement() && reader.getLocalName().equals(parentElement.getName())) { break; } continue; } if (reader.getLocalName().equals(parentElement.getName())) { continue; } ModelElement element = ModelElement.forName(reader.getLocalName()); if (element == null) { if (XMLElement.forName(reader.getLocalName()) != null) { continue; } throw unexpectedElement(reader); } parser.parse(reader, element, parentNode, addOperations); } } protected interface ElementParser { void parse(XMLExtendedStreamReader reader, ModelElement element, ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException; } }
19,532
48.576142
148
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/parser/ModelXMLElementWriter.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.parser; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamWriter; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.XMLElement; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import java.util.Collections; import java.util.List; import java.util.Map; import static org.wildfly.extension.picketlink.common.model.AbstractResourceDefinition.getAttributeDefinition; import static org.wildfly.extension.picketlink.common.model.AbstractResourceDefinition.getChildResourceDefinitions; /** * <p> A generic XML Writer for all {@link ModelElement} definitions. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 9, 2012 */ public class ModelXMLElementWriter { private final Map<String, ModelXMLElementWriter> register; private final ModelElement modelElement; private XMLElement parentElement; private String nameAttribute; public ModelXMLElementWriter(ModelElement element, Map<String, ModelXMLElementWriter> register) { this.modelElement = element; this.register = Collections.unmodifiableMap(register); } public ModelXMLElementWriter(ModelElement element, XMLElement parentElement, Map<String, ModelXMLElementWriter> register) { this(element, register); this.parentElement = parentElement; } public ModelXMLElementWriter(ModelElement element, String nameAttribute, Map<String, ModelXMLElementWriter> register) { this(element, register); this.nameAttribute = nameAttribute; } public ModelXMLElementWriter(ModelElement element, String nameAttribute, XMLElement parentElement, Map<String, ModelXMLElementWriter> register) { this(element, nameAttribute, register); this.parentElement = parentElement; } public void write(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException { String nodeName = modelNode.asProperty().getName(); if (nodeName.equals(this.modelElement.getName())) { List<ModelNode> modelNodes = modelNode.asProperty().getValue().asList(); boolean writeParrent = this.parentElement != null && !modelNodes.isEmpty(); if (writeParrent) { writer.writeStartElement(this.parentElement.getName()); } for (ModelNode valueNode : modelNodes) { writer.writeStartElement(this.modelElement.getName()); if (this.nameAttribute != null) { writer.writeAttribute(this.nameAttribute, valueNode.keys().iterator().next()); } ModelNode value = valueNode.asProperty().getValue(); if (value.isDefined()) { writeAttributes(writer, value); for (ModelNode propertyIdentity : value.asList()) { List<ResourceDefinition> children = getChildResourceDefinitions().get(this.modelElement); if (children != null) { for (ResourceDefinition child : children) { get(child.getPathElement().getKey()).write(writer, propertyIdentity); } } } } writer.writeEndElement(); } if (writeParrent) { writer.writeEndElement(); } } } private ModelXMLElementWriter get(String writerKey) { return this.register.get(writerKey); } private void writeAttributes(XMLStreamWriter writer, ModelNode modelNode) throws XMLStreamException { for (SimpleAttributeDefinition simpleAttributeDefinition : getAttributeDefinition(this.modelElement)) { simpleAttributeDefinition.marshallAsAttribute(modelNode, writer); } } }
5,130
39.401575
149
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/XMLElement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model; import java.util.HashMap; import java.util.Map; /** * <p> XML elements used in the schema. This elements are not related with the subsystem's model. Usually they are used to group model elements. * </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 8, 2012 */ public enum XMLElement { RELATIONSHIPS("relationships"), LDAP_MAPPINGS("mappings"), IDENTITY_STORE_CREDENTIAL_HANDLERS("credential-handlers"), TRUST("trust"), KEYS("keys"), SERVICE_PROVIDERS("service-providers"), HANDLERS("handlers"); private static final Map<String, XMLElement> xmlElements = new HashMap<String, XMLElement>(); static { for (XMLElement element : values()) { xmlElements.put(element.getName(), element); } } private final String name; private XMLElement(String name) { this.name = name; } public static XMLElement forName(String name) { return xmlElements.get(name); } public String getName() { return this.name; } }
2,138
30.925373
144
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/ModelElement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model; import java.util.HashMap; import java.util.Map; /** * <p> {@link Enum} class where all model elements name (attributes and elements) are defined. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 8, 2012 */ public enum ModelElement { /* * Common elements shared by all resources definitions */ COMMON_URL("url"), COMMON_NAME("name"), COMMON_VALUE("value"), COMMON_CLASS_NAME("class-name"), COMMON_CODE("code"), COMMON_SUPPORTS_ALL("supports-all"), COMMON_MODULE("module"), COMMON_FILE("file"), COMMON_RELATIVE_TO("relative-to"), /* * Identity Management model elements */ PARTITION_MANAGER("partition-manager"), IDENTITY_CONFIGURATION("identity-configuration"), IDENTITY_STORE_CREDENTIAL_HANDLER("credential-handler"), IDENTITY_STORE_SUPPORT_ATTRIBUTE("support-attribute"), IDENTITY_STORE_SUPPORT_CREDENTIAL("support-credential"), IDENTITY_MANAGEMENT_JNDI_NAME("jndi-name"), JPA_STORE("jpa-store"), JPA_STORE_DATASOURCE("data-source"), JPA_STORE_ENTITY_MODULE("entity-module"), JPA_STORE_ENTITY_MODULE_UNIT_NAME("entity-module-unit-name"), JPA_STORE_ENTITY_MANAGER_FACTORY("entity-manager-factory"), FILE_STORE("file-store"), FILE_STORE_WORKING_DIR("working-dir"), FILE_STORE_ALWAYS_CREATE_FILE("always-create-files"), FILE_STORE_ASYNC_WRITE("async-write"), FILE_STORE_ASYNC_THREAD_POOL("async-write-thread-pool"), LDAP_STORE("ldap-store"), LDAP_STORE_URL(COMMON_URL.getName()), LDAP_STORE_BIND_DN("bind-dn"), LDAP_STORE_BIND_CREDENTIAL("bind-credential"), LDAP_STORE_BASE_DN_SUFFIX("base-dn-suffix"), LDAP_STORE_ACTIVE_DIRECTORY("active-directory"), LDAP_STORE_UNIQUE_ID_ATTRIBUTE_NAME("unique-id-attribute-name"), LDAP_STORE_MAPPING("mapping"), LDAP_STORE_MAPPING_BASE_DN(LDAP_STORE_BASE_DN_SUFFIX.getName()), LDAP_STORE_MAPPING_OBJECT_CLASSES("object-classes"), LDAP_STORE_MAPPING_PARENT_ATTRIBUTE_NAME("parent-membership-attribute-name"), LDAP_STORE_MAPPING_RELATES_TO("relates-to"), LDAP_STORE_ATTRIBUTE("attribute"), LDAP_STORE_ATTRIBUTE_NAME(COMMON_NAME.getName()), LDAP_STORE_ATTRIBUTE_LDAP_NAME("ldap-name"), LDAP_STORE_ATTRIBUTE_IS_IDENTIFIER("is-identifier"), LDAP_STORE_ATTRIBUTE_READ_ONLY("read-only"), SUPPORTED_TYPES("supported-types"), SUPPORTED_TYPE("supported-type"), /* * Federation model elements */ FEDERATION("federation"), COMMON_HANDLER("handler"), COMMON_HANDLER_PARAMETER("handler-parameter"), COMMON_SECURITY_DOMAIN("security-domain"), COMMON_STRICT_POST_BINDING("strict-post-binding"), COMMON_SUPPORTS_SIGNATURES("support-signatures"), COMMON_SUPPORT_METADATA("support-metadata"), /* * Identity Provider model elements */ IDENTITY_PROVIDER("identity-provider"), IDENTITY_PROVIDER_TRUST_DOMAIN("trust-domain"), IDENTITY_PROVIDER_TRUST_DOMAIN_NAME("name"), IDENTITY_PROVIDER_TRUST_DOMAIN_CERT_ALIAS("cert-alias"), IDENTITY_PROVIDER_SAML_METADATA("idp-metadata"), IDENTITY_PROVIDER_SAML_METADATA_ORGANIZATION("organization"), IDENTITY_PROVIDER_EXTERNAL("external"), IDENTITY_PROVIDER_ATTRIBUTE_MANAGER("attribute-manager"), IDENTITY_PROVIDER_ROLE_GENERATOR("role-generator"), IDENTITY_PROVIDER_ENCRYPT("encrypt"), IDENTITY_PROVIDER_SSL_AUTHENTICATION("ssl-authentication"), /* * KeyStore model elements */ KEY_STORE("key-store"), KEY_STORE_PASSWORD("password"), KEY_STORE_SIGN_KEY_ALIAS("sign-key-alias"), KEY_STORE_SIGN_KEY_PASSWORD("sign-key-password"), HOST("host"), KEY("key"), /* * Service Provider model elements */ SERVICE_PROVIDER("service-provider"), SERVICE_PROVIDER_POST_BINDING("post-binding"), SERVICE_PROVIDER_ERROR_PAGE("error-page"), SERVICE_PROVIDER_LOGOUT_PAGE("logout-page"), /* * Security Token Service model elements */ SECURITY_TOKEN_SERVICE("security-token-service"), /* * SAML model elements */ SAML("saml"), SAML_TOKEN_TIMEOUT("token-timeout"), SAML_CLOCK_SKEW("clock-skew"), /* * Metric model elements */ METRICS_CREATED_ASSERTIONS_COUNT("created-assertions-count"), METRICS_RESPONSE_TO_SP_COUNT("response-to-sp-count"), METRICS_ERROR_RESPONSE_TO_SP_COUNT("error-response-to-sp-count"), METRICS_ERROR_SIGN_VALIDATION_COUNT("error-sign-validation-count"), METRICS_ERROR_TRUSTED_DOMAIN_COUNT("error-trusted-domain-count"), METRICS_EXPIRED_ASSERTIONS_COUNT("expired-assertions-count"), METRICS_LOGIN_INIT_COUNT("login-init-count"), METRICS_LOGIN_COMPLETE_COUNT("login-complete-count"), METRICS_REQUEST_FROM_IDP_COUNT("request-from-idp-count"), METRICS_RESPONSE_FROM_IDP_COUNT("response-from-idp-count"), METRICS_REQUEST_TO_IDP_COUNT("request-to-idp-count"); private static final Map<String, ModelElement> modelElements = new HashMap<String, ModelElement>(); static { for (ModelElement element : values()) { modelElements.put(element.getName(), element); } } private final String name; private ModelElement(String name) { this.name = name; } public static ModelElement forName(String name) { return modelElements.get(name); } public String getName() { return this.name; } }
6,514
36.017045
103
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/AbstractResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.ModelOnlyRemoveStepHandler; import org.jboss.as.controller.ModelOnlyWriteAttributeHandler; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 18, 2012 */ public abstract class AbstractResourceDefinition extends SimpleResourceDefinition { private static final Map<ModelElement, List<SimpleAttributeDefinition>> attributeDefinitions; private static final Map<ModelElement, List<ResourceDefinition>> childResourceDefinitions; static { attributeDefinitions = new HashMap<>(); childResourceDefinitions = new HashMap<>(); } private final ModelElement modelElement; private final List<SimpleAttributeDefinition> attributes; protected AbstractResourceDefinition(ModelElement modelElement, final OperationStepHandler addHandler, ResourceDescriptionResolver resourceDescriptor, SimpleAttributeDefinition... attributes) { this(modelElement, PathElement.pathElement(modelElement.getName()), resourceDescriptor, addHandler, ModelOnlyRemoveStepHandler.INSTANCE, attributes); } protected AbstractResourceDefinition(ModelElement modelElement, final OperationStepHandler addHandler, final OperationStepHandler removeHandler, ResourceDescriptionResolver resourceDescriptor, SimpleAttributeDefinition... attributes) { this(modelElement, PathElement.pathElement(modelElement.getName()), resourceDescriptor, addHandler, removeHandler, attributes); } protected AbstractResourceDefinition(ModelElement modelElement, String name, final ModelOnlyAddStepHandler addHandler,ResourceDescriptionResolver resourceDescriptor, SimpleAttributeDefinition... attributes) { this(modelElement, PathElement.pathElement(modelElement.getName(), name), resourceDescriptor, addHandler, ModelOnlyRemoveStepHandler.INSTANCE, attributes); } private AbstractResourceDefinition(ModelElement modelElement, PathElement pathElement,ResourceDescriptionResolver resourceDescriptor, final OperationStepHandler addHandler, final OperationStepHandler removeHandler, SimpleAttributeDefinition... attributes) { super(new Parameters(pathElement, resourceDescriptor) .setAddHandler(addHandler) .setRemoveHandler(removeHandler) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) ); this.modelElement = modelElement; this.attributes = Collections.unmodifiableList(Arrays.asList(attributes)); } public static List<SimpleAttributeDefinition> getAttributeDefinition(ModelElement modelElement) { List<SimpleAttributeDefinition> definitions = attributeDefinitions.get(modelElement); if (definitions == null) { return Collections.emptyList(); } return definitions; } public static Map<ModelElement, List<ResourceDefinition>> getChildResourceDefinitions() { return Collections.unmodifiableMap(childResourceDefinitions); } private void addAttributeDefinition(ModelElement resourceDefinitionKey, SimpleAttributeDefinition attribute) { List<SimpleAttributeDefinition> resourceAttributes = attributeDefinitions.get(resourceDefinitionKey); if (resourceAttributes == null) { resourceAttributes = new ArrayList<>(); attributeDefinitions.put(resourceDefinitionKey, resourceAttributes); } if (!resourceAttributes.contains(attribute)) { resourceAttributes.add(attribute); } } private void addChildResourceDefinition(ModelElement resourceDefinitionKey, ResourceDefinition resourceDefinition) { List<ResourceDefinition> childResources = childResourceDefinitions.get(resourceDefinitionKey); if (childResources == null) { childResources = new ArrayList<>(); childResourceDefinitions.put(resourceDefinitionKey, childResources); } if (!childResources.contains(resourceDefinition)) { for (ResourceDefinition childResource : childResources) { if (childResource.getPathElement().getKey().equals(resourceDefinition.getPathElement().getKey())) { return; } } childResources.add(resourceDefinition); } } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { OperationStepHandler writeAttributeHandler = createAttributeWriterHandler(); for (SimpleAttributeDefinition attribute : getAttributes()) { addAttributeDefinition(attribute, writeAttributeHandler, resourceRegistration); } } public List<SimpleAttributeDefinition> getAttributes() { return attributes; } private void addAttributeDefinition(SimpleAttributeDefinition definition, OperationStepHandler writeHandler, ManagementResourceRegistration resourceRegistration) { addAttributeDefinition(this.modelElement, definition); resourceRegistration.registerReadWriteAttribute(definition, null, writeHandler); } protected void addChildResourceDefinition(AbstractResourceDefinition definition, ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(this.modelElement, definition); resourceRegistration.registerSubModel(definition); } protected OperationStepHandler createAttributeWriterHandler() { return new ModelOnlyWriteAttributeHandler(attributes.toArray(new AttributeDefinition[0])); } }
7,513
45.9625
212
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/validator/ElementMaxOccurrenceValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model.validator; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; import java.util.Set; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.ModelElement; /** * @author Pedro Igor */ public class ElementMaxOccurrenceValidationStepHandler implements ModelValidationStepHandler { private final int maxOccurs; private final ModelElement parentElement; private final ModelElement element; public ElementMaxOccurrenceValidationStepHandler(ModelElement element, ModelElement parentElement, int maxOccurs) { this.element = element; this.parentElement = parentElement; this.maxOccurs = maxOccurs; } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validateOccurrence(context, operation); } protected void validateOccurrence(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); PathAddress parentAddress = Util.getParentAddressByKey(address, this.parentElement.getName()); Set<String> elements = context.readResourceFromRoot(parentAddress, false).getChildrenNames(this.element.getName()); if (elements.size() > this.maxOccurs) { throw ROOT_LOGGER.invalidChildTypeOccurrence(parentAddress.getLastElement().toString(), this.maxOccurs, this.element .getName()); } } }
2,902
42.328358
128
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/validator/NotEmptyResourceValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model.validator; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; /** * @author Pedro Igor */ public class NotEmptyResourceValidationStepHandler implements ModelValidationStepHandler { public static final NotEmptyResourceValidationStepHandler INSTANCE = new NotEmptyResourceValidationStepHandler(); private NotEmptyResourceValidationStepHandler() { } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validateChildren(context, operation); } protected void validateChildren(OperationContext context, ModelNode operation) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); if (resource.getChildTypes().isEmpty()) { throw ROOT_LOGGER.emptyResource(pathAddress.getLastElement().toString()); } } }
2,400
41.122807
117
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/validator/RequiredChildValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model.validator; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.ModelElement; import java.util.Set; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.registry.Resource.ResourceEntry; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; /** * @author Pedro Igor */ public class RequiredChildValidationStepHandler implements ModelValidationStepHandler { private final ModelElement childElement; public RequiredChildValidationStepHandler(ModelElement childElement) { this.childElement = childElement; } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validateRequiredChild(context, operation); } protected void validateRequiredChild(OperationContext context, ModelNode operation) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); Set<ResourceEntry> children = resource.getChildren(this.childElement.getName()); if (children.isEmpty()) { throw ROOT_LOGGER.requiredChild(pathAddress.getLastElement().toString(), this.childElement.getName()); } } }
2,660
41.238095
121
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/validator/AlternativeAttributeValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model.validator; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import static org.jboss.as.controller.PathAddress.EMPTY_ADDRESS; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; /** * @author Pedro Igor */ public class AlternativeAttributeValidationStepHandler implements ModelValidationStepHandler { private final AttributeDefinition[] attributes; private final boolean required; public AlternativeAttributeValidationStepHandler(AttributeDefinition[] attributes) { this(attributes, true); } public AlternativeAttributeValidationStepHandler(AttributeDefinition[] attributes, boolean required) { this.attributes = attributes; this.required = required; } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validateAlternatives(context, operation); } protected void validateAlternatives(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode elementNode = context.readResource(EMPTY_ADDRESS, false).getModel(); PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); ModelNode definedAttribute = null; for (AttributeDefinition attribute : this.attributes) { if (elementNode.hasDefined(attribute.getName())) { if (definedAttribute != null) { throw ROOT_LOGGER.invalidAlternativeAttributeOccurrence(attribute.getName(), address.getLastElement().toString(), getAttributeNames()); } definedAttribute = attribute.resolveModelAttribute(context, elementNode); } } if (this.required && definedAttribute == null) { throw ROOT_LOGGER.requiredAlternativeAttributes(address.getLastElement().toString(), getAttributeNames()); } } private String getAttributeNames() { StringBuilder builder = new StringBuilder(); for (AttributeDefinition alternativeAttribute : this.attributes) { if (builder.length() > 0) { builder.append(", "); } builder.append(alternativeAttribute.getName()); } return builder.toString(); } }
3,636
39.411111
155
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/validator/ModelValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model.validator; import org.jboss.as.controller.OperationStepHandler; /** * @author Pedro Igor */ public interface ModelValidationStepHandler extends OperationStepHandler { }
1,251
38.125
74
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/common/model/validator/UniqueTypeValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.common.model.validator; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.ModelElement; import java.util.Set; import static org.jboss.as.controller.PathAddress.EMPTY_ADDRESS; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; /** * @author Pedro Igor */ public abstract class UniqueTypeValidationStepHandler implements ModelValidationStepHandler { private final ModelElement element; public UniqueTypeValidationStepHandler(ModelElement element) { this.element = element; } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validateType(context, operation); } protected void validateType(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress pathAddress = context.getCurrentAddress(); String elementName = context.getCurrentAddressValue(); ModelNode typeNode = context.readResource(EMPTY_ADDRESS, false).getModel(); String type = getType(context, typeNode); PathAddress parentAddress = pathAddress.getParent(); Set<Resource.ResourceEntry> children = context.readResourceFromRoot(parentAddress, true).getChildren(this.element.getName()); for (Resource.ResourceEntry child : children) { String existingResourceName = child.getName(); String existingType = getType(context, child.getModel()); if (!elementName.equals(existingResourceName) && (type.equals(existingType))) { throw ROOT_LOGGER.typeAlreadyDefined(type); } } } protected abstract String getType(OperationContext context, ModelNode model) throws OperationFailedException; }
3,057
41.472222
133
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/logging/PicketLinkLogger.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.logging; import static org.jboss.logging.Logger.Level.INFO; import org.jboss.as.controller.OperationFailedException; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; /** * @author Pedro Igor */ @MessageLogger(projectCode = "WFLYPL", length = 4) public interface PicketLinkLogger extends BasicLogger { PicketLinkLogger ROOT_LOGGER = Logger.getMessageLogger(PicketLinkLogger.class, "org.wildfly.extension.picketlink"); // General Messages 1-49 @LogMessage(level = INFO) @Message(id = 1, value = "Activating PicketLink %s Subsystem") void activatingSubsystem(String name); // @LogMessage(level = INFO) // @Message(id = 2, value = "Configuring PicketLink Federation for deployment [%s]") // void federationConfiguringDeployment(String deploymentName); @LogMessage(level = INFO) @Message(id = 3, value = "Bound [%s] to [%s]") void boundToJndi(String alias, String jndiName); // @LogMessage(level = INFO) // @Message(id = 4, value = "Ignoring unexpected event type [%s]") // void federationIgnoringAuditEvent(PicketLinkAuditEventType eventType); // @LogMessage(level = ERROR) // @Message(id = 5, value = "Error while configuring the metrics collector. Metrics will not be collected.") // void federationErrorCollectingMetric(@Cause Throwable t); // @Message(id = 6, value = "No writer provided for element %s. Check if a writer is registered in PicketLinkSubsystemWriter.") // IllegalStateException noModelElementWriterProvided(String modelElement); @Message(id = 7, value = "Could not load module [%s].") RuntimeException moduleCouldNotLoad(String s, @Cause Throwable t); // @Message(id = 8, value = "Unexpected element [%s].") // XMLStreamException parserUnexpectedElement(String modelName); @Message(id = 9, value = "Could not load class [%s].") RuntimeException couldNotLoadClass(String mappingClass, @Cause Throwable e); @Message(id = 10, value = "No type provided for %s. You must specify a class-name or code.") OperationFailedException typeNotProvided(String elementName); // @Message(id = 11, value = "Failed to get metrics %s.") // OperationFailedException failedToGetMetrics(String reason); @Message(id = 12, value = "Attribute [%s] is not longer supported.") OperationFailedException attributeNoLongerSupported(String attributeName); @Message(id = 13, value = "[%s] can only have [%d] child of type [%s].") OperationFailedException invalidChildTypeOccurrence(String parentPathElement, int maxOccurs, String elementName); @Message(id = 14, value = "Invalid attribute [%s] definition for [%s]. Only one of the following attributes are allowed: [%s].") OperationFailedException invalidAlternativeAttributeOccurrence(String attributeName, String pathElement, String attributeNames); @Message(id = 15, value = "Required attribute [%s] for [%s].") OperationFailedException requiredAttribute(String attributeName, String configuration); @Message(id = 16, value = "[%s] requires one of the given attributes [%s].") OperationFailedException requiredAlternativeAttributes(String pathElement, String attributeNames); @Message(id = 17, value = "Type [%s] already defined.") IllegalStateException typeAlreadyDefined(String clazz); @Message(id = 18, value = "[%s] can not be empty.") OperationFailedException emptyResource(String parentPathElement); @Message(id = 19, value = "[%s] requires child [%s].") OperationFailedException requiredChild(String parentPathElement, String childPathElement); // IDM Messages 50-99 // @Message(id = 50, value = "Entities module not found [%s].") // SecurityConfigurationException idmJpaEntityModuleNotFound(String entityModuleName); // @Message(id = 51, value = "Could not configure JPA store.") // SecurityConfigurationException idmJpaStartFailed(@Cause Throwable e); // @Message(id = 52, value = "Could not lookup EntityManagerFactory [%s].") // SecurityConfigurationException idmJpaEMFLookupFailed(String entityManagerFactoryJndiName); // @Message(id = 53, value = "Could not create transactional EntityManager.") // SecurityConfigurationException idmJpaFailedCreateTransactionEntityManager(@Cause Exception e); @Message(id = 54, value = "You must provide at least one identity configuration.") OperationFailedException idmNoIdentityConfigurationProvided(); @Message(id = 55, value = "You must provide at least one identity store for identity configuration [%s].") OperationFailedException idmNoIdentityStoreProvided(String identityConfiguration); @Message(id = 56, value = "No supported type provided.") OperationFailedException idmNoSupportedTypesDefined(); @Message(id = 57, value = "No mapping was defined.") OperationFailedException idmLdapNoMappingDefined(); // Federation Messages - 100-150 // @Message(id = 100, value = "No Identity Provider configuration found for federation [%s]. ") // IllegalStateException federationIdentityProviderNotConfigured(String federationAlias); @Message(id = 101, value = "No type provided for the handler. You must specify a class-name or code.") OperationFailedException federationHandlerTypeNotProvided(); // @Message(id = 102, value = "Could not parse default STS configuration.") // RuntimeException federationCouldNotParseSTSConfig(@Cause Throwable t); // @Message(id = 104, value = "Could not configure SAML Metadata to deployment [%s].") // IllegalStateException federationSAMLMetadataConfigError(String deploymentName, @Cause ProcessingException e); @Message(id = 105, value = "The migrate operation can not be performed: the server must be in admin-only mode") OperationFailedException migrateOperationAllowedOnlyInAdminOnly(); @Message(id = 106, value = "Migration failed, see results for more details.") String migrationFailed(); @Message(id = 107, value = "Cannot migrate non-empty picketlink-federation subsystem configuration.") OperationFailedException cannotMigrateNonEmptyConfiguration(); }
7,376
47.215686
132
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/FederationSubsystemRootResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.ModelOnlyRemoveStepHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.wildfly.extension.picketlink.federation.model.FederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class FederationSubsystemRootResourceDefinition extends SimpleResourceDefinition { FederationSubsystemRootResourceDefinition() { super(new Parameters(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, FederationExtension.SUBSYSTEM_NAME), FederationExtension.getResourceDescriptionResolver(FederationExtension.SUBSYSTEM_NAME)) .setAddHandler(new ModelOnlyAddStepHandler()) .setAddRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .setRemoveHandler(ModelOnlyRemoveStepHandler.INSTANCE) .setDeprecatedSince(FederationExtension.DEPRECATED_SINCE) ); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { resourceRegistration.registerSubModel(new FederationResourceDefinition()); MigrateOperation.registerOperations(resourceRegistration, getResourceDescriptionResolver()); } }
2,621
46.672727
126
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/MigrateOperation.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation; import static org.jboss.as.controller.OperationContext.Stage.MODEL; import static org.jboss.as.controller.PathAddress.pathAddress; import static org.jboss.as.controller.PathElement.pathElement; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MODULE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.jboss.as.controller.operations.common.Util.createAddOperation; import static org.jboss.as.controller.operations.common.Util.createOperation; import static org.jboss.as.controller.operations.common.Util.createRemoveOperation; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.ProcessType; import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.SimpleMapAttributeDefinition; import org.jboss.as.controller.SimpleOperationDefinitionBuilder; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.operations.MultistepUtil; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.dmr.Property; /** * Operation to migrate from the legacy picketlink-federation subsystem to the keycloak-saml subsystem. * * <p/> * This operation must be performed when the server is in admin-only mode. * <p/> * * <p> * This operation assumes that the user has already obtained the Keycloak client SAML adapter and installed it. * <p/> * * <p> * Internally, the operation: * <p/> * * <ul> * <li>queries the description of the entire picketlink-federation subsystem by invoking the :describe operation. * This returns a list of :add operations for each picketlink-federation resource.</li> * <li>:add the new org.keycloak.keycloak-saml-adapter-subsystem extension if necessary (this should already * be added when installing the Keycloak client SAML adapter)</li> * <li>for each picketlink-federation resource, transform the :add operations to add the corresponding resource to the * new keycloak-saml. In this step, changes to the resources model are taken into account</li> * <li>:remove the picketlink-federation subsystem</li> * </ul> * * <p/> * * The companion <code>:describe-migration</code> operation will return a list of all the actual operations that would * be performed during the invocation of the <code>:migrate</code> operation. * <p/> * * Note that all new operation addresses are generated for standalone mode. If this is a domain mode server then the * addresses are fixed after they have been generated * * @author <a href="mailto:fjuma@redhat.com">Farah Juma</a> */ public class MigrateOperation implements OperationStepHandler { private static final String KEYCLOAK_SAML_EXTENSION = "org.keycloak.keycloak-saml-adapter-subsystem"; private static final String KEYCLOAK_SAML = "keycloak-saml"; private static final String PICKETLINK_EXTENSION = "org.wildfly.extension.picketlink"; private static final PathAddress PICKETLINK_EXTENSION_ADDRESS = pathAddress(pathElement(EXTENSION, PICKETLINK_EXTENSION)); private static final OperationStepHandler DESCRIBE_MIGRATION_INSTANCE = new MigrateOperation(true); private static final OperationStepHandler MIGRATE_INSTANCE = new MigrateOperation(false); private static final String MIGRATE = "migrate"; private static final String MIGRATION_WARNINGS = "migration-warnings"; private static final String MIGRATION_ERROR = "migration-error"; private static final String MIGRATION_OPERATIONS = "migration-operations"; private static final String DESCRIBE_MIGRATION = "describe-migration"; static final StringListAttributeDefinition MIGRATION_WARNINGS_ATTR = new StringListAttributeDefinition.Builder(MIGRATION_WARNINGS) .setRequired(false) .build(); static final SimpleMapAttributeDefinition MIGRATION_ERROR_ATTR = new SimpleMapAttributeDefinition.Builder(MIGRATION_ERROR, ModelType.OBJECT, true) .setValueType(ModelType.OBJECT) .setRequired(false) .build(); private final boolean describe; private MigrateOperation(boolean describe) { this.describe = describe; } static void registerOperations(ManagementResourceRegistration registry, ResourceDescriptionResolver resourceDescriptionResolver) { registry.registerOperationHandler(new SimpleOperationDefinitionBuilder(MIGRATE, resourceDescriptionResolver) .setReplyParameters(MIGRATION_WARNINGS_ATTR, MIGRATION_ERROR_ATTR) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.READ_WHOLE_CONFIG) .build(), MigrateOperation.MIGRATE_INSTANCE); registry.registerOperationHandler(new SimpleOperationDefinitionBuilder(DESCRIBE_MIGRATION, resourceDescriptionResolver) .setReplyParameters(MIGRATION_WARNINGS_ATTR) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.READ_WHOLE_CONFIG) .setReadOnly() .build(), MigrateOperation.DESCRIBE_MIGRATION_INSTANCE); } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (! describe && context.getRunningMode() != RunningMode.ADMIN_ONLY) { throw ROOT_LOGGER.migrateOperationAllowedOnlyInAdminOnly(); } final List<String> warnings = new ArrayList<>(); // node containing the description (list of add operations) of the legacy subsystem final ModelNode legacyModelAddOps = new ModelNode(); // preserve the order of insertion of the add operations for the new subsystem. final Map<PathAddress, ModelNode> migrationOperations = new LinkedHashMap<>(); // invoke an OSH to describe the legacy picketlink-federation subsystem describeLegacyPicketLinkFederationResources(context, legacyModelAddOps); // invoke an OSH to add the keycloak-saml extension addKeycloakSamlExtension(context, migrationOperations, describe); context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // transform the legacy add operations and put them in migrationOperations transformResources(context, legacyModelAddOps, migrationOperations, warnings); // put the /subsystem=picketlink-federation:remove operation removePicketLinkFederation(migrationOperations, context.getProcessType() == ProcessType.STANDALONE_SERVER); PathAddress parentAddress = context.getCurrentAddress().getParent(); fixAddressesForDomainMode(parentAddress, migrationOperations); if (describe) { // :describe-migration operation returns the list of operations that would be executed in the composite operation final Collection<ModelNode> values = migrationOperations.values(); ModelNode result = new ModelNode(); fillWarnings(result, warnings); result.get(MIGRATION_OPERATIONS).set(values); context.getResult().set(result); } else { // :migrate operation invokes an OSH on a composite operation with all the migration operations final Map<PathAddress, ModelNode> migrateOpResponses = migrateSubsystems(context, migrationOperations); context.completeStep(new OperationContext.ResultHandler() { @Override public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) { final ModelNode result = new ModelNode(); fillWarnings(result, warnings); if (resultAction == OperationContext.ResultAction.ROLLBACK) { for (Map.Entry<PathAddress, ModelNode> entry : migrateOpResponses.entrySet()) { if (entry.getValue().hasDefined(FAILURE_DESCRIPTION)) { //we check for failure description, as every node has 'failed', but one //the real error has a failure description //we break when we find the first one, as there will only ever be one failure //as the op stops after the first failure ModelNode desc = new ModelNode(); desc.get(OP).set(migrationOperations.get(entry.getKey())); desc.get(RESULT).set(entry.getValue()); result.get(MIGRATION_ERROR).set(desc); break; } } context.getFailureDescription().set(ROOT_LOGGER.migrationFailed()); } context.getResult().set(result); } }); } } }, MODEL); } private void describeLegacyPicketLinkFederationResources(OperationContext context, ModelNode legacyModelDescription) { ModelNode describeLegacySubsystem = createOperation(GenericSubsystemDescribeHandler.DEFINITION, context.getCurrentAddress()); context.addStep(legacyModelDescription, describeLegacySubsystem, GenericSubsystemDescribeHandler.INSTANCE, MODEL, true); } /** * Attempt to add the keycloak-saml extension. If it's already present, nothing is done. */ private void addKeycloakSamlExtension(OperationContext context, Map<PathAddress, ModelNode> migrationOperations, boolean describe) { Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false); if (root.getChildrenNames(EXTENSION).contains(KEYCLOAK_SAML_EXTENSION)) { return; // extension is already added, nothing to do } PathAddress extensionAddress = pathAddress(EXTENSION, KEYCLOAK_SAML_EXTENSION); OperationEntry addEntry = context.getRootResourceRegistration().getOperationEntry(extensionAddress, ADD); ModelNode addOperation = createAddOperation(extensionAddress); addOperation.get(MODULE).set(KEYCLOAK_SAML_EXTENSION); if (describe) { migrationOperations.put(extensionAddress, addOperation); } else { context.addStep(context.getResult().get(extensionAddress.toString()), addOperation, addEntry.getOperationHandler(), MODEL); } } private void transformResources(OperationContext context, final ModelNode legacyModelDescription, final Map<PathAddress, ModelNode> newAddOperations, List<String> warnings) throws OperationFailedException { for (ModelNode legacyAddOp : legacyModelDescription.get(RESULT).asList()) { final ModelNode newAddOp = legacyAddOp.clone(); ModelNode legacyAddress = legacyAddOp.get(OP_ADDR); ModelNode newAddress = transformAddress(legacyAddress.clone(), context); if (! newAddress.isDefined()) { continue; } newAddOp.get(OP_ADDR).set(newAddress); PathAddress address = PathAddress.pathAddress(newAddress); if (address.size() > 1) { // non-empty subsystem configuration, fail for now throw ROOT_LOGGER.cannotMigrateNonEmptyConfiguration(); } newAddOperations.put(address, newAddOp); } } private ModelNode transformAddress(ModelNode legacyAddress, OperationContext context) { ModelNode newAddress = new ModelNode(); if (legacyAddress.asPropertyList().size() == 1) { Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false); if (root.getChildrenNames(SUBSYSTEM).contains(KEYCLOAK_SAML)) { return new ModelNode(); // keycloak-saml subsystem is already present, no need to add it } } for (Property segment : legacyAddress.asPropertyList()) { final Property newSegment; switch (segment.getName()) { case SUBSYSTEM: newSegment = new Property(SUBSYSTEM, new ModelNode(KEYCLOAK_SAML)); break; default: newSegment = segment; } newAddress.add(newSegment); } return newAddress; } private void removePicketLinkFederation(Map<PathAddress, ModelNode> migrationOperations, boolean standalone) { PathAddress subsystemAddress = pathAddress(FederationExtension.SUBSYSTEM_PATH); ModelNode removeOperation = createRemoveOperation(subsystemAddress); migrationOperations.put(subsystemAddress, removeOperation); if (standalone) { removeOperation = createRemoveOperation(PICKETLINK_EXTENSION_ADDRESS); migrationOperations.put(PICKETLINK_EXTENSION_ADDRESS, removeOperation); } } private Map<PathAddress, ModelNode> migrateSubsystems(OperationContext context, final Map<PathAddress, ModelNode> migrationOperations) throws OperationFailedException { final Map<PathAddress, ModelNode> result = new LinkedHashMap<>(); MultistepUtil.recordOperationSteps(context, migrationOperations, result); return result; } /** * In domain mode, the subsystems are under /profile=XXX. * This method fixes the address by prepending the addresses (that start with /subsystem) with the current * operation parent so that is works both in standalone (parent = EMPTY_ADDRESS) and domain mode * (parent = /profile=XXX). */ private void fixAddressesForDomainMode(PathAddress parentAddress, Map<PathAddress, ModelNode> migrationOperations) { // in standalone mode, do nothing if (parentAddress.size() == 0) { return; } // use a linked hash map to preserve operations order Map<PathAddress, ModelNode> fixedMigrationOperations = new LinkedHashMap<>(migrationOperations); migrationOperations.clear(); for (Map.Entry<PathAddress, ModelNode> entry : fixedMigrationOperations.entrySet()) { PathAddress fixedAddress = parentAddress.append(entry.getKey()); entry.getValue().get(ADDRESS).set(fixedAddress.toModelNode()); migrationOperations.put(fixedAddress, entry.getValue()); } } private void fillWarnings(ModelNode result, List<String> warnings) { ModelNode rw = new ModelNode().setEmptyList(); for (String warning : warnings) { rw.add(warning); } result.get(MIGRATION_WARNINGS).set(rw); } }
17,670
51.126844
172
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/Namespace.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.persistence.SubsystemMarshallingContext; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLElementWriter; import org.wildfly.extension.picketlink.federation.model.parser.FederationSubsystemReader_1_0; import org.wildfly.extension.picketlink.federation.model.parser.FederationSubsystemReader_2_0; import org.wildfly.extension.picketlink.federation.model.parser.FederationSubsystemWriter; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public enum Namespace { PICKETLINK_FEDERATION_1_0(1, 0, 0, "1.0", new FederationSubsystemReader_1_0(), FederationSubsystemWriter.INSTANCE), PICKETLINK_FEDERATION_1_1(1, 1, 0, "1.1", new FederationSubsystemReader_2_0(), FederationSubsystemWriter.INSTANCE), PICKETLINK_FEDERATION_2_0(2, 0, 0, "2.0", new FederationSubsystemReader_2_0(), FederationSubsystemWriter.INSTANCE), PICKETLINK_FEDERATION_3_0(3, 0, 0, "2.0", new FederationSubsystemReader_2_0(), FederationSubsystemWriter.INSTANCE); public static final Namespace CURRENT = PICKETLINK_FEDERATION_3_0; public static final String BASE_URN = "urn:jboss:domain:picketlink-federation:"; private static final Map<String, Namespace> namespaces; static { final Map<String, Namespace> map = new HashMap<String, Namespace>(); for (Namespace namespace : values()) { final String name = namespace.getUri(); if (name != null) { map.put(name, namespace); } } namespaces = map; } private final int major; private final int minor; private final int patch; private final String urnSuffix; private final XMLElementReader<List<ModelNode>> reader; private final XMLElementWriter<SubsystemMarshallingContext> writer; Namespace(int major, int minor, int patch, String urnSuffix, XMLElementReader<List<ModelNode>> reader, XMLElementWriter<SubsystemMarshallingContext> writer) { this.major = major; this.minor = minor; this.patch = patch; this.urnSuffix = urnSuffix; this.reader = reader; this.writer = writer; } /** * Converts the specified uri to a {@link org.wildfly.extension.picketlink.federation.Namespace}. * * @param uri a namespace uri * * @return the matching namespace enum. */ public static Namespace forUri(String uri) { return namespaces.get(uri) == null ? null : namespaces.get(uri); } /** * @return the major */ public int getMajor() { return this.major; } /** * @return the minor */ public int getMinor() { return this.minor; } /** * * @return the patch */ public int getPatch() { return patch; } /** * Get the URI of this namespace. * * @return the URI */ public String getUri() { return BASE_URN + this.urnSuffix; } /** * Returns a xml reader for a specific namespace version. * * @return */ public XMLElementReader<List<ModelNode>> getXMLReader() { return this.reader; } /** * Returns a xml writer for a specific namespace version. * * @return */ public XMLElementWriter<SubsystemMarshallingContext> getXMLWriter() { return this.writer; } public ModelVersion getModelVersion() { if (this.patch > 0) { return ModelVersion.create(getMajor(), getMinor(), getPatch()); } return ModelVersion.create(getMajor(), getMinor()); } }
4,863
31.211921
119
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/FederationExtension.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation; import static org.wildfly.extension.picketlink.federation.Namespace.CURRENT; import static org.wildfly.extension.picketlink.federation.Namespace.PICKETLINK_FEDERATION_1_1; import static org.wildfly.extension.picketlink.federation.Namespace.PICKETLINK_FEDERATION_1_0; import java.util.Collections; import java.util.Set; import org.jboss.as.controller.ExtensionContext; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.descriptions.DeprecatedResourceDescriptionResolver; import org.jboss.as.controller.extension.AbstractLegacyExtension; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.transform.ExtensionTransformerRegistration; import org.jboss.as.controller.transform.SubsystemTransformerRegistration; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.TransformationDescription; import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; import org.wildfly.extension.picketlink.federation.model.FederationResourceDefinition; import org.wildfly.extension.picketlink.federation.model.keystore.KeyResourceDefinition; import org.wildfly.extension.picketlink.federation.model.keystore.KeyStoreProviderResourceDefinition; import org.wildfly.extension.picketlink.federation.model.parser.FederationSubsystemWriter; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public final class FederationExtension extends AbstractLegacyExtension { public static final String SUBSYSTEM_NAME = "picketlink-federation"; public static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME); private static final String RESOURCE_NAME = FederationExtension.class.getPackage().getName() + ".LocalDescriptions"; private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(CURRENT.getMajor(), CURRENT.getMinor()); //deprecated in EAP 6.4 public static final ModelVersion DEPRECATED_SINCE = ModelVersion.create(2,0,0); public FederationExtension() { super("org.wildfly.extension.picketlink", SUBSYSTEM_NAME); } public static ResourceDescriptionResolver getResourceDescriptionResolver(final String keyPrefix) { return new DeprecatedResourceDescriptionResolver(SUBSYSTEM_NAME, keyPrefix, RESOURCE_NAME, FederationExtension.class.getClassLoader(), true, true); } @Override protected Set<ManagementResourceRegistration> initializeLegacyModel(ExtensionContext context) { SubsystemRegistration subsystemRegistration = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION, true); final ManagementResourceRegistration subsystem = subsystemRegistration.registerSubsystemModel(new FederationSubsystemRootResourceDefinition()); subsystemRegistration.registerXMLElementWriter(FederationSubsystemWriter.INSTANCE); return Collections.singleton(subsystem); } @Override protected void initializeLegacyParsers(ExtensionParsingContext context) { context.setSubsystemXmlMapping(SUBSYSTEM_NAME, CURRENT.getUri(), CURRENT::getXMLReader); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, PICKETLINK_FEDERATION_1_1.getUri(), PICKETLINK_FEDERATION_1_1::getXMLReader); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, PICKETLINK_FEDERATION_1_0.getUri(), PICKETLINK_FEDERATION_1_0::getXMLReader); } public static final class TransformerRegistration implements ExtensionTransformerRegistration { @Override public String getSubsystemName() { return SUBSYSTEM_NAME; } @Override public void registerTransformers(SubsystemTransformerRegistration subsystemRegistration) { ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance(); ResourceTransformationDescriptionBuilder federationTransfDescBuilder = builder .addChildResource(new FederationResourceDefinition()); ResourceTransformationDescriptionBuilder keyStoreTransfDescBuilder = federationTransfDescBuilder .addChildResource(KeyStoreProviderResourceDefinition.INSTANCE); keyStoreTransfDescBuilder.rejectChildResource(KeyResourceDefinition.INSTANCE.getPathElement()); TransformationDescription.Tools.register(builder.build(), subsystemRegistration, ModelVersion.create(1, 0)); } } }
5,953
51.690265
155
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/FederationResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model; import java.util.List; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.access.constraint.SensitivityClassification; import org.jboss.as.controller.access.management.AccessConstraintDefinition; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.FederationExtension; import org.wildfly.extension.picketlink.federation.model.idp.IdentityProviderResourceDefinition; import org.wildfly.extension.picketlink.federation.model.keystore.KeyStoreProviderResourceDefinition; import org.wildfly.extension.picketlink.federation.model.saml.SAMLResourceDefinition; import org.wildfly.extension.picketlink.federation.model.sp.ServiceProviderResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class FederationResourceDefinition extends AbstractFederationResourceDefinition { private static final List<AccessConstraintDefinition> CONSTRAINTS = new SensitiveTargetAccessConstraintDefinition( new SensitivityClassification(FederationExtension.SUBSYSTEM_NAME, "federation", false, true, true) ).wrapAsList(); public FederationResourceDefinition() { super(ModelElement.FEDERATION, new ModelOnlyAddStepHandler()); setDeprecated(FederationExtension.DEPRECATED_SINCE); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(KeyStoreProviderResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(new IdentityProviderResourceDefinition(), resourceRegistration); addChildResourceDefinition(new ServiceProviderResourceDefinition(), resourceRegistration); addChildResourceDefinition(SAMLResourceDefinition.INSTANCE, resourceRegistration); } @Override public List<AccessConstraintDefinition> getAccessConstraints() { return CONSTRAINTS; } }
3,235
47.298507
118
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/AbstractFederationResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.wildfly.extension.picketlink.common.model.AbstractResourceDefinition; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.FederationExtension; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 18, 2012 */ public abstract class AbstractFederationResourceDefinition extends AbstractResourceDefinition { protected AbstractFederationResourceDefinition(ModelElement modelElement, ModelOnlyAddStepHandler addHandler, SimpleAttributeDefinition... attributes) { super(modelElement, addHandler, FederationExtension.getResourceDescriptionResolver(modelElement.getName()), attributes); } protected AbstractFederationResourceDefinition(ModelElement modelElement, String name, ModelOnlyAddStepHandler addHandler, SimpleAttributeDefinition... attributes) { super(modelElement, name, addHandler, FederationExtension.getResourceDescriptionResolver(modelElement.getName()), attributes); } }
2,214
49.340909
169
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/RoleGeneratorTypeEnum.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import java.util.HashMap; import java.util.Map; /** * <p>Enum defining alias for each supported built-in org.picketlink.identity.federation.core.interfaces.RoleGenerator provided by * PicketLink. The alias is used in the configuration without using the full qualified name of a type.</p> * * @author Pedro Igor */ public enum RoleGeneratorTypeEnum { UNDERTOW_ROLE_GENERATOR("UndertowRoleGenerator"), EMPTY_ROLE_GENERATOR("EmptyRoleGenerator"); private static final Map<String, RoleGeneratorTypeEnum> types = new HashMap<String, RoleGeneratorTypeEnum>(); static { for (RoleGeneratorTypeEnum element : values()) { types.put(element.getAlias(), element); } } private final String alias; RoleGeneratorTypeEnum(String alias) { this.alias = alias; } @Override public String toString() { return this.alias; } String getAlias() { return this.alias; } }
2,050
32.080645
130
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/TrustDomainResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.Namespace; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class TrustDomainResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition CERT_ALIAS = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_PROVIDER_TRUST_DOMAIN_CERT_ALIAS.getName(), ModelType.STRING, true) .setAllowExpression(true) .setDeprecated(Namespace.PICKETLINK_FEDERATION_1_1.getModelVersion()) .build(); public static final TrustDomainResourceDefinition INSTANCE = new TrustDomainResourceDefinition(); private TrustDomainResourceDefinition() { super(ModelElement.IDENTITY_PROVIDER_TRUST_DOMAIN, new ModelOnlyAddStepHandler(CERT_ALIAS), CERT_ALIAS); } }
2,299
45
189
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/AttributeManagerResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class AttributeManagerResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition CLASS_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CLASS_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CODE.getName()) .build(); public static final SimpleAttributeDefinition CODE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CODE.getName(), ModelType.STRING, true) .setValidator(EnumValidator.create(AttributeManagerTypeEnum.class)) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_MODULE.getName(), ModelType.STRING, true) .setAllowExpression(true) .setRequires(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition[] ATTRIBUTE_DEFINITIONS = new SimpleAttributeDefinition[]{CLASS_NAME, CODE, MODULE}; public static final AttributeManagerResourceDefinition INSTANCE = new AttributeManagerResourceDefinition(); private AttributeManagerResourceDefinition() { super(ModelElement.IDENTITY_PROVIDER_ATTRIBUTE_MANAGER, new IdentityProviderConfigAddStepHandler(ATTRIBUTE_DEFINITIONS), ATTRIBUTE_DEFINITIONS); } }
3,024
51.155172
165
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/IdentityProviderAddHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class IdentityProviderAddHandler extends ModelOnlyAddStepHandler { static final IdentityProviderAddHandler INSTANCE = new IdentityProviderAddHandler(); private IdentityProviderAddHandler() { super(IdentityProviderResourceDefinition.ATTRIBUTE_DEFINITIONS); } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.addStep(new IdentityProviderValidationStepHandler(), OperationContext.Stage.MODEL); super.execute(context, operation); } }
1,911
39.680851
104
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/IdentityProviderValidationStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ElementMaxOccurrenceValidationStepHandler; import static org.jboss.as.controller.PathAddress.EMPTY_ADDRESS; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; /** * @author Pedro Igor */ public class IdentityProviderValidationStepHandler extends ElementMaxOccurrenceValidationStepHandler { public IdentityProviderValidationStepHandler() { super(ModelElement.IDENTITY_PROVIDER, ModelElement.FEDERATION, 1); } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validateSecurityDomain(context); validateOccurrence(context, operation); } private void validateSecurityDomain(OperationContext context) throws OperationFailedException { ModelNode identityProviderNode = context.readResource(EMPTY_ADDRESS, false).getModel(); boolean external = IdentityProviderResourceDefinition.EXTERNAL.resolveModelAttribute(context, identityProviderNode).asBoolean(); ModelNode securityDomain = IdentityProviderResourceDefinition.SECURITY_DOMAIN.resolveModelAttribute(context, identityProviderNode); if (!external && !securityDomain.isDefined()) { throw ROOT_LOGGER.requiredAttribute(ModelElement.COMMON_SECURITY_DOMAIN.getName(), ModelElement.IDENTITY_PROVIDER .getName()); } } }
2,737
45.40678
139
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/AttributeManagerTypeEnum.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import java.util.HashMap; import java.util.Map; /** * <p>Enum defining alias for each supported built-in org.picketlink.identity.federation.core.interfaces.AttributeManager provided by * PicketLink. The alias is used in the configuration without using the full qualified name of a type.</p> * * @author Pedro Igor */ public enum AttributeManagerTypeEnum { UNDERTOW_ATTRIBUTE_MANAGER("UndertowAttributeManager"), EMPTY_ATTRIBUTE_MANAGER("EmptyAttributeManager"); private static final Map<String, AttributeManagerTypeEnum> types = new HashMap<String, AttributeManagerTypeEnum>(); static { for (AttributeManagerTypeEnum element : values()) { types.put(element.getAlias(), element); } } private final String alias; AttributeManagerTypeEnum(String alias) { this.alias = alias; } @Override public String toString() { return this.alias; } String getAlias() { return this.alias; } }
2,080
32.564516
133
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/IdentityProviderConfigAddStepHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.ElementMaxOccurrenceValidationStepHandler; /** * @author Pedro Silva */ public class IdentityProviderConfigAddStepHandler extends ModelOnlyAddStepHandler { IdentityProviderConfigAddStepHandler(final AttributeDefinition... attributes) { super(attributes); } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.addStep( new ElementMaxOccurrenceValidationStepHandler(ModelElement.IDENTITY_PROVIDER_ATTRIBUTE_MANAGER, ModelElement.IDENTITY_PROVIDER, 1), OperationContext.Stage.MODEL); context.addStep( new ElementMaxOccurrenceValidationStepHandler(ModelElement.IDENTITY_PROVIDER_ROLE_GENERATOR, ModelElement.IDENTITY_PROVIDER, 1), OperationContext.Stage.MODEL); super.execute(context, operation); } }
2,341
43.188679
139
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/IdentityProviderResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class IdentityProviderResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition URL = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_URL.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SECURITY_DOMAIN = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SECURITY_DOMAIN.getName(), ModelType.STRING, true) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SECURITY_DOMAIN_REF) .build(); public static final SimpleAttributeDefinition ENCRYPT = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_PROVIDER_ENCRYPT.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SUPPORT_SIGNATURES = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SUPPORTS_SIGNATURES.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition STRICT_POST_BINDING = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_STRICT_POST_BINDING.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition EXTERNAL = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_PROVIDER_EXTERNAL.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SUPPORT_METADATA = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SUPPORT_METADATA.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SSL_AUTHENTICATION = new SimpleAttributeDefinitionBuilder(ModelElement.IDENTITY_PROVIDER_SSL_AUTHENTICATION.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition[] ATTRIBUTE_DEFINITIONS = new SimpleAttributeDefinition[]{URL, SECURITY_DOMAIN, EXTERNAL, ENCRYPT, SUPPORT_SIGNATURES, STRICT_POST_BINDING, SSL_AUTHENTICATION, SUPPORT_METADATA}; public IdentityProviderResourceDefinition() { super(ModelElement.IDENTITY_PROVIDER, IdentityProviderAddHandler.INSTANCE, ATTRIBUTE_DEFINITIONS); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(TrustDomainResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(HandlerResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(RoleGeneratorResourceDefinition.INSTANCE, resourceRegistration); addChildResourceDefinition(AttributeManagerResourceDefinition.INSTANCE, resourceRegistration); } }
4,982
53.163043
193
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/idp/RoleGeneratorResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.idp; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class RoleGeneratorResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition CLASS_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CLASS_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CODE.getName()) .build(); public static final SimpleAttributeDefinition CODE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CODE.getName(), ModelType.STRING, true) .setValidator(EnumValidator.create(RoleGeneratorTypeEnum.class)) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_MODULE.getName(), ModelType.STRING, true) .setAllowExpression(true) .setRequires(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final SimpleAttributeDefinition[] ATTRIBUTE_DEFINITIONS = new SimpleAttributeDefinition[]{CLASS_NAME, CODE, MODULE}; public static final RoleGeneratorResourceDefinition INSTANCE = new RoleGeneratorResourceDefinition(); private RoleGeneratorResourceDefinition() { super(ModelElement.IDENTITY_PROVIDER_ROLE_GENERATOR, new IdentityProviderConfigAddStepHandler(ATTRIBUTE_DEFINITIONS), ATTRIBUTE_DEFINITIONS); } }
3,006
50.844828
165
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/saml/SAMLResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.saml; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class SAMLResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition TOKEN_TIMEOUT = new SimpleAttributeDefinitionBuilder(ModelElement.SAML_TOKEN_TIMEOUT.getName(), ModelType.INT, true) .setDefaultValue(new ModelNode(5000)) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition CLOCK_SKEW = new SimpleAttributeDefinitionBuilder(ModelElement.SAML_CLOCK_SKEW.getName(), ModelType.INT, true) .setDefaultValue(ModelNode.ZERO) .setAllowExpression(true) .build(); public static final SAMLResourceDefinition INSTANCE = new SAMLResourceDefinition(); private SAMLResourceDefinition() { super(ModelElement.SAML, ModelElement.SAML.getName(), new ModelOnlyAddStepHandler(TOKEN_TIMEOUT, CLOCK_SKEW), TOKEN_TIMEOUT, CLOCK_SKEW); } }
2,476
43.232143
166
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/handlers/HandlerParameterResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.handlers; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class HandlerParameterResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition VALUE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_VALUE.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final HandlerParameterResourceDefinition INSTANCE = new HandlerParameterResourceDefinition(); private HandlerParameterResourceDefinition() { super(ModelElement.COMMON_HANDLER_PARAMETER, new ModelOnlyAddStepHandler(VALUE), VALUE); } }
2,135
43.5
156
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/handlers/HandlerAddHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.handlers; import static org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition.CLASS_NAME; import static org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition.CODE; import static org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition.getHandlerType; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.UniqueTypeValidationStepHandler; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class HandlerAddHandler extends ModelOnlyAddStepHandler { static final HandlerAddHandler INSTANCE = new HandlerAddHandler(); private HandlerAddHandler() { super(CLASS_NAME, CODE); } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.addStep(new UniqueTypeValidationStepHandler(ModelElement.COMMON_HANDLER) { @Override protected String getType(OperationContext context, ModelNode model) throws OperationFailedException { return getHandlerType(context, model); } }, OperationContext.Stage.MODEL); super.execute(context, operation); } }
2,573
43.37931
114
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/handlers/HandlerResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.handlers; import static org.wildfly.extension.picketlink.logging.PicketLinkLogger.ROOT_LOGGER; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ModelOnlyWriteAttributeHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.validator.UniqueTypeValidationStepHandler; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class HandlerResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition CLASS_NAME = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CLASS_NAME.getName(), ModelType.STRING, true) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CODE.getName()) .build(); public static final SimpleAttributeDefinition CODE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_CODE.getName(), ModelType.STRING, true) .setValidator(EnumValidator.create(HandlerTypeEnum.class)) .setAllowExpression(true) .setAlternatives(ModelElement.COMMON_CLASS_NAME.getName()) .build(); public static final HandlerResourceDefinition INSTANCE = new HandlerResourceDefinition(); private HandlerResourceDefinition() { super(ModelElement.COMMON_HANDLER, HandlerAddHandler.INSTANCE, CLASS_NAME, CODE); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(HandlerParameterResourceDefinition.INSTANCE, resourceRegistration); } public static String getHandlerType(OperationContext context, ModelNode elementNode) throws OperationFailedException { ModelNode classNameNode = CLASS_NAME.resolveModelAttribute(context, elementNode); ModelNode codeNode = CODE.resolveModelAttribute(context, elementNode); if (classNameNode.isDefined()) { return classNameNode.asString(); } else if (codeNode.isDefined()) { return HandlerTypeEnum.forType(codeNode.asString()); } else { throw ROOT_LOGGER.federationHandlerTypeNotProvided(); } } @Override protected OperationStepHandler createAttributeWriterHandler() { return new ModelOnlyWriteAttributeHandler(getAttributes().toArray(new AttributeDefinition[0])) { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.addStep(new UniqueTypeValidationStepHandler(ModelElement.COMMON_HANDLER) { @Override protected String getType(OperationContext context, ModelNode model) throws OperationFailedException { return getHandlerType(context, model); } }, OperationContext.Stage.MODEL); super.execute(context, operation); } }; } }
4,685
46.333333
165
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/handlers/HandlerTypeEnum.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.handlers; import java.util.HashMap; import java.util.Map; /** * <p>Enum defining alias for each supported built-in org.picketlink.idm.credential.handler.CredentialHandler provided by * PicketLink. The alias is used in the configuration without using the full qualified name of a type.</p> * * @author Pedro Igor */ public enum HandlerTypeEnum { // handlers SAML2_ISSUER_TRUST_HANDLER("SAML2IssuerTrustHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler"), SAML2_AUTHENTICATION_HANDLER("SAML2AuthenticationHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler"), ROLES_GENERATION_HANDLER("RolesGenerationHandler", "org.picketlink.identity.federation.web.handlers.saml2.RolesGenerationHandler"), SAML2_ATTRIBUTE_HANDLER("SAML2AttributeHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2AttributeHandler"), SAML2_ENCRYPTION_HANDLER("SAML2EncryptionHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2EncryptionHandler"), SAML2_IN_RESPONSE_VERIFICATION_HANDLER("SAML2InResponseToVerificationHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2InResponseToVerificationHandler"), SAML2_LOGOUT_HANDLER("SAML2LogOutHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2LogOutHandler"), SAML2_SIGNATURE_GENERATION_HANDLER("SAML2SignatureGenerationHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2SignatureGenerationHandler"), SAML2_SIGNATURE_VALIDATION_HANDLER("SAML2SignatureValidationHandler", "org.picketlink.identity.federation.web.handlers.saml2.SAML2SignatureValidationHandler"); private static final Map<String, HandlerTypeEnum> types = new HashMap<String, HandlerTypeEnum>(); static { for (HandlerTypeEnum element : values()) { types.put(element.getAlias(), element); } } private final String alias; private final String type; private HandlerTypeEnum(String alias, String type) { this.alias = alias; this.type = type; } public static String forType(String alias) { HandlerTypeEnum resolvedType = types.get(alias); if (resolvedType != null) { return resolvedType.getType(); } return null; } @Override public String toString() { return this.alias; } String getAlias() { return this.alias; } String getType() { return this.type; } }
3,613
40.54023
177
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/sp/ServiceProviderResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.sp; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class ServiceProviderResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition SECURITY_DOMAIN = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SECURITY_DOMAIN.getName(), ModelType.STRING, false) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SECURITY_DOMAIN_REF) .build(); public static final SimpleAttributeDefinition URL = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_URL.getName(),ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition POST_BINDING = new SimpleAttributeDefinitionBuilder(ModelElement.SERVICE_PROVIDER_POST_BINDING.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SUPPORT_SIGNATURES = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SUPPORTS_SIGNATURES.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SUPPORT_METADATA = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_SUPPORT_METADATA.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition STRICT_POST_BINDING = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_STRICT_POST_BINDING.getName(), ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition ERROR_PAGE = new SimpleAttributeDefinitionBuilder(ModelElement.SERVICE_PROVIDER_ERROR_PAGE.getName(), ModelType.STRING, true) .setDefaultValue(new ModelNode("/error.jsp")) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition LOGOUT_PAGE = new SimpleAttributeDefinitionBuilder(ModelElement.SERVICE_PROVIDER_LOGOUT_PAGE.getName(), ModelType.STRING, true) .setDefaultValue(new ModelNode("/logout.jsp")) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition[] ATTRIBUTE_DEFINITIONS = new SimpleAttributeDefinition[]{SECURITY_DOMAIN, URL, POST_BINDING, SUPPORT_SIGNATURES, SUPPORT_METADATA, STRICT_POST_BINDING, ERROR_PAGE, LOGOUT_PAGE}; public ServiceProviderResourceDefinition() { super(ModelElement.SERVICE_PROVIDER, new ModelOnlyAddStepHandler(ATTRIBUTE_DEFINITIONS), ATTRIBUTE_DEFINITIONS); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(HandlerResourceDefinition.INSTANCE, resourceRegistration); } }
4,758
53.079545
184
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/parser/FederationSubsystemReader_2_0.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.parser; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.keystore.KeyResourceDefinition; import org.wildfly.extension.picketlink.federation.model.keystore.KeyStoreProviderResourceDefinition; import javax.xml.stream.XMLStreamException; import java.util.List; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.KEY; import static org.wildfly.extension.picketlink.common.model.ModelElement.KEY_STORE; /** * <p> XML Reader for the subsystem schema, version 2.0. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class FederationSubsystemReader_2_0 extends AbstractFederationSubsystemReader { protected void parseKeyStore(XMLExtendedStreamReader reader, ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { ModelNode identityProviderNode = parseConfig(reader, KEY_STORE, null, parentNode, KeyStoreProviderResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case KEY: parseConfig(reader, KEY, COMMON_NAME.getName(), parentNode, KeyResourceDefinition.INSTANCE.getAttributes(), addOperations); break; default: throw unexpectedElement(reader); } } }, KEY_STORE, identityProviderNode, reader, addOperations); } }
3,108
45.402985
145
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/parser/AbstractFederationSubsystemReader.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.parser; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.parsing.ParseUtils.duplicateNamedElement; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_HANDLER; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_HANDLER_PARAMETER; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.FEDERATION; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_ATTRIBUTE_MANAGER; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_ROLE_GENERATOR; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_TRUST_DOMAIN; import static org.wildfly.extension.picketlink.common.model.ModelElement.KEY_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.SAML; import static org.wildfly.extension.picketlink.common.model.ModelElement.SERVICE_PROVIDER; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.XMLElement; import org.wildfly.extension.picketlink.federation.FederationExtension; import org.wildfly.extension.picketlink.federation.Namespace; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerParameterResourceDefinition; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition; import org.wildfly.extension.picketlink.federation.model.idp.AttributeManagerResourceDefinition; import org.wildfly.extension.picketlink.federation.model.idp.IdentityProviderResourceDefinition; import org.wildfly.extension.picketlink.federation.model.idp.RoleGeneratorResourceDefinition; import org.wildfly.extension.picketlink.federation.model.idp.TrustDomainResourceDefinition; import org.wildfly.extension.picketlink.federation.model.keystore.KeyStoreProviderResourceDefinition; import org.wildfly.extension.picketlink.federation.model.saml.SAMLResourceDefinition; import org.wildfly.extension.picketlink.federation.model.sp.ServiceProviderResourceDefinition; /** * @author Pedro Igor */ public abstract class AbstractFederationSubsystemReader implements XMLStreamConstants, XMLElementReader<List<ModelNode>> { @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> addOperations) throws XMLStreamException { requireNoAttributes(reader); Namespace nameSpace = Namespace.forUri(reader.getNamespaceURI()); ModelNode subsystemNode = createSubsystemRoot(); addOperations.add(subsystemNode); switch (nameSpace) { case PICKETLINK_FEDERATION_1_0: this.readElement(reader, subsystemNode, addOperations); break; case PICKETLINK_FEDERATION_1_1: case PICKETLINK_FEDERATION_2_0: case PICKETLINK_FEDERATION_3_0: this.readElement(reader, subsystemNode, addOperations); break; default: throw unexpectedElement(reader); } } private void readElement(XMLExtendedStreamReader reader, ModelNode subsystemNode, List<ModelNode> addOperations) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_DOCUMENT) { if (!reader.isStartElement()) { continue; } // if the current element is supported but is not a model element if (XMLElement.forName(reader.getLocalName()) != null) { continue; } ModelElement modelKey = ModelElement.forName(reader.getLocalName()); if (modelKey == null) { throw unexpectedElement(reader); } switch (modelKey) { case FEDERATION: parseFederation(reader, subsystemNode, addOperations); break; default: throw unexpectedElement(reader); } } } private void parseFederation(final XMLExtendedStreamReader reader, final ModelNode subsystemNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode federationNode = parseConfig(reader, FEDERATION, COMMON_NAME.getName(), subsystemNode, Collections.emptyList(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case KEY_STORE: parseKeyStore(reader, parentNode, addOperations); break; case SAML: parseConfig(reader, SAML, null, parentNode, SAMLResourceDefinition.INSTANCE.getAttributes(), addOperations); break; case IDENTITY_PROVIDER: parseIdentityProviderConfig(reader, parentNode, addOperations); break; case SERVICE_PROVIDER: parseServiceProviderConfig(reader, parentNode, addOperations); break; default: throw unexpectedElement(reader); } } }, FEDERATION, federationNode, reader, addOperations); } protected void parseKeyStore(XMLExtendedStreamReader reader, ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { ModelNode identityProviderNode = parseConfig(reader, KEY_STORE, null, parentNode, KeyStoreProviderResourceDefinition.INSTANCE.getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { throw unexpectedElement(reader); } }, KEY_STORE, identityProviderNode, reader, addOperations); } private void parseServiceProviderConfig(final XMLExtendedStreamReader reader, ModelNode federationNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode serviceProviderNode = parseConfig(reader, SERVICE_PROVIDER, COMMON_NAME.getName(), federationNode, Arrays.asList(ServiceProviderResourceDefinition.ATTRIBUTE_DEFINITIONS), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case COMMON_HANDLER: parseHandlerConfig(reader, parentNode, addOperations); break; } } }, SERVICE_PROVIDER, serviceProviderNode, reader, addOperations); } protected void parseHandlerConfig(final XMLExtendedStreamReader reader, final ModelNode entityProviderNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode handlerNode = parseConfig(reader, COMMON_HANDLER, COMMON_NAME.getName(), entityProviderNode, HandlerResourceDefinition.INSTANCE .getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case COMMON_HANDLER_PARAMETER: parseConfig(reader, COMMON_HANDLER_PARAMETER, COMMON_NAME.getName(), parentNode, HandlerParameterResourceDefinition.INSTANCE.getAttributes(), addOperations); break; default: throw unexpectedElement(reader); } } }, COMMON_HANDLER, handlerNode, reader, addOperations); } private void parseIdentityProviderConfig(final XMLExtendedStreamReader reader, final ModelNode federationNode, final List<ModelNode> addOperations) throws XMLStreamException { ModelNode identityProviderNode = parseConfig(reader, IDENTITY_PROVIDER, COMMON_NAME.getName(), federationNode, Arrays.asList(IdentityProviderResourceDefinition.ATTRIBUTE_DEFINITIONS), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case IDENTITY_PROVIDER_TRUST_DOMAIN: parseConfig(reader, IDENTITY_PROVIDER_TRUST_DOMAIN, COMMON_NAME.getName(), parentNode, TrustDomainResourceDefinition.INSTANCE.getAttributes(), addOperations); break; case IDENTITY_PROVIDER_ROLE_GENERATOR: parseConfig(reader, IDENTITY_PROVIDER_ROLE_GENERATOR, COMMON_NAME.getName(), parentNode, RoleGeneratorResourceDefinition.INSTANCE.getAttributes(), addOperations); break; case IDENTITY_PROVIDER_ATTRIBUTE_MANAGER: parseConfig(reader, IDENTITY_PROVIDER_ATTRIBUTE_MANAGER, COMMON_NAME.getName(), parentNode, AttributeManagerResourceDefinition.INSTANCE.getAttributes(), addOperations); break; case COMMON_HANDLER: parseHandlerConfig(reader, parentNode, addOperations); break; default: throw unexpectedElement(reader); } } }, IDENTITY_PROVIDER, identityProviderNode, reader, addOperations); } /** * Creates the root subsystem's root address. * * @return */ private ModelNode createSubsystemRoot() { ModelNode subsystemAddress = new ModelNode(); subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, FederationExtension.SUBSYSTEM_NAME); subsystemAddress.protect(); return Util.getEmptyOperation(ADD, subsystemAddress); } /** * Reads a element from the stream considering the parameters. * * @param reader XMLExtendedStreamReader instance from which the elements are read. * @param xmlElement Name of the Model Element to be parsed. * @param key Name of the attribute to be used to as the key for the model. * @param addOperations List of operations. * @param lastNode Parent ModelNode instance. * @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model. * * @return A ModelNode instance populated. * * @throws javax.xml.stream.XMLStreamException */ protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException { if (!reader.getLocalName().equals(xmlElement.getName())) { return null; } ModelNode modelNode = Util.getEmptyOperation(ADD, null); int attributeCount = reader.getAttributeCount(); for (int i = 0; i < attributeCount; i++) { String attributeLocalName = reader.getAttributeLocalName(i); if (ModelElement.forName(attributeLocalName) == null) { throw unexpectedAttribute(reader, i); } } for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) { String attributeValue = reader.getAttributeValue("", simpleAttributeDefinition.getXmlName()); simpleAttributeDefinition.parseAndSetParameter(attributeValue, modelNode, reader); } String name = xmlElement.getName(); if (key != null) { name = key; if (modelNode.hasDefined(key)) { name = modelNode.get(key).asString(); } else { String attributeValue = reader.getAttributeValue("", key); if (attributeValue != null) { name = attributeValue; } } } modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name)); addOperations.add(modelNode); return modelNode; } protected void parseElement(final ElementParser parser, ModelElement parentElement, final ModelNode parentNode, final XMLExtendedStreamReader reader, final List<ModelNode> addOperations) throws XMLStreamException { Set<String> visited = new HashSet<>(); while (reader.hasNext() && reader.nextTag() != END_DOCUMENT) { String tagName = reader.getLocalName(); if (!reader.isStartElement()) { if (reader.isEndElement() && tagName.equals(parentElement.getName())) { break; } continue; } if (!tagName.equals(parentElement.getName())) { ModelElement element = ModelElement.forName(tagName); if (element != null) { parser.parse(reader, element, parentNode, addOperations); } else { if (XMLElement.forName(tagName) != null) { if (visited.contains(tagName)) { throw duplicateNamedElement(reader, tagName); } } else { throw unexpectedElement(reader); } } } visited.add(tagName); } } interface ElementParser { void parse(XMLExtendedStreamReader reader, ModelElement element, ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException; } }
16,752
45.665738
176
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/parser/FederationSubsystemWriter.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.parser; import org.jboss.as.controller.persistence.SubsystemMarshallingContext; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementWriter; import org.jboss.staxmapper.XMLExtendedStreamWriter; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.common.model.XMLElement; import org.wildfly.extension.picketlink.common.parser.ModelXMLElementWriter; import org.wildfly.extension.picketlink.federation.Namespace; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_HANDLER; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_HANDLER_PARAMETER; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.FEDERATION; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_ATTRIBUTE_MANAGER; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_ROLE_GENERATOR; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_SAML_METADATA; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_SAML_METADATA_ORGANIZATION; import static org.wildfly.extension.picketlink.common.model.ModelElement.IDENTITY_PROVIDER_TRUST_DOMAIN; import static org.wildfly.extension.picketlink.common.model.ModelElement.KEY; import static org.wildfly.extension.picketlink.common.model.ModelElement.KEY_STORE; import static org.wildfly.extension.picketlink.common.model.ModelElement.SAML; import static org.wildfly.extension.picketlink.common.model.ModelElement.SERVICE_PROVIDER; import static org.wildfly.extension.picketlink.common.model.XMLElement.HANDLERS; import static org.wildfly.extension.picketlink.common.model.XMLElement.SERVICE_PROVIDERS; /** * <p> XML Writer for the subsystem schema, version 1.0. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class FederationSubsystemWriter implements XMLStreamConstants, XMLElementWriter<SubsystemMarshallingContext> { private static final Map<String, ModelXMLElementWriter> writers = new HashMap<String, ModelXMLElementWriter>(); public static final FederationSubsystemWriter INSTANCE = new FederationSubsystemWriter(); static { // federation elements writers registerWriter(FEDERATION, COMMON_NAME); registerWriter(IDENTITY_PROVIDER, COMMON_NAME); registerWriter(KEY_STORE); registerWriter(KEY, COMMON_NAME, XMLElement.KEYS); registerWriter(IDENTITY_PROVIDER_SAML_METADATA); registerWriter(IDENTITY_PROVIDER_SAML_METADATA_ORGANIZATION); registerWriter(IDENTITY_PROVIDER_TRUST_DOMAIN, COMMON_NAME, XMLElement.TRUST); registerWriter(IDENTITY_PROVIDER_ROLE_GENERATOR, COMMON_NAME); registerWriter(IDENTITY_PROVIDER_ATTRIBUTE_MANAGER, COMMON_NAME); registerWriter(COMMON_HANDLER, COMMON_NAME, HANDLERS); registerWriter(COMMON_HANDLER_PARAMETER, COMMON_NAME); registerWriter(SERVICE_PROVIDER, COMMON_NAME, SERVICE_PROVIDERS); registerWriter(SAML); } private FederationSubsystemWriter() { // singleton } @Override public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException { // Start subsystem context.startSubsystemElement(Namespace.CURRENT.getUri(), false); ModelNode subsystemNode = context.getModelNode(); if (subsystemNode.isDefined()) { List<ModelNode> identityManagement = subsystemNode.asList(); for (ModelNode modelNode : identityManagement) { writers.get(FEDERATION.getName()).write(writer, modelNode); } } // End subsystem writer.writeEndElement(); } private static void registerWriter(final ModelElement element, final ModelElement keyAttribute) { writers.put(element.getName(), new ModelXMLElementWriter(element, keyAttribute.getName(), writers)); } private static void registerWriter(final ModelElement element) { writers.put(element.getName(), new ModelXMLElementWriter(element, writers)); } private static void registerWriter(final ModelElement element, final ModelElement keyAttribute, final XMLElement parent) { writers.put(element.getName(), new ModelXMLElementWriter(element, keyAttribute.getName(), parent, writers)); } }
5,886
48.058333
126
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/parser/FederationSubsystemReader_1_0.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.parser; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerParameterResourceDefinition; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerResourceDefinition; import org.wildfly.extension.picketlink.federation.model.handlers.HandlerTypeEnum; import javax.xml.stream.XMLStreamException; import java.util.List; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_CLASS_NAME; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_CODE; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_HANDLER; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_HANDLER_PARAMETER; import static org.wildfly.extension.picketlink.common.model.ModelElement.COMMON_NAME; /** * <p> XML Reader for the subsystem schema, version 1.0. </p> * * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> */ public class FederationSubsystemReader_1_0 extends AbstractFederationSubsystemReader { @Override protected void parseHandlerConfig(final XMLExtendedStreamReader reader, final ModelNode entityProviderNode, final List<ModelNode> addOperations) throws XMLStreamException { String name = reader.getAttributeValue("", COMMON_CLASS_NAME.getName()); if (name == null) { name = reader.getAttributeValue("", COMMON_CODE.getName()); if (name != null) { name = HandlerTypeEnum.forType(name); } } ModelNode handlerNode = parseConfig(reader, COMMON_HANDLER, name, entityProviderNode, HandlerResourceDefinition.INSTANCE .getAttributes(), addOperations); parseElement(new ElementParser() { @Override public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException { switch (element) { case COMMON_HANDLER_PARAMETER: parseConfig(reader, COMMON_HANDLER_PARAMETER, COMMON_NAME.getName(), parentNode, HandlerParameterResourceDefinition.INSTANCE.getAttributes(), addOperations); break; default: throw unexpectedElement(reader); } } }, COMMON_HANDLER, handlerNode, reader, addOperations); } }
3,809
45.463415
155
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/keystore/KeyStoreProviderResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.keystore; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class KeyStoreProviderResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition FILE = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_FILE.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition RELATIVE_TO = new SimpleAttributeDefinitionBuilder(ModelElement.COMMON_RELATIVE_TO.getName(), ModelType.STRING, true) .setRequires(ModelElement.COMMON_FILE.getName()) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition PASSWORD = new SimpleAttributeDefinitionBuilder(ModelElement.KEY_STORE_PASSWORD.getName(), ModelType.STRING, false) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.CREDENTIAL) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SIGN_KEY_ALIAS = new SimpleAttributeDefinitionBuilder(ModelElement.KEY_STORE_SIGN_KEY_ALIAS.getName(), ModelType.STRING, false) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.CREDENTIAL) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition SIGN_KEY_PASSWORD = new SimpleAttributeDefinitionBuilder(ModelElement.KEY_STORE_SIGN_KEY_PASSWORD.getName(), ModelType.STRING, false) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.CREDENTIAL) .setAllowExpression(true) .build(); private static final SimpleAttributeDefinition[] ATTRIBUTE_DEFINITIONS = new SimpleAttributeDefinition[] {FILE, RELATIVE_TO, PASSWORD, SIGN_KEY_ALIAS, SIGN_KEY_PASSWORD}; public static final KeyStoreProviderResourceDefinition INSTANCE = new KeyStoreProviderResourceDefinition(); private KeyStoreProviderResourceDefinition() { super(ModelElement.KEY_STORE, ModelElement.KEY_STORE.getName(), new ModelOnlyAddStepHandler(ATTRIBUTE_DEFINITIONS), ATTRIBUTE_DEFINITIONS); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { addChildResourceDefinition(KeyResourceDefinition.INSTANCE, resourceRegistration); } }
3,936
52.931507
183
java
null
wildfly-main/picketlink/src/main/java/org/wildfly/extension/picketlink/federation/model/keystore/KeyResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.picketlink.federation.model.keystore; import org.jboss.as.controller.ModelOnlyAddStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.dmr.ModelType; import org.wildfly.extension.picketlink.common.model.ModelElement; import org.wildfly.extension.picketlink.federation.model.AbstractFederationResourceDefinition; /** * @author <a href="mailto:psilva@redhat.com">Pedro Silva</a> * @since Mar 16, 2012 */ public class KeyResourceDefinition extends AbstractFederationResourceDefinition { public static final SimpleAttributeDefinition HOST = new SimpleAttributeDefinitionBuilder(ModelElement.HOST.getName(), ModelType.STRING, false) .setAllowExpression(true) .build(); public static final KeyResourceDefinition INSTANCE = new KeyResourceDefinition(); private KeyResourceDefinition() { super(ModelElement.KEY, new ModelOnlyAddStepHandler(HOST), HOST); } }
2,051
41.75
147
java
null
wildfly-main/iiop-openjdk/src/test/java/org/wildfly/iiop/openjdk/IIOPSubsystemTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; /** * <ṕ> * IIOP subsystem tests. * </ṕ> * * @author <a href="kabir.khan@jboss.com">Kabir Khan</a> * @author <a href="sguilhen@jboss.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystemTestCase extends AbstractSubsystemBaseTest { public IIOPSubsystemTestCase() { super(IIOPExtension.SUBSYSTEM_NAME, new IIOPExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("subsystem-3.0.xml"); } @Test public void testExpressions() throws Exception { standardSubsystemTest("expressions.xml"); } @Override protected String getSubsystemXsdPath() throws Exception { return "schema/wildfly-iiop-openjdk_3_0.xsd"; } @Test public void testParseEmptySubsystem() throws Exception { // parse the subsystem xml into operations. String subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + "</subsystem>"; List<ModelNode> operations = super.parse(subsystemXml); // check that we have the expected number of operations. Assert.assertEquals(1, operations.size()); // check that each operation has the correct content. ModelNode addSubsystem = operations.get(0); Assert.assertEquals(ADD, addSubsystem.get(OP).asString()); PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR)); Assert.assertEquals(1, addr.size()); PathElement element = addr.getElement(0); Assert.assertEquals(SUBSYSTEM, element.getKey()); Assert.assertEquals(IIOPExtension.SUBSYSTEM_NAME, element.getValue()); } @Test public void testParseSubsystemWithBadChild() throws Exception { // try parsing a XML with an invalid element. String subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + " <invalid/>" + "</subsystem>"; try { super.parse(subsystemXml); Assert.fail("Should not have parsed bad child"); } catch (XMLStreamException expected) { } // now try parsing a valid element in an invalid position. subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + " <orb>" + " <poa/>" + " </orb>" + "</subsystem>"; try { super.parse(subsystemXml); Assert.fail("Should not have parsed bad child"); } catch (XMLStreamException expected) { } } @Test public void testSubsystemWithSecurityIdentity() throws Exception { super.standardSubsystemTest("subsystem-security-identity.xml"); } @Test public void testSubsystemWithSecurityClient() throws Exception { super.standardSubsystemTest("subsystem-security-client.xml"); } @Test public void testSubsystem_1_0() throws Exception { super.standardSubsystemTest("subsystem-1.0.xml", false); } /** * Verifies that attributes with expression are handled properly. * @throws Exception for any test failures */ @Test public void testExpressionInAttributeValue() throws Exception { final String subsystemXml = readResource("subsystem-full-expressions.xml"); final KernelServices ks = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml).build(); final ModelNode iiop = ks.readWholeModel().get("subsystem", getMainSubsystemName()); final String giopVersion = iiop.get(Constants.ORB_GIOP_VERSION).resolve().asString(); assertEquals("1.2", giopVersion); final String highWaterMark = iiop.get(Constants.TCP_HIGH_WATER_MARK).resolve().asString(); assertEquals("500", highWaterMark); final String numberToReclaim = iiop.get(Constants.TCP_NUMBER_TO_RECLAIM).resolve().asString(); assertEquals("30", numberToReclaim); final String security = iiop.get(Constants.SECURITY).resolve().asString(); assertEquals("elytron", security); final String authenticationContext = iiop.get(Constants.ORB_INIT_AUTH_CONTEXT).resolve().asString(); assertEquals("iiop", authenticationContext); final String transactions = iiop.get(Constants.ORB_INIT_TRANSACTIONS).resolve().asString(); assertEquals("spec", transactions); final String rootContext = iiop.get(Constants.NAMING_ROOT_CONTEXT).resolve().asString(); assertEquals("JBoss/Naming/root2", rootContext); final String exportCorbaloc = iiop.get(Constants.NAMING_EXPORT_CORBALOC).resolve().asString(); assertEquals("false", exportCorbaloc); final String supportSsl = iiop.get(Constants.SECURITY_SUPPORT_SSL).resolve().asString(); assertEquals("true", supportSsl); final String addComponentViaInterceptor = iiop.get(Constants.SECURITY_ADD_COMP_VIA_INTERCEPTOR).resolve().asString(); assertEquals("false", addComponentViaInterceptor); final String clientRequiresSsl = iiop.get(Constants.SECURITY_CLIENT_REQUIRES_SSL).resolve().asString(); assertEquals("false", clientRequiresSsl); final String serverRequiresSsl = iiop.get(Constants.SECURITY_SERVER_REQUIRES_SSL).resolve().asString(); assertEquals("false", serverRequiresSsl); final String interopIona = iiop.get(Constants.INTEROP_IONA).resolve().asString(); assertEquals("false", interopIona); final String integrity = iiop.get(Constants.IOR_TRANSPORT_INTEGRITY).resolve().asString(); assertEquals("required", integrity); final String confidentiality = iiop.get(Constants.IOR_TRANSPORT_CONFIDENTIALITY).resolve().asString(); assertEquals("required", confidentiality); final String trustInClient = iiop.get(Constants.IOR_TRANSPORT_TRUST_IN_CLIENT).resolve().asString(); assertEquals("required", trustInClient); final String trustInTarget = iiop.get(Constants.IOR_TRANSPORT_TRUST_IN_TARGET).resolve().asString(); assertEquals("supported", trustInTarget); final String detectReply = iiop.get(Constants.IOR_TRANSPORT_DETECT_REPLAY).resolve().asString(); assertEquals("supported", detectReply); final String detectMisordering = iiop.get(Constants.IOR_TRANSPORT_DETECT_MISORDERING).resolve().asString(); assertEquals("supported", detectMisordering); final String authMethod = iiop.get(Constants.IOR_AS_CONTEXT_AUTH_METHOD).resolve().asString(); assertEquals("none", authMethod); final String realm = iiop.get(Constants.IOR_AS_CONTEXT_REALM).resolve().asString(); assertEquals("test_realm2", realm); final String required = iiop.get(Constants.IOR_AS_CONTEXT_REQUIRED).resolve().asString(); assertEquals("true", required); final String callerPropagation = iiop.get(Constants.IOR_SAS_CONTEXT_CALLER_PROPAGATION).resolve().asString(); assertEquals("supported", callerPropagation); } }
9,075
40.254545
134
java
null
wildfly-main/iiop-openjdk/src/test/java/org/wildfly/iiop/openjdk/IIOPSubsystem2_1TestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; /** * <ṕ> * IIOP subsystem tests. * </ṕ> * * @author <a href="kabir.khan@jboss.com">Kabir Khan</a> * @author <a href="sguilhen@jboss.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystem2_1TestCase extends AbstractSubsystemBaseTest { public IIOPSubsystem2_1TestCase() { super(IIOPExtension.SUBSYSTEM_NAME, new IIOPExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("subsystem-2.1.xml"); } @Test public void testExpressions() throws Exception { standardSubsystemTest("expressions.xml"); } @Override protected String getSubsystemXsdPath() throws Exception { return "schema/wildfly-iiop-openjdk_2_1.xsd"; } @Test public void testParseEmptySubsystem() throws Exception { // parse the subsystem xml into operations. String subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + "</subsystem>"; List<ModelNode> operations = super.parse(subsystemXml); // check that we have the expected number of operations. Assert.assertEquals(1, operations.size()); // check that each operation has the correct content. ModelNode addSubsystem = operations.get(0); Assert.assertEquals(ADD, addSubsystem.get(OP).asString()); PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR)); Assert.assertEquals(1, addr.size()); PathElement element = addr.getElement(0); Assert.assertEquals(SUBSYSTEM, element.getKey()); Assert.assertEquals(IIOPExtension.SUBSYSTEM_NAME, element.getValue()); } @Test public void testParseSubsystemWithBadChild() throws Exception { // try parsing a XML with an invalid element. String subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + " <invalid/>" + "</subsystem>"; try { super.parse(subsystemXml); Assert.fail("Should not have parsed bad child"); } catch (XMLStreamException expected) { } // now try parsing a valid element in an invalid position. subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + " <orb>" + " <poa/>" + " </orb>" + "</subsystem>"; try { super.parse(subsystemXml); Assert.fail("Should not have parsed bad child"); } catch (XMLStreamException expected) { } } @Test public void testSubsystemWithSecurityIdentity() throws Exception { super.standardSubsystemTest("subsystem-security-identity.xml"); } @Test public void testSubsystemWithSecurityClient() throws Exception { super.standardSubsystemTest("subsystem-security-client.xml"); } @Test public void testSubsystem_1_0() throws Exception { super.standardSubsystemTest("subsystem-1.0.xml", false); } @Override protected void compareXml(String configId, String original, String marshalled) throws Exception { // } /** * Verifies that attributes with expression are handled properly. * @throws Exception for any test failures */ @Test public void testExpressionInAttributeValue() throws Exception { final String subsystemXml = readResource("subsystem-full-expressions.xml"); final KernelServices ks = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml).build(); final ModelNode iiop = ks.readWholeModel().get("subsystem", getMainSubsystemName()); final String giopVersion = iiop.get(Constants.ORB_GIOP_VERSION).resolve().asString(); assertEquals("1.2", giopVersion); final String highWaterMark = iiop.get(Constants.TCP_HIGH_WATER_MARK).resolve().asString(); assertEquals("500", highWaterMark); final String numberToReclaim = iiop.get(Constants.TCP_NUMBER_TO_RECLAIM).resolve().asString(); assertEquals("30", numberToReclaim); final String security = iiop.get(Constants.SECURITY).resolve().asString(); assertEquals("elytron", security); final String authenticationContext = iiop.get(Constants.ORB_INIT_AUTH_CONTEXT).resolve().asString(); assertEquals("iiop", authenticationContext); final String transactions = iiop.get(Constants.ORB_INIT_TRANSACTIONS).resolve().asString(); assertEquals("spec", transactions); final String rootContext = iiop.get(Constants.NAMING_ROOT_CONTEXT).resolve().asString(); assertEquals("JBoss/Naming/root2", rootContext); final String exportCorbaloc = iiop.get(Constants.NAMING_EXPORT_CORBALOC).resolve().asString(); assertEquals("false", exportCorbaloc); final String supportSsl = iiop.get(Constants.SECURITY_SUPPORT_SSL).resolve().asString(); assertEquals("true", supportSsl); final String addComponentViaInterceptor = iiop.get(Constants.SECURITY_ADD_COMP_VIA_INTERCEPTOR).resolve().asString(); assertEquals("false", addComponentViaInterceptor); final String clientRequiresSsl = iiop.get(Constants.SECURITY_CLIENT_REQUIRES_SSL).resolve().asString(); assertEquals("false", clientRequiresSsl); final String serverRequiresSsl = iiop.get(Constants.SECURITY_SERVER_REQUIRES_SSL).resolve().asString(); assertEquals("false", serverRequiresSsl); final String interopIona = iiop.get(Constants.INTEROP_IONA).resolve().asString(); assertEquals("false", interopIona); final String integrity = iiop.get(Constants.IOR_TRANSPORT_INTEGRITY).resolve().asString(); assertEquals("required", integrity); final String confidentiality = iiop.get(Constants.IOR_TRANSPORT_CONFIDENTIALITY).resolve().asString(); assertEquals("required", confidentiality); final String trustInClient = iiop.get(Constants.IOR_TRANSPORT_TRUST_IN_CLIENT).resolve().asString(); assertEquals("required", trustInClient); final String trustInTarget = iiop.get(Constants.IOR_TRANSPORT_TRUST_IN_TARGET).resolve().asString(); assertEquals("supported", trustInTarget); final String detectReply = iiop.get(Constants.IOR_TRANSPORT_DETECT_REPLAY).resolve().asString(); assertEquals("supported", detectReply); final String detectMisordering = iiop.get(Constants.IOR_TRANSPORT_DETECT_MISORDERING).resolve().asString(); assertEquals("supported", detectMisordering); final String authMethod = iiop.get(Constants.IOR_AS_CONTEXT_AUTH_METHOD).resolve().asString(); assertEquals("none", authMethod); final String realm = iiop.get(Constants.IOR_AS_CONTEXT_REALM).resolve().asString(); assertEquals("test_realm2", realm); final String required = iiop.get(Constants.IOR_AS_CONTEXT_REQUIRED).resolve().asString(); assertEquals("true", required); final String callerPropagation = iiop.get(Constants.IOR_SAS_CONTEXT_CALLER_PROPAGATION).resolve().asString(); assertEquals("supported", callerPropagation); } }
9,215
39.96
134
java
null
wildfly-main/iiop-openjdk/src/test/java/org/wildfly/iiop/openjdk/IIOPSubsystem1_0TestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import java.io.IOException; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.KernelServices; /** * <ṕ> * IIOP subsystem tests. * </ṕ> * * @author <a href="kabir.khan@jboss.com">Kabir Khan</a> * @author <a href="sguilhen@jboss.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystem1_0TestCase extends AbstractSubsystemBaseTest { public IIOPSubsystem1_0TestCase() { super(IIOPExtension.SUBSYSTEM_NAME, new IIOPExtension()); } @Override protected String getSubsystemXml() throws IOException { return readResource("subsystem-1.0.xml"); } @Override protected KernelServices standardSubsystemTest(String configId, boolean compareXml) throws Exception { return super.standardSubsystemTest(configId, false); } @Override protected String getSubsystemXsdPath() throws Exception { return "schema/jboss-as-iiop-openjdk_1_0.xsd"; } }
2,083
33.733333
106
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/Constants.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; /** * <p> * Collection of constants used in the IIOP subsystem. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public final class Constants { /** * <p> * Private constructor as required by the {@code Singleton} pattern. * </p> */ private Constants() { } // subsystem configuration constants (elements and attributes). public static final String CLIENT = "client"; public static final String SETTING = "setting"; public static final String ORB = "orb"; public static final String ORB_GIOP_VERSION = "giop-version"; public static final String ORB_TCP = "tcp"; public static final String TCP_HIGH_WATER_MARK = "high-water-mark"; public static final String TCP_NUMBER_TO_RECLAIM = "number-to-reclaim"; public static final String ORB_SOCKET_BINDING = "socket-binding"; public static final String ORB_SSL_SOCKET_BINDING = "ssl-socket-binding"; public static final String ORB_PERSISTENT_SERVER_ID = "persistent-server-id"; public static final String ORB_INIT = "initializers"; public static final String ORB_INIT_SECURITY = "security"; public static final String ORB_INIT_AUTH_CONTEXT = "authentication-context"; public static final String ORB_INIT_TRANSACTIONS = "transactions"; public static final String NAMING = "naming"; public static final String NAMING_EXPORT_CORBALOC = "export-corbaloc"; public static final String NAMING_ROOT_CONTEXT = "root-context"; public static final String NONE = "none"; public static final String IDENTITY = "identity"; public static final String SECURITY = "security"; public static final String ELYTRON = "elytron"; public static final String SPEC = "spec"; public static final String FULL = "full"; public static final String SECURITY_SUPPORT_SSL = "support-ssl"; public static final String SECURITY_SECURITY_DOMAIN = "security-domain"; public static final String SERVER_SSL_CONTEXT = "server-ssl-context"; public static final String CLIENT_SSL_CONTEXT = "client-ssl-context"; public static final String SECURITY_ADD_COMP_VIA_INTERCEPTOR = "add-component-via-interceptor"; public static final String SECURITY_CLIENT_SUPPORTS = "client-supports"; public static final String SECURITY_CLIENT_REQUIRES = "client-requires"; public static final String SECURITY_SERVER_SUPPORTS = "server-supports"; public static final String SECURITY_SERVER_REQUIRES = "server-requires"; public static final String SECURITY_CLIENT_REQUIRES_SSL = "client-requires-ssl"; public static final String SECURITY_SERVER_REQUIRES_SSL = "server-requires-ssl"; public static final String INTEROP = "interop"; public static final String INTEROP_IONA = "iona"; public static final String IOR_SETTINGS = "ior-settings"; public static final String IOR_TRANSPORT_CONFIG = "transport-config"; public static final String IOR_TRANSPORT_INTEGRITY = "integrity"; public static final String IOR_TRANSPORT_CONFIDENTIALITY = "confidentiality"; public static final String IOR_TRANSPORT_TRUST_IN_TARGET = "trust-in-target"; public static final String IOR_TRANSPORT_TRUST_IN_CLIENT = "trust-in-client"; public static final String IOR_TRANSPORT_DETECT_REPLAY = "detect-replay"; public static final String IOR_TRANSPORT_DETECT_MISORDERING = "detect-misordering"; public static final String IOR_AS_CONTEXT = "as-context"; public static final String IOR_AS_CONTEXT_AUTH_METHOD = "auth-method"; public static final String IOR_AS_CONTEXT_REALM = "realm"; public static final String IOR_AS_CONTEXT_REQUIRED = "required"; public static final String IOR_SAS_CONTEXT = "sas-context"; public static final String IOR_SAS_CONTEXT_CALLER_PROPAGATION = "caller-propagation"; public static final String IOR_SUPPORTED = "supported"; public static final String IOR_REQUIRED = "required"; public static final String IOR_NONE = "none"; public static final String PROPERTIES = "properties"; public static final String PROPERTY = "property"; public static final String PROPERTY_NAME = "name"; // constants for common org.omg properties. public static final String ORB_ADDRESS = "OAIAddr"; public static final String ORB_PORT = "OAPort"; public static final String ORB_SSL_PORT = "OASSLPort"; public static final String ORB_CLASS = "org.omg.CORBA.ORBClass"; public static final String ORB_SINGLETON_CLASS = "org.omg.CORBA.ORBSingletonClass"; public static final String ORB_INITIALIZER_PREFIX = "org.omg.PortableInterceptor.ORBInitializerClass."; // Configuration properties that are built and set by the ORB service. public static final String NAME_SERVICE_INIT_REF = "NameService"; public static final String ROOT_CONTEXT_INIT_REF = "JBoss/Naming/root"; public static final String SSL_SOCKET_TYPE = "SSL"; }
6,043
49.366667
107
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/SSLConfigValue.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import java.util.HashMap; import java.util.Map; /** * <p> * Enumeration of the SSL configuration values. Each enum contains the corresponding IIOP value, which is represented * as an int. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> */ public enum SSLConfigValue { NONE("None", "0"), SERVERAUTH("ServerAuth", "20"), CLIENTAUTH("ClientAuth", "40"), MUTUALAUTH("MutualAuth", "60"); private String name; private String iiopValue; SSLConfigValue(String name, String iiopValue) { this.name = name; this.iiopValue = iiopValue; } public String getIIOPValue() { return this.iiopValue; } private static Map<String, SSLConfigValue> MAP; static { final Map<String, SSLConfigValue> map = new HashMap<String, SSLConfigValue>(); for (SSLConfigValue configValue : values()) { map.put(configValue.getIIOPValue(), configValue); } MAP = map; } public static SSLConfigValue fromValue(String value) { return MAP.get(value); } @Override public String toString() { return this.name; } }
2,196
29.943662
118
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPSubsystemParser_2_1.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.PersistentResourceXMLDescription.builder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PersistentResourceXMLDescription; import org.jboss.as.controller.PersistentResourceXMLParser; /** * <p> * This class implements a parser for the IIOP subsystem. * </p> * * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystemParser_2_1 extends PersistentResourceXMLParser { IIOPSubsystemParser_2_1() { } @Override public PersistentResourceXMLDescription getParserDescription() { return builder(IIOPExtension.PATH_SUBSYSTEM, Namespace.IIOP_OPENJDK_2_1.getUriString()) .setMarshallDefaultValues(true) .addAttributes(IIOPRootDefinition.ALL_ATTRIBUTES.toArray(new AttributeDefinition[0])) .build(); } }
1,951
35.148148
101
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/PropertiesMap.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * <p> * This class contains mapping from IIOP subsystem constants to orb specific properties. * </p> * * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ import com.sun.corba.se.impl.orbutil.ORBConstants; public interface PropertiesMap { Map<String, String> PROPS_MAP = Collections.unmodifiableMap(new HashMap<String, String>() { { put(Constants.ORB_PERSISTENT_SERVER_ID, ORBConstants.ORB_SERVER_ID_PROPERTY); put(Constants.ORB_GIOP_VERSION, ORBConstants.GIOP_VERSION); put(Constants.TCP_HIGH_WATER_MARK, ORBConstants.HIGH_WATER_MARK_PROPERTY); put(Constants.TCP_NUMBER_TO_RECLAIM, ORBConstants.NUMBER_TO_RECLAIM_PROPERTY); } }); }
1,873
36.48
95
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPRootDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.wildfly.iiop.openjdk.Capabilities.LEGACY_SECURITY; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PersistentResourceDefinition; import org.jboss.as.controller.PropertiesAttributeDefinition; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.access.constraint.SensitivityClassification; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.operations.validation.IntRangeValidator; import org.jboss.as.controller.operations.validation.ParameterValidator; import org.jboss.as.controller.operations.validation.StringLengthValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.omg.CORBA.ORB; /** * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ class IIOPRootDefinition extends PersistentResourceDefinition { static final RuntimeCapability<Void> IIOP_CAPABILITY = RuntimeCapability.Builder.of(Capabilities.IIOP_CAPABILITY, false, ORB.class).build(); static final ModelNode NONE = new ModelNode("none"); static final ParameterValidator SSL_CONFIG_VALIDATOR = EnumValidator.create(SSLConfigValue.class); static final StringLengthValidator LENGTH_VALIDATOR = new StringLengthValidator(1, Integer.MAX_VALUE, true, false); static final SensitivityClassification IIOP_SECURITY = new SensitivityClassification(IIOPExtension.SUBSYSTEM_NAME, "iiop-security", false, false, true); static final SensitiveTargetAccessConstraintDefinition IIOP_SECURITY_DEF = new SensitiveTargetAccessConstraintDefinition( IIOP_SECURITY); static final ParameterValidator VALIDATOR = EnumValidator.create(IORTransportConfigValues.class); //ORB attributes protected static final AttributeDefinition PERSISTENT_SERVER_ID = new SimpleAttributeDefinitionBuilder( Constants.ORB_PERSISTENT_SERVER_ID, ModelType.STRING, true).setAttributeGroup(Constants.ORB) .setDefaultValue(new ModelNode().set("1")).setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).build(); protected static final AttributeDefinition GIOP_VERSION = new SimpleAttributeDefinitionBuilder(Constants.ORB_GIOP_VERSION, ModelType.STRING, true).setAttributeGroup(Constants.ORB).setDefaultValue(new ModelNode().set("1.2")) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).setAllowExpression(true).build(); protected static final AttributeDefinition SOCKET_BINDING = new SimpleAttributeDefinitionBuilder( Constants.ORB_SOCKET_BINDING, ModelType.STRING, true).setAttributeGroup(Constants.ORB) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF).build(); protected static final AttributeDefinition SSL_SOCKET_BINDING = new SimpleAttributeDefinitionBuilder( Constants.ORB_SSL_SOCKET_BINDING, ModelType.STRING, true).setAttributeGroup(Constants.ORB) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF).build(); //TCP attributes protected static final AttributeDefinition HIGH_WATER_MARK = new SimpleAttributeDefinitionBuilder( Constants.TCP_HIGH_WATER_MARK, ModelType.INT, true).setAttributeGroup(Constants.ORB_TCP) .setValidator(new IntRangeValidator(0, Integer.MAX_VALUE, true, false)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).setAllowExpression(true).build(); protected static final AttributeDefinition NUMBER_TO_RECLAIM = new SimpleAttributeDefinitionBuilder( Constants.TCP_NUMBER_TO_RECLAIM, ModelType.INT, true).setAttributeGroup(Constants.ORB_TCP) .setValidator(new IntRangeValidator(0, Integer.MAX_VALUE, true, false)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).setAllowExpression(true).build(); //initializer attributes protected static final AttributeDefinition SECURITY = new SimpleAttributeDefinitionBuilder( Constants.ORB_INIT_SECURITY, ModelType.STRING, true) .setAttributeGroup(Constants.ORB_INIT) .setDefaultValue(NONE) .setValidator(EnumValidator.create(SecurityAllowedValues.class)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF).build(); protected static final AttributeDefinition AUTHENTICATION_CONTEXT = new SimpleAttributeDefinitionBuilder( Constants.ORB_INIT_AUTH_CONTEXT, ModelType.STRING, true) .setAttributeGroup(Constants.ORB_INIT) .setValidator(LENGTH_VALIDATOR) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .setCapabilityReference(Capabilities.AUTH_CONTEXT_CAPABILITY, IIOP_CAPABILITY) .addAccessConstraint(IIOP_SECURITY_DEF).build(); protected static final AttributeDefinition TRANSACTIONS = new SimpleAttributeDefinitionBuilder( Constants.ORB_INIT_TRANSACTIONS, ModelType.STRING, true) .setAttributeGroup(Constants.ORB_INIT) .setDefaultValue(NONE) .setValidator(EnumValidator.create(TransactionsAllowedValues.class)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).setAllowExpression(true).build(); //Naming attributes protected static final AttributeDefinition ROOT_CONTEXT = new SimpleAttributeDefinitionBuilder( Constants.NAMING_ROOT_CONTEXT, ModelType.STRING, true) .setAttributeGroup(Constants.NAMING) .setDefaultValue(new ModelNode(Constants.ROOT_CONTEXT_INIT_REF)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .build(); protected static final AttributeDefinition EXPORT_CORBALOC = new SimpleAttributeDefinitionBuilder( Constants.NAMING_EXPORT_CORBALOC, ModelType.BOOLEAN, true) .setAttributeGroup(Constants.NAMING) .setDefaultValue(ModelNode.TRUE) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .build(); //Security attributes public static final AttributeDefinition SUPPORT_SSL = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_SUPPORT_SSL, ModelType.BOOLEAN, true) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(ModelNode.FALSE) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .build(); public static final AttributeDefinition SECURITY_DOMAIN = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_SECURITY_DOMAIN, ModelType.STRING, true) .setAttributeGroup(Constants.SECURITY) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(LENGTH_VALIDATOR) .addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SECURITY_DOMAIN_REF) .addAccessConstraint(IIOP_SECURITY_DEF) .setAlternatives(Constants.SERVER_SSL_CONTEXT, Constants.CLIENT_SSL_CONTEXT) .setCapabilityReference(Capabilities.LEGACY_SECURITY_DOMAIN_CAPABILITY, IIOP_CAPABILITY) .setDeprecated(ModelVersion.create(3)) .build(); public static final AttributeDefinition SERVER_SSL_CONTEXT = new SimpleAttributeDefinitionBuilder( Constants.SERVER_SSL_CONTEXT, ModelType.STRING, true) .setAttributeGroup(Constants.SECURITY) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .addAccessConstraint(IIOP_SECURITY_DEF) .setValidator(LENGTH_VALIDATOR) .setAlternatives(Constants.SECURITY_SECURITY_DOMAIN) .setRequires(Constants.CLIENT_SSL_CONTEXT) .setCapabilityReference(Capabilities.SSL_CONTEXT_CAPABILITY, IIOP_CAPABILITY) .build(); public static final AttributeDefinition CLIENT_SSL_CONTEXT = new SimpleAttributeDefinitionBuilder( Constants.CLIENT_SSL_CONTEXT, ModelType.STRING, true) .setAttributeGroup(Constants.SECURITY) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .addAccessConstraint(IIOP_SECURITY_DEF) .setValidator(LENGTH_VALIDATOR) .setAlternatives(Constants.SECURITY_SECURITY_DOMAIN) .setRequires(Constants.SERVER_SSL_CONTEXT) .setCapabilityReference(Capabilities.SSL_CONTEXT_CAPABILITY, IIOP_CAPABILITY) .build(); @Deprecated public static final AttributeDefinition ADD_COMPONENT_INTERCEPTOR = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_ADD_COMP_VIA_INTERCEPTOR, ModelType.BOOLEAN, true) .setDeprecated(IIOPExtension.VERSION_1) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(ModelNode.TRUE) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated public static final AttributeDefinition CLIENT_SUPPORTS = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_CLIENT_SUPPORTS, ModelType.STRING, true) .setDeprecated(IIOPExtension.VERSION_1) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(new ModelNode().set(SSLConfigValue.MUTUALAUTH.toString())) .setValidator(SSL_CONFIG_VALIDATOR) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated public static final AttributeDefinition CLIENT_REQUIRES = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_CLIENT_REQUIRES, ModelType.STRING, true) .setDeprecated(IIOPExtension.VERSION_1) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(new ModelNode().set(SSLConfigValue.NONE.toString())) .setValidator(SSL_CONFIG_VALIDATOR) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated public static final AttributeDefinition SERVER_SUPPORTS = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_SERVER_SUPPORTS, ModelType.STRING, true) .setDeprecated(IIOPExtension.VERSION_1) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(new ModelNode().set(SSLConfigValue.MUTUALAUTH.toString())) .setValidator(SSL_CONFIG_VALIDATOR) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated public static final AttributeDefinition SERVER_REQUIRES = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_SERVER_REQUIRES, ModelType.STRING, true) .setDeprecated(IIOPExtension.VERSION_1) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(new ModelNode().set(SSLConfigValue.NONE.toString())) .setValidator(SSL_CONFIG_VALIDATOR) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .setDeprecated(IIOPExtension.VERSION_1) .build(); public static final AttributeDefinition CLIENT_REQUIRES_SSL = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_CLIENT_REQUIRES_SSL, ModelType.BOOLEAN, true) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(new ModelNode().set(Boolean.FALSE)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .build(); public static final AttributeDefinition SERVER_REQUIRES_SSL = new SimpleAttributeDefinitionBuilder( Constants.SECURITY_SERVER_REQUIRES_SSL, ModelType.BOOLEAN, true) .setAttributeGroup(Constants.SECURITY) .setDefaultValue(new ModelNode().set(Boolean.FALSE)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .addAccessConstraint(IIOP_SECURITY_DEF) .build(); public static final AttributeDefinition INTEROP_IONA = new SimpleAttributeDefinitionBuilder( Constants.INTEROP_IONA, ModelType.BOOLEAN, true) .setAttributeGroup(Constants.INTEROP) .setDefaultValue(ModelNode.FALSE) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAllowExpression(true) .build(); protected static final PropertiesAttributeDefinition PROPERTIES = new PropertiesAttributeDefinition.Builder( Constants.PROPERTIES, true) .setAllowExpression(true) .setRestartAllServices() .build(); //ior transport config attributes @Deprecated protected static final AttributeDefinition INTEGRITY = new SimpleAttributeDefinitionBuilder( Constants.IOR_TRANSPORT_INTEGRITY, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_TRANSPORT_CONFIG) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(VALIDATOR) .setAllowExpression(true) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated protected static final AttributeDefinition CONFIDENTIALITY = new SimpleAttributeDefinitionBuilder( Constants.IOR_TRANSPORT_CONFIDENTIALITY, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_TRANSPORT_CONFIG) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(VALIDATOR) .setAllowExpression(true) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated protected static final AttributeDefinition TRUST_IN_TARGET = new SimpleAttributeDefinitionBuilder( Constants.IOR_TRANSPORT_TRUST_IN_TARGET, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_TRANSPORT_CONFIG) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(new EnumValidator<>(IORTransportConfigValues.class, IORTransportConfigValues.NONE, IORTransportConfigValues.SUPPORTED)) .setAllowExpression(true) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated protected static final AttributeDefinition TRUST_IN_CLIENT = new SimpleAttributeDefinitionBuilder( Constants.IOR_TRANSPORT_TRUST_IN_CLIENT, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_TRANSPORT_CONFIG) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(VALIDATOR) .setAllowExpression(true) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated protected static final AttributeDefinition DETECT_REPLAY = new SimpleAttributeDefinitionBuilder( Constants.IOR_TRANSPORT_DETECT_REPLAY, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_TRANSPORT_CONFIG) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(VALIDATOR) .setAllowExpression(true) .setDeprecated(IIOPExtension.VERSION_1) .build(); @Deprecated protected static final AttributeDefinition DETECT_MISORDERING = new SimpleAttributeDefinitionBuilder( Constants.IOR_TRANSPORT_DETECT_MISORDERING, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_TRANSPORT_CONFIG) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(VALIDATOR) .setAllowExpression(true) .setDeprecated(IIOPExtension.VERSION_1) .build(); //ior as context attributes protected static final AttributeDefinition AUTH_METHOD = new SimpleAttributeDefinitionBuilder( Constants.IOR_AS_CONTEXT_AUTH_METHOD, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_AS_CONTEXT) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(new ModelNode(AuthMethodValues.USERNAME_PASSWORD.toString())) .setValidator(EnumValidator.create(AuthMethodValues.class)) .setAllowExpression(true) .build(); protected static final AttributeDefinition REALM = new SimpleAttributeDefinitionBuilder( Constants.IOR_AS_CONTEXT_REALM, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_AS_CONTEXT) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SECURITY_REALM_REF) .setAllowExpression(true) .setDeprecated(ModelVersion.create(3)) .build(); protected static final AttributeDefinition REQUIRED = new SimpleAttributeDefinitionBuilder( Constants.IOR_AS_CONTEXT_REQUIRED, ModelType.BOOLEAN, true) .setAttributeGroup(Constants.IOR_AS_CONTEXT) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(ModelNode.FALSE) .setAllowExpression(true) .build(); //ior sas context attributes protected static final AttributeDefinition CALLER_PROPAGATION = new SimpleAttributeDefinitionBuilder( Constants.IOR_SAS_CONTEXT_CALLER_PROPAGATION, ModelType.STRING, true) .setAttributeGroup(Constants.IOR_SAS_CONTEXT) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(NONE) .setValidator(EnumValidator.create(CallerPropagationValues.class)) .setAllowExpression(true) .build(); // list that contains ORB attribute definitions static final List<AttributeDefinition> ORB_ATTRIBUTES = Arrays.asList(PERSISTENT_SERVER_ID, GIOP_VERSION, SOCKET_BINDING, SSL_SOCKET_BINDING); // list that contains initializers attribute definitions static final List<AttributeDefinition> INITIALIZERS_ATTRIBUTES = Arrays.asList(SECURITY, AUTHENTICATION_CONTEXT, TRANSACTIONS); // list that contains naming attributes definitions static final List<AttributeDefinition> NAMING_ATTRIBUTES = Arrays.asList(ROOT_CONTEXT, EXPORT_CORBALOC); // list that contains security attributes definitions static final List<AttributeDefinition> SECURITY_ATTRIBUTES = Arrays.asList(SUPPORT_SSL, SECURITY_DOMAIN, SERVER_SSL_CONTEXT, CLIENT_SSL_CONTEXT, SERVER_REQUIRES_SSL, CLIENT_REQUIRES_SSL, ADD_COMPONENT_INTERCEPTOR, CLIENT_SUPPORTS, CLIENT_REQUIRES, SERVER_SUPPORTS, SERVER_REQUIRES); // list that contains interoperability attributes definitions static final List<AttributeDefinition> INTEROP_ATTRIBUTES = Arrays.asList(INTEROP_IONA); //list that contains tcp attributes definitions protected static final List<AttributeDefinition> TCP_ATTRIBUTES = Arrays.asList(HIGH_WATER_MARK, NUMBER_TO_RECLAIM); //list that contains ior sas attributes definitions static final List<AttributeDefinition> IOR_SAS_ATTRIBUTES = Arrays.asList(CALLER_PROPAGATION); //list that contains ior as attributes definitions static final List<AttributeDefinition> IOR_AS_ATTRIBUTES = Arrays.asList(AUTH_METHOD, REALM, REQUIRED); //list that contains ior transport config attributes definitions static final List<AttributeDefinition> IOR_TRANSPORT_CONFIG_ATTRIBUTES = Arrays.asList(INTEGRITY, CONFIDENTIALITY, TRUST_IN_TARGET, TRUST_IN_CLIENT, DETECT_REPLAY, DETECT_MISORDERING); static final List<AttributeDefinition> CONFIG_ATTRIBUTES = new ArrayList<>(); static final List<AttributeDefinition> IOR_ATTRIBUTES = new ArrayList<>(); static final List<AttributeDefinition> ALL_ATTRIBUTES = new ArrayList<>(); static { CONFIG_ATTRIBUTES.addAll(ORB_ATTRIBUTES); CONFIG_ATTRIBUTES.addAll(TCP_ATTRIBUTES); CONFIG_ATTRIBUTES.addAll(INITIALIZERS_ATTRIBUTES); CONFIG_ATTRIBUTES.addAll(NAMING_ATTRIBUTES); CONFIG_ATTRIBUTES.addAll(SECURITY_ATTRIBUTES); CONFIG_ATTRIBUTES.addAll(INTEROP_ATTRIBUTES); CONFIG_ATTRIBUTES.add(PROPERTIES); IOR_ATTRIBUTES.addAll(IOR_TRANSPORT_CONFIG_ATTRIBUTES); IOR_ATTRIBUTES.addAll(IOR_AS_ATTRIBUTES); IOR_ATTRIBUTES.addAll(IOR_SAS_ATTRIBUTES); ALL_ATTRIBUTES.addAll(CONFIG_ATTRIBUTES); ALL_ATTRIBUTES.addAll(IOR_ATTRIBUTES); } IIOPRootDefinition() { super(new SimpleResourceDefinition.Parameters(IIOPExtension.PATH_SUBSYSTEM, IIOPExtension.SUBSYSTEM_RESOLVER) .setAddHandler(new IIOPSubsystemAdd(ALL_ATTRIBUTES)) .setRemoveHandler(new ReloadRequiredRemoveStepHandler() { @Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.recordCapabilitiesAndRequirements(context, operation, resource); ModelNode model = resource.getModel(); String security = IIOPRootDefinition.SECURITY.resolveModelAttribute(context, model).asStringOrNull(); if (SecurityAllowedValues.IDENTITY.toString().equals(security) || SecurityAllowedValues.CLIENT.toString().equals(security)) { context.deregisterCapabilityRequirement(LEGACY_SECURITY, Capabilities.IIOP_CAPABILITY, Constants.ORB_INIT_SECURITY); } } }) .addCapabilities(IIOP_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(ALL_ATTRIBUTES) { @Override protected void recordCapabilitiesAndRequirements(OperationContext context, AttributeDefinition attributeDefinition, ModelNode newValue, ModelNode oldValue) { if (attributeDefinition != SECURITY) { super.recordCapabilitiesAndRequirements(context, attributeDefinition, newValue, oldValue); return; } boolean oldIsLegacy; boolean newIsLegacy; try { // For historic reasons this attribute supports expressions so resolution is required. oldIsLegacy = SecurityAllowedValues.IDENTITY.toString().equals(IIOPRootDefinition.SECURITY.resolveValue(context, oldValue).asStringOrNull()) || SecurityAllowedValues.CLIENT.toString().equals(IIOPRootDefinition.SECURITY.resolveValue(context, oldValue).asStringOrNull()); newIsLegacy = SecurityAllowedValues.IDENTITY.toString().equals(IIOPRootDefinition.SECURITY.resolveValue(context, newValue).asStringOrNull()) || SecurityAllowedValues.CLIENT.toString().equals(IIOPRootDefinition.SECURITY.resolveValue(context, newValue).asStringOrNull()); } catch (OperationFailedException e) { throw new RuntimeException(e); } if (oldIsLegacy && !newIsLegacy) { // Capability was registered but no longer required. context.deregisterCapabilityRequirement(LEGACY_SECURITY, Capabilities.IIOP_CAPABILITY, Constants.ORB_INIT_SECURITY); } else if (!oldIsLegacy && newIsLegacy) { // Capability wasn't required but now is. context.registerAdditionalCapabilityRequirement(LEGACY_SECURITY, LEGACY_SECURITY, LEGACY_SECURITY); } // Other permutations mean no change in requirement. } }; for (AttributeDefinition attr : ALL_ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, handler); } } @Override public Collection<AttributeDefinition> getAttributes() { return ALL_ATTRIBUTES; } private enum AuthMethodValues { NONE("none"), USERNAME_PASSWORD("username_password"); private String name; AuthMethodValues(String name) { this.name = name; } @Override public String toString() { return this.name; } } private enum CallerPropagationValues { NONE("none"), SUPPORTED("supported"); private String name; CallerPropagationValues(String name) { this.name = name; } @Override public String toString() { return this.name; } } private enum IORTransportConfigValues { NONE("none"), SUPPORTED("supported"), REQUIRED("required"); private String name; IORTransportConfigValues(String name) { this.name = name; } @Override public String toString() { return this.name; } } }
27,769
48.677996
160
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPSubsystemParser_2_0.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.PersistentResourceXMLDescription.builder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PersistentResourceXMLDescription; import org.jboss.as.controller.PersistentResourceXMLParser; import org.jboss.dmr.ModelNode; /** * <p> * This class implements a parser for the IIOP subsystem. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystemParser_2_0 extends PersistentResourceXMLParser { IIOPSubsystemParser_2_0() { } @Override public PersistentResourceXMLDescription getParserDescription() { return builder(IIOPExtension.PATH_SUBSYSTEM, Namespace.IIOP_OPENJDK_2_0.getUriString()) .setMarshallDefaultValues(true) .addAttributes(IIOPRootDefinition.ALL_ATTRIBUTES.toArray(new AttributeDefinition[0])) .setAdditionalOperationsGenerator((address, addOperation, operations) -> { if(!addOperation.get(IIOPRootDefinition.SOCKET_BINDING.getName()).isDefined()){ addOperation.get(IIOPRootDefinition.SOCKET_BINDING.getName()).set(new ModelNode().set("iiop")); } }) .build(); } }
2,401
39.033333
119
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/TransactionsAllowedValues.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; /** * <p> * Enumeration of the allowed IIOP subsystem configuration values. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> */ enum TransactionsAllowedValues { FULL("full"), NONE("none"), SPEC("spec"); private String name; TransactionsAllowedValues(String name) { this.name = name; } @Override public String toString() { return this.name; } }
1,464
30.847826
69
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPSubsystemParser_1.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.PersistentResourceXMLDescription.builder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PersistentResourceXMLDescription; import org.jboss.as.controller.PersistentResourceXMLParser; import org.jboss.dmr.ModelNode; /** * <p> * This class implements a parser for the IIOP subsystem. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ class IIOPSubsystemParser_1 extends PersistentResourceXMLParser { IIOPSubsystemParser_1() { } @Override public PersistentResourceXMLDescription getParserDescription() { return builder(IIOPExtension.PATH_SUBSYSTEM) .setMarshallDefaultValues(true) .addAttributes(IIOPRootDefinition.ALL_ATTRIBUTES.toArray(new AttributeDefinition[0])) .setAdditionalOperationsGenerator((address, addOperation, operations) -> { if(!addOperation.get(IIOPRootDefinition.SOCKET_BINDING.getName()).isDefined()){ addOperation.get(IIOPRootDefinition.SOCKET_BINDING.getName()).set(new ModelNode().set("iiop")); } }) .build(); } }
2,344
40.140351
119
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/Capabilities.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; /** * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ final class Capabilities { /* Capabilities in this subsystem */ public static final String IIOP_CAPABILITY = "org.wildfly.iiop"; /* References to capabilities outside of the subsystem */ public static final String LEGACY_SECURITY = "org.wildfly.legacy-security"; public static final String LEGACY_SECURITY_DOMAIN_CAPABILITY = "org.wildfly.security.legacy-security-domain"; public static final String SSL_CONTEXT_CAPABILITY = "org.wildfly.security.ssl-context"; public static final String AUTH_CONTEXT_CAPABILITY = "org.wildfly.security.authentication-context"; }
1,743
39.55814
113
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPSubsystemParser_3_0.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.PersistentResourceXMLDescription.builder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PersistentResourceXMLDescription; import org.jboss.as.controller.PersistentResourceXMLParser; /** * <p> * This class implements a parser for the IIOP subsystem. * </p> * * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystemParser_3_0 extends PersistentResourceXMLParser { IIOPSubsystemParser_3_0() { } @Override public PersistentResourceXMLDescription getParserDescription() { return builder(IIOPExtension.PATH_SUBSYSTEM, Namespace.IIOP_OPENJDK_3_0.getUriString()) .setMarshallDefaultValues(true) .addAttributes(IIOPRootDefinition.ALL_ATTRIBUTES.toArray(new AttributeDefinition[0])) .build(); } }
1,951
35.148148
101
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPExtension.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import org.jboss.as.controller.Extension; import org.jboss.as.controller.ExtensionContext; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver; import org.jboss.as.controller.descriptions.SubsystemResourceDescriptionResolver; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * <p> * The IIOP extension implementation. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPExtension implements Extension { public static final String SUBSYSTEM_NAME = "iiop-openjdk"; protected static final PathElement PATH_SUBSYSTEM = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); static final ParentResourceDescriptionResolver SUBSYSTEM_RESOLVER = new SubsystemResourceDescriptionResolver(SUBSYSTEM_NAME, IIOPExtension.class); static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(3); static final ModelVersion VERSION_2_1 = ModelVersion.create(2, 1); static final ModelVersion VERSION_2 = ModelVersion.create(2,0,0); static final ModelVersion VERSION_1 = ModelVersion.create(1); @Override public void initialize(ExtensionContext context) { final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION); final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(new IIOPRootDefinition()); subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); subsystem.registerXMLElementWriter(new IIOPSubsystemParser_3_0()); } @Override public void initializeParsers(ExtensionParsingContext context) { context.setSubsystemXmlMapping(SUBSYSTEM_NAME,Namespace.IIOP_OPENJDK_1_0.getUriString(), IIOPSubsystemParser_1::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME,Namespace.IIOP_OPENJDK_2_0.getUriString(), IIOPSubsystemParser_2_0::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME,Namespace.IIOP_OPENJDK_2_1.getUriString(), IIOPSubsystemParser_2_1::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME,Namespace.IIOP_OPENJDK_3_0.getUriString(), IIOPSubsystemParser_3_0::new); } }
3,762
47.87013
150
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/SecurityAllowedValues.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of / * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; /** * <p> * Enumeration of the allowed iiop subsystem configuration values. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> */ enum SecurityAllowedValues { IDENTITY("identity"), CLIENT("client"), ELYTRON("elytron"), NONE("none"); private String name; SecurityAllowedValues(String name) { this.name = name; } @Override public String toString() { return this.name; } }
1,500
29.632653
69
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import java.util.HashMap; import java.util.Map; /** * <p> * Enumeration of {@code ORB} initializer groups. Each member contains one or more initializer classes that belong to a * specific group. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public enum IIOPInitializer { UNKNOWN("", ""), // the security group encompasses both CSIv2 and SAS initializers. SECURITY_ELYTRON("elytron", "org.wildfly.iiop.openjdk.csiv2.CSIv2Initializer", "org.wildfly.iiop.openjdk.csiv2.ElytronSASInitializer"), // the transaction group encompasses the Interposition and InboundCurrent initializers. TRANSACTIONS("transactions", "com.arjuna.ats.jts.orbspecific.javaidl.interceptors.interposition.InterpositionORBInitializerImpl", "org.jboss.iiop.tm.InboundTransactionCurrentInitializer", "org.wildfly.iiop.openjdk.tm.TxIORInterceptorInitializer", "org.wildfly.iiop.openjdk.tm.TxServerInterceptorInitializer"), // the transaction group that is used for spec compliant mode without JTS SPEC_TRANSACTIONS("specTransactions", "org.wildfly.iiop.openjdk.tm.TxServerInterceptorInitializer"); private final String initializerName; private final String[] initializerClasses; /** * <p> * {@code ORBInitializer} constructor. Sets the group name and implementation classes of the initializers that are * part of the group. * </p> * * @param initializerName the name that identifies the initializer group. * @param initializerClasses an array containing the fully-qualified name of the initializers that compose the group. */ IIOPInitializer(final String initializerName, final String... initializerClasses) { this.initializerName = initializerName; this.initializerClasses = initializerClasses; } /** * <p> * Obtains the name of this initializer group. * </p> * * @return a {@code String} that represents the initializer group name. */ public String getInitializerName() { return this.initializerName; } /** * <p> * Obtains the class names of the initializers that are part of this group. * </p> * * @return a {@code String[]} containing the fully-qualified class names of the initializers. */ public String[] getInitializerClasses() { return this.initializerClasses; } // a map that caches all available initializer groups by name. private static final Map<String, IIOPInitializer> MAP; static { final Map<String, IIOPInitializer> map = new HashMap<String, IIOPInitializer>(); for (IIOPInitializer element : values()) { final String name = element.getInitializerName(); if (name != null) map.put(name, element); } MAP = map; } /** * <p> * Gets the {@code ORBInitializer} instance identified by the specified group name. * </p> * * @param initializerName a {@code String} representing the initializer group name. * @return the {@code ORBInitializer} identified by the name. If no implementation can be found, the * {@code ORBInitializer.UNKNOWN} type is returned. */ static IIOPInitializer fromName(final String initializerName) { final IIOPInitializer element = MAP.get(initializerName); return element == null ? UNKNOWN : element; } }
4,612
37.123967
139
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/Namespace.java
package org.wildfly.iiop.openjdk; /* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ /** * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ import java.util.HashMap; import java.util.Map; enum Namespace { UNKNOWN(null), IIOP_OPENJDK_1_0("urn:jboss:domain:iiop-openjdk:1.0"), IIOP_OPENJDK_2_0("urn:jboss:domain:iiop-openjdk:2.0"), IIOP_OPENJDK_2_1("urn:jboss:domain:iiop-openjdk:2.1"), IIOP_OPENJDK_3_0("urn:jboss:domain:iiop-openjdk:3.0"); static final Namespace CURRENT = IIOP_OPENJDK_3_0; private final String namespaceURI; /** * <p> * {@code Namespace} constructor. Sets the namespace {@code URI}. * </p> * * @param namespaceURI a {@code String} representing the namespace {@code URI}. */ private Namespace(final String namespaceURI) { this.namespaceURI = namespaceURI; } /** * <p> * Obtains the {@code URI} of this namespace. * </p> * * @return a {@code String} representing the namespace {@code URI}. */ String getUriString() { return namespaceURI; } // a map that caches all available namespaces by URI. private static final Map<String, Namespace> MAP; static { final Map<String, Namespace> map = new HashMap<String, Namespace>(); for (final Namespace namespace : values()) { final String name = namespace.getUriString(); if (name != null) map.put(name, namespace); } MAP = map; } /** * <p> * Gets the {@code Namespace} identified by the specified {@code URI}. * </p> * * @param uri a {@code String} representing the namespace {@code URI}. * @return the {@code Namespace} identified by the {@code URI}. If no namespace can be found, the {@code Namespace.UNKNOWN} * type is returned. */ static Namespace forUri(final String uri) { final Namespace element = MAP.get(uri); return element == null ? UNKNOWN : element; } }
3,022
31.159574
127
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/IIOPSubsystemAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import static org.jboss.as.controller.resource.AbstractSocketBindingResourceDefinition.SOCKET_BINDING_CAPABILITY_NAME; import static org.wildfly.iiop.openjdk.logging.IIOPLogger.ROOT_LOGGER; import static org.wildfly.iiop.openjdk.Capabilities.IIOP_CAPABILITY; import static org.wildfly.iiop.openjdk.Capabilities.LEGACY_SECURITY; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.function.Consumer; import java.util.function.Supplier; import javax.net.ssl.SSLContext; import com.sun.corba.se.impl.orbutil.ORBConstants; import org.jboss.as.controller.AbstractBoottimeAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityServiceBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PropertiesAttributeDefinition; import org.jboss.as.controller.registry.Resource; import org.jboss.as.naming.InitialContext; import org.jboss.as.network.SocketBinding; import org.jboss.as.server.AbstractDeploymentChainStep; import org.jboss.as.server.DeploymentProcessorTarget; import org.jboss.as.server.Services; import org.jboss.as.server.deployment.Phase; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.jboss.metadata.ejb.jboss.IORASContextMetaData; import org.jboss.metadata.ejb.jboss.IORSASContextMetaData; import org.jboss.metadata.ejb.jboss.IORSecurityConfigMetaData; import org.jboss.metadata.ejb.jboss.IORTransportConfigMetaData; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.omg.CORBA.ORB; import org.omg.PortableServer.IdAssignmentPolicyValue; import org.omg.PortableServer.LifespanPolicyValue; import org.omg.PortableServer.POA; import org.wildfly.common.function.Functions; import org.wildfly.iiop.openjdk.csiv2.CSIV2IORToSocketInfo; import org.wildfly.iiop.openjdk.csiv2.ElytronSASClientInterceptor; import org.wildfly.iiop.openjdk.deployment.IIOPClearCachesProcessor; import org.wildfly.iiop.openjdk.deployment.IIOPDependencyProcessor; import org.wildfly.iiop.openjdk.deployment.IIOPMarkerProcessor; import org.wildfly.iiop.openjdk.logging.IIOPLogger; import org.wildfly.iiop.openjdk.naming.jndi.JBossCNCtxFactory; import org.wildfly.iiop.openjdk.rmi.DelegatingStubFactoryFactory; import org.wildfly.iiop.openjdk.security.NoSSLSocketFactory; import org.wildfly.iiop.openjdk.security.SSLSocketFactory; import org.wildfly.iiop.openjdk.service.CorbaNamingService; import org.wildfly.iiop.openjdk.service.CorbaORBService; import org.wildfly.iiop.openjdk.service.CorbaPOAService; import org.wildfly.iiop.openjdk.service.IORSecConfigMetaDataService; import org.wildfly.security.auth.client.AuthenticationContext; import org.wildfly.security.manager.WildFlySecurityManager; /** * <p> * This class implements a {@code ModelAddOperationHandler} that installs the IIOP subsystem services: * <ul> * <li>{@code CorbaORBService}: responsible for configuring and starting the CORBA {@code ORB}.</li> * <li>{@code CorbaPOAService}: responsible for creating and activating CORBA {@code POA}s.</li> * <li>{@code CorbaNamingService}: responsible for creating and starting the CORBA naming service.</li> * </ul> * After the {@code ORB} is created, we create and activate the "RootPOA" and then use this {@code POA} to create the * {@code POA}s required by the other services. * </p> * * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class IIOPSubsystemAdd extends AbstractBoottimeAddStepHandler { public IIOPSubsystemAdd(final Collection<? extends AttributeDefinition> attributes) { super(attributes); } @Override protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { // This needs to run after all child resources so that they can detect a fresh state context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode node = Resource.Tools.readModel(resource); launchServices(context, node); // Rollback handled by the parent step context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME); } @Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { super.populateModel(context, operation, resource); final ModelNode model = resource.getModel(); ConfigValidator.validateConfig(context, model); } @Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.recordCapabilitiesAndRequirements(context, operation, resource); if (IIOPExtension.SUBSYSTEM_NAME.equals(context.getCurrentAddressValue())) { ModelNode model = resource.getModel(); String security = IIOPRootDefinition.SECURITY.resolveModelAttribute(context, model).asStringOrNull(); if (SecurityAllowedValues.IDENTITY.toString().equals(security) || SecurityAllowedValues.CLIENT.toString().equals(security)) { context.registerAdditionalCapabilityRequirement(LEGACY_SECURITY, IIOP_CAPABILITY, Constants.ORB_INIT_SECURITY); } } } protected void launchServices(final OperationContext context, final ModelNode model) throws OperationFailedException { IIOPLogger.ROOT_LOGGER.activatingSubsystem(); // set the ORBUseDynamicStub system property. WildFlySecurityManager.setPropertyPrivileged("org.jboss.com.sun.CORBA.ORBUseDynamicStub", "true"); // we set the same stub factory to both the static and dynamic stub factory. As there is no way to dynamically change // the userDynamicStubs's property at runtime it is possible for the ORB class's <clinit> method to be // called before this property is set. // TODO: investigate a better way to handle this com.sun.corba.se.spi.orb.ORB.getPresentationManager().setStubFactoryFactory(true, new DelegatingStubFactoryFactory()); com.sun.corba.se.spi.orb.ORB.getPresentationManager().setStubFactoryFactory(false, new DelegatingStubFactoryFactory()); // setup naming. InitialContext.addUrlContextFactory("corbaloc", JBossCNCtxFactory.INSTANCE); InitialContext.addUrlContextFactory("corbaname", JBossCNCtxFactory.INSTANCE); InitialContext.addUrlContextFactory("IOR", JBossCNCtxFactory.INSTANCE); InitialContext.addUrlContextFactory("iiopname", JBossCNCtxFactory.INSTANCE); InitialContext.addUrlContextFactory("iiop", JBossCNCtxFactory.INSTANCE); context.addStep(new AbstractDeploymentChainStep() { @Override public void execute(DeploymentProcessorTarget processorTarget) { processorTarget.addDeploymentProcessor(IIOPExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_IIOP_OPENJDK, new IIOPDependencyProcessor()); processorTarget.addDeploymentProcessor(IIOPExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_IIOP_OPENJDK, new IIOPMarkerProcessor()); processorTarget.addDeploymentProcessor(IIOPExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_IIOP_CLEAR_CACHES, new IIOPClearCachesProcessor()); } }, OperationContext.Stage.RUNTIME); // get the configured ORB properties. Properties props = this.getConfigurationProperties(context, model); // setup the ORB initializers using the configured properties. this.setupInitializers(props); // setup the SSL socket factories, if necessary. final boolean sslConfigured = this.setupSSLFactories(props); // create the service that initializes and starts the CORBA ORB. final CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(org.wildfly.iiop.openjdk.IIOPRootDefinition.IIOP_CAPABILITY); final Consumer<ORB> serviceConsumer = builder.provides(org.wildfly.iiop.openjdk.IIOPRootDefinition.IIOP_CAPABILITY, CorbaORBService.SERVICE_NAME); Supplier<ExecutorService> executorServiceSupplier = Services.requireServerExecutor(builder); Supplier<SocketBinding> iiopSocketBindingSupplier = Functions.constantSupplier(null); Supplier<SocketBinding> iiopSSLSocketBindingSupplier = Functions.constantSupplier(null); // if a security domain has been specified, add a dependency to the domain service. String securityDomain = props.getProperty(Constants.SECURITY_SECURITY_DOMAIN); if (securityDomain != null) { throw ROOT_LOGGER.runtimeSecurityDomainUnsupported(); } // add dependencies to the ssl context services if needed. final String serverSSLContextName = props.getProperty(Constants.SERVER_SSL_CONTEXT); if (serverSSLContextName != null) { ServiceName serverContextServiceName = context.getCapabilityServiceName(Capabilities.SSL_CONTEXT_CAPABILITY, serverSSLContextName, SSLContext.class); builder.requires(serverContextServiceName); } final String clientSSLContextName = props.getProperty(Constants.CLIENT_SSL_CONTEXT); if (clientSSLContextName != null) { ServiceName clientContextServiceName = context.getCapabilityServiceName(Capabilities.SSL_CONTEXT_CAPABILITY, clientSSLContextName, SSLContext.class); builder.requires(clientContextServiceName); } // if an authentication context has ben specified, add a dependency to its service. final String authContext = props.getProperty(Constants.ORB_INIT_AUTH_CONTEXT); if (authContext != null) { ServiceName authContextServiceName = context.getCapabilityServiceName(Capabilities.AUTH_CONTEXT_CAPABILITY, authContext, AuthenticationContext.class); builder.requires(authContextServiceName); } final boolean serverRequiresSsl = IIOPRootDefinition.SERVER_REQUIRES_SSL.resolveModelAttribute(context, model).asBoolean(); // inject the socket bindings that specify IIOP and IIOP/SSL ports. String socketBinding = props.getProperty(Constants.ORB_SOCKET_BINDING); if (socketBinding != null) { if (!serverRequiresSsl) { iiopSocketBindingSupplier = builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, socketBinding); } else { IIOPLogger.ROOT_LOGGER.wontUseCleartextSocket(); } } String sslSocketBinding = props.getProperty(Constants.ORB_SSL_SOCKET_BINDING); if(sslSocketBinding != null) { iiopSSLSocketBindingSupplier = builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, sslSocketBinding); } // create the IOR security config metadata service. final IORSecurityConfigMetaData securityConfigMetaData = this.createIORSecurityConfigMetaData(context, model, sslConfigured, serverRequiresSsl); final IORSecConfigMetaDataService securityConfigMetaDataService = new IORSecConfigMetaDataService(securityConfigMetaData); context.getServiceTarget() .addService(IORSecConfigMetaDataService.SERVICE_NAME, securityConfigMetaDataService) .setInitialMode(ServiceController.Mode.ACTIVE).install(); builder.requires(IORSecConfigMetaDataService.SERVICE_NAME); builder.setInitialMode(ServiceController.Mode.ACTIVE); CorbaORBService orbService = new CorbaORBService(props, serviceConsumer, executorServiceSupplier, iiopSocketBindingSupplier, iiopSSLSocketBindingSupplier); builder.setInstance(orbService); // set the initial mode and install the service. builder.install(); // create the service the initializes the Root POA. CorbaPOAService rootPOAService = new CorbaPOAService("RootPOA", "poa", serverRequiresSsl); context.getServiceTarget().addService(CorbaPOAService.ROOT_SERVICE_NAME, rootPOAService) .addDependency(CorbaORBService.SERVICE_NAME, ORB.class, rootPOAService.getORBInjector()) .setInitialMode(ServiceController.Mode.ACTIVE).install(); // create the service the initializes the interface repository POA. final CorbaPOAService irPOAService = new CorbaPOAService("IRPOA", "irpoa", serverRequiresSsl, IdAssignmentPolicyValue.USER_ID, null, null, LifespanPolicyValue.PERSISTENT, null, null, null); context.getServiceTarget() .addService(CorbaPOAService.INTERFACE_REPOSITORY_SERVICE_NAME, irPOAService) .addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, irPOAService.getParentPOAInjector()) .setInitialMode(ServiceController.Mode.ACTIVE).install(); // create the service that initializes the naming service POA. final CorbaPOAService namingPOAService = new CorbaPOAService("Naming", null, serverRequiresSsl, IdAssignmentPolicyValue.USER_ID, null, null, LifespanPolicyValue.PERSISTENT, null, null, null); context.getServiceTarget() .addService(CorbaPOAService.SERVICE_NAME.append("namingpoa"), namingPOAService) .addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, namingPOAService.getParentPOAInjector()) .setInitialMode(ServiceController.Mode.ACTIVE).install(); // create the CORBA naming service. final CorbaNamingService namingService = new CorbaNamingService(props); context .getServiceTarget() .addService(CorbaNamingService.SERVICE_NAME, namingService) .addDependency(CorbaORBService.SERVICE_NAME, ORB.class, namingService.getORBInjector()) .addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, namingService.getRootPOAInjector()) .addDependency(CorbaPOAService.SERVICE_NAME.append("namingpoa"), POA.class, namingService.getNamingPOAInjector()) .setInitialMode(ServiceController.Mode.ACTIVE).install(); configureClientSecurity(props); } /** * <p> * Obtains the subsystem configuration properties from the specified {@code ModelNode}, using default values for undefined * properties. If the property has a IIOP equivalent, it is translated into its IIOP counterpart before being added to * the returned {@code Properties} object. * </p> * * @param model the {@code ModelNode} that contains the subsystem configuration properties. * @return a {@code Properties} instance containing all configured subsystem properties. * @throws OperationFailedException if an error occurs while resolving the properties. */ protected Properties getConfigurationProperties(OperationContext context, ModelNode model) throws OperationFailedException { Properties properties = new Properties(); for (AttributeDefinition attrDefinition : IIOPRootDefinition.ALL_ATTRIBUTES) { if(attrDefinition instanceof PropertiesAttributeDefinition){ ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model); if(resolvedModelAttribute.isDefined()) { for (final Property prop : resolvedModelAttribute.asPropertyList()) { properties.setProperty(prop.getName(), prop.getValue().asString()); } } continue; } ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model); //FIXME if (resolvedModelAttribute.isDefined()) { String name = attrDefinition.getName(); String value = resolvedModelAttribute.asString(); String openjdkProperty = PropertiesMap.PROPS_MAP.get(name); if (openjdkProperty != null) { name = openjdkProperty; } properties.setProperty(name, value); } } return properties; } /** * <p> * Sets up the ORB initializers according to what has been configured in the subsystem. * </p> * * @param props the subsystem configuration properties. */ private void setupInitializers(Properties props) { List<String> orbInitializers = new ArrayList<String>(); // check which groups of initializers are to be installed. String installSecurity = (String) props.remove(Constants.ORB_INIT_SECURITY); if (installSecurity.equalsIgnoreCase(Constants.CLIENT) || installSecurity.equalsIgnoreCase(Constants.IDENTITY)) { throw ROOT_LOGGER.legacySecurityUnsupported(); } else if (installSecurity.equalsIgnoreCase(Constants.ELYTRON)) { final String authContext = props.getProperty(Constants.ORB_INIT_AUTH_CONTEXT); ElytronSASClientInterceptor.setAuthenticationContextName(authContext); orbInitializers.addAll(Arrays.asList(IIOPInitializer.SECURITY_ELYTRON.getInitializerClasses())); } String installTransaction = (String) props.remove(Constants.ORB_INIT_TRANSACTIONS); if (installTransaction.equalsIgnoreCase(Constants.FULL)) { orbInitializers.addAll(Arrays.asList(IIOPInitializer.TRANSACTIONS.getInitializerClasses())); } else if (installTransaction.equalsIgnoreCase(Constants.SPEC)) { orbInitializers.addAll(Arrays.asList(IIOPInitializer.SPEC_TRANSACTIONS.getInitializerClasses())); } // add the standard opendk initializer plus all configured initializers. for (String initializerClass : orbInitializers) { props.setProperty(Constants.ORB_INITIALIZER_PREFIX + initializerClass, ""); } } /** * <p> * Sets up the SSL domain socket factories if SSL support has been enabled. * </p> * * @param props the subsystem configuration properties. * @return true if ssl has been configured * @throws OperationFailedException if the SSL setup has not been done correctly (SSL support has been turned on but no * security domain has been specified). */ private boolean setupSSLFactories(final Properties props) throws OperationFailedException { final boolean supportSSL = "true".equalsIgnoreCase(props.getProperty(Constants.SECURITY_SUPPORT_SSL)); final boolean sslConfigured; if (supportSSL) { // if the config is using Elytron supplied SSL contexts, install the SSLSocketFactory. final String serverSSLContextName = props.getProperty(Constants.SERVER_SSL_CONTEXT); final String clientSSLContextName = props.getProperty(Constants.CLIENT_SSL_CONTEXT); if (serverSSLContextName != null && clientSSLContextName != null) { SSLSocketFactory.setServerSSLContextName(serverSSLContextName); SSLSocketFactory.setClientSSLContextName(clientSSLContextName); props.setProperty(ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY, SSLSocketFactory.class.getName()); } else { throw ROOT_LOGGER.legacySecurityUnsupported(); } sslConfigured = true; } else { props.setProperty(ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY, NoSSLSocketFactory.class.getName()); sslConfigured = false; } return sslConfigured; } private IORSecurityConfigMetaData createIORSecurityConfigMetaData(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final boolean serverRequiresSsl) throws OperationFailedException { final IORSecurityConfigMetaData securityConfigMetaData = new IORSecurityConfigMetaData(); final IORSASContextMetaData sasContextMetaData = new IORSASContextMetaData(); sasContextMetaData.setCallerPropagation(IIOPRootDefinition.CALLER_PROPAGATION.resolveModelAttribute(context, resourceModel).asString()); securityConfigMetaData.setSasContext(sasContextMetaData); final IORASContextMetaData asContextMetaData = new IORASContextMetaData(); asContextMetaData.setAuthMethod(IIOPRootDefinition.AUTH_METHOD.resolveModelAttribute(context, resourceModel).asString()); if (resourceModel.hasDefined(IIOPRootDefinition.REALM.getName())) { throw ROOT_LOGGER.runtimeSecurityRealmUnsupported(); } asContextMetaData.setRequired(IIOPRootDefinition.REQUIRED.resolveModelAttribute(context, resourceModel).asBoolean()); securityConfigMetaData.setAsContext(asContextMetaData); final IORTransportConfigMetaData transportConfigMetaData = new IORTransportConfigMetaData(); final ModelNode integrityNode = IIOPRootDefinition.INTEGRITY.resolveModelAttribute(context, resourceModel); if(integrityNode.isDefined()){ transportConfigMetaData.setIntegrity(integrityNode.asString()); } else { transportConfigMetaData.setIntegrity(sslConfigured ? (serverRequiresSsl ? Constants.IOR_REQUIRED : Constants.IOR_SUPPORTED) : Constants.NONE); } final ModelNode confidentialityNode = IIOPRootDefinition.CONFIDENTIALITY.resolveModelAttribute(context, resourceModel); if(confidentialityNode.isDefined()){ transportConfigMetaData.setConfidentiality(confidentialityNode.asString()); } else { transportConfigMetaData.setConfidentiality(sslConfigured ? (serverRequiresSsl ? Constants.IOR_REQUIRED: Constants.IOR_SUPPORTED) : Constants.IOR_NONE); } final ModelNode establishTrustInTargetNode = IIOPRootDefinition.TRUST_IN_TARGET.resolveModelAttribute(context, resourceModel); if (establishTrustInTargetNode.isDefined()) { transportConfigMetaData.setEstablishTrustInTarget(confidentialityNode.asString()); } else { transportConfigMetaData.setEstablishTrustInTarget(sslConfigured ? Constants.IOR_SUPPORTED : Constants.NONE); } final ModelNode establishTrustInClientNode = IIOPRootDefinition.TRUST_IN_CLIENT.resolveModelAttribute(context, resourceModel); if(establishTrustInClientNode.isDefined()){ transportConfigMetaData.setEstablishTrustInClient(establishTrustInClientNode.asString()); } else { transportConfigMetaData.setEstablishTrustInClient(sslConfigured ? (serverRequiresSsl ? Constants.IOR_REQUIRED : Constants.IOR_SUPPORTED) : Constants.NONE); } transportConfigMetaData.setDetectMisordering(Constants.IOR_SUPPORTED); transportConfigMetaData.setDetectReplay(Constants.IOR_SUPPORTED); securityConfigMetaData.setTransportConfig(transportConfigMetaData); return securityConfigMetaData; } private void configureClientSecurity(final Properties props) { final boolean clientRequiresSSL = Boolean.getBoolean(props.getProperty(Constants.SECURITY_CLIENT_REQUIRES_SSL)); CSIV2IORToSocketInfo.setClientRequiresSSL(clientRequiresSSL); } }
25,138
53.65
194
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/ConfigValidator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.wildfly.iiop.openjdk.logging.IIOPLogger; import java.util.LinkedList; import java.util.List; /** * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> */ public class ConfigValidator { private ConfigValidator(){ } public static List<String> validateConfig(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { final List<String> warnings = new LinkedList<>(); validateSocketBindings(context, resourceModel); final boolean supportSSL = IIOPRootDefinition.SUPPORT_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); final boolean serverRequiresSsl = IIOPRootDefinition.SERVER_REQUIRES_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); final boolean clientRequiresSsl = IIOPRootDefinition.CLIENT_REQUIRES_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); final boolean sslConfigured = isSSLConfigured(context, resourceModel); validateSSLConfig(supportSSL, sslConfigured, serverRequiresSsl, clientRequiresSsl); validateSSLSocketBinding(context, resourceModel, sslConfigured, warnings); validateIORTransportConfig(context, resourceModel, supportSSL, serverRequiresSsl, warnings); validateORBInitializerConfig(context, resourceModel); return warnings; } private static void validateSocketBindings(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { final ModelNode socketBinding = IIOPRootDefinition.SOCKET_BINDING.resolveModelAttribute(context, resourceModel); final ModelNode sslSocketBinding = IIOPRootDefinition.SSL_SOCKET_BINDING.resolveModelAttribute(context, resourceModel); if(!socketBinding.isDefined() && !sslSocketBinding.isDefined()){ throw IIOPLogger.ROOT_LOGGER.noSocketBindingsConfigured(); } } private static boolean isSSLConfigured(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { final ModelNode securityDomainNode = IIOPRootDefinition.SECURITY_DOMAIN.resolveModelAttribute(context, resourceModel); final ModelNode serverSSLContextNode = IIOPRootDefinition.SERVER_SSL_CONTEXT.resolveModelAttribute(context, resourceModel); final ModelNode clientSSLContextNode = IIOPRootDefinition.CLIENT_SSL_CONTEXT.resolveModelAttribute(context, resourceModel); if (!securityDomainNode.isDefined() && (!serverSSLContextNode.isDefined() || !clientSSLContextNode.isDefined())){ return false; } else { return true; } } private static void validateSSLConfig(final boolean supportSSL, final boolean sslConfigured, final boolean serverRequiresSsl, final boolean clientRequiresSsl) throws OperationFailedException { if (supportSSL) { if (!sslConfigured) { throw IIOPLogger.ROOT_LOGGER.noSecurityDomainOrSSLContextsSpecified(); } } else if (serverRequiresSsl || clientRequiresSsl) { // if either the server or the client requires SSL, then SSL support must have been enabled. throw IIOPLogger.ROOT_LOGGER.sslNotConfigured(); } } private static void validateSSLSocketBinding(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final List<String> warnings) throws OperationFailedException{ ModelNode sslSocketBinding = IIOPRootDefinition.SSL_SOCKET_BINDING.resolveModelAttribute(context, resourceModel); if(sslSocketBinding.isDefined() && !sslConfigured){ final String warning = IIOPLogger.ROOT_LOGGER.sslPortWithoutSslConfiguration(); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } private static void validateIORTransportConfig(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final boolean serverRequiresSsl, final List<String> warnings) throws OperationFailedException { validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.INTEGRITY, warnings); validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.CONFIDENTIALITY, warnings); validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.TRUST_IN_CLIENT, warnings); validateTrustInTarget(context, resourceModel, sslConfigured, warnings); validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_MISORDERING, warnings); validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_REPLAY, warnings); } private static void validateSSLAttribute(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final boolean serverRequiresSsl, final AttributeDefinition attributeDefinition, final List<String> warnings) throws OperationFailedException { final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); if(attributeNode.isDefined()){ final String attribute = attributeNode.asString(); if(sslConfigured) { if(attribute.equals(Constants.IOR_NONE)){ final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName(), serverRequiresSsl ? Constants.IOR_REQUIRED : Constants.IOR_SUPPORTED); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } if (serverRequiresSsl && attribute.equals(Constants.IOR_SUPPORTED)) { final String warning = IIOPLogger.ROOT_LOGGER.inconsistentRequiredTransportConfig(Constants.SECURITY_SERVER_REQUIRES_SSL, attributeDefinition.getName()); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } else { if(!attribute.equals(Constants.IOR_NONE)){ final String warning = IIOPLogger.ROOT_LOGGER.inconsistentUnsupportedTransportConfig(attributeDefinition.getName()); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } } } private static void validateTrustInTarget(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final List<String> warnings) throws OperationFailedException { final ModelNode establishTrustInTargetNode = IIOPRootDefinition.TRUST_IN_TARGET.resolveModelAttribute(context, resourceModel); if(establishTrustInTargetNode.isDefined()){ final String establishTrustInTarget = establishTrustInTargetNode.asString(); if(sslConfigured && establishTrustInTarget.equals(Constants.IOR_NONE)){ final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(Constants.IOR_TRANSPORT_TRUST_IN_TARGET, Constants.IOR_SUPPORTED); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } } private static void validateSupportedAttribute(final OperationContext context, final ModelNode resourceModel, final AttributeDefinition attributeDefinition, final List<String> warnings) throws OperationFailedException{ final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); if(attributeNode.isDefined() && !attributeNode.asString().equals(Constants.IOR_SUPPORTED)) { final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName(), Constants.IOR_SUPPORTED); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } private static void validateORBInitializerConfig(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { // validate the elytron initializer configuration: it requires an authentication-context name. final ModelNode securityInitializerNode = IIOPRootDefinition.SECURITY.resolveModelAttribute(context, resourceModel); final ModelNode authContextNode = IIOPRootDefinition.AUTHENTICATION_CONTEXT.resolveModelAttribute(context, resourceModel); if ((!securityInitializerNode.isDefined() || !securityInitializerNode.asString().equalsIgnoreCase(Constants.ELYTRON)) && authContextNode.isDefined()) { // authentication-context has been specified but is ineffective because the security initializer is not set to // 'elytron'. throw IIOPLogger.ROOT_LOGGER.ineffectiveAuthenticationContextConfiguration(); } } }
10,260
59.358824
279
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi/ValueAnalysis.java
/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk.rmi; import java.io.Externalizable; import java.io.ObjectStreamField; import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.rmi.Remote; import java.util.ArrayList; import java.util.Comparator; import java.util.SortedSet; import java.util.TreeSet; import org.omg.CORBA.portable.IDLEntity; import org.omg.CORBA.portable.ValueBase; import org.wildfly.iiop.openjdk.logging.IIOPLogger; /** * Value analysis. * <p/> * Routines here are conforming to the "Java(TM) Language to IDL Mapping * Specification", version 1.1 (01-06-07). * * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a> */ public class ValueAnalysis extends ContainerAnalysis { private static WorkCacheManager cache = new WorkCacheManager(ValueAnalysis.class); /** * Analysis of our superclass, of null if our superclass is * java.lang.Object. */ private ValueAnalysis superAnalysis; /** * Flags that this is an abstract value. */ private boolean abstractValue = false; /** * Flags that this implements <code>java.io.Externalizable</code>. */ private boolean externalizable = false; /** * Flags that this has a <code>writeObject()</code> method. */ private boolean hasWriteObjectMethod = false; /** * The <code>serialPersistentFields of the value, or <code>null</code> * if the value does not have this field. */ private ObjectStreamField[] serialPersistentFields; /** * The value members of this value class. */ private ValueMemberAnalysis[] members; public static ValueAnalysis getValueAnalysis(Class cls) throws RMIIIOPViolationException { return (ValueAnalysis) cache.getAnalysis(cls); } public static void clearCache(final ClassLoader classLoader) { cache.clearClassLoader(classLoader); } protected ValueAnalysis(final Class cls) { super(cls); } public String getIDLModuleName() { String result = super.getIDLModuleName(); // Checked for boxedIDL 1.3.9 Class clazz = getCls(); if (IDLEntity.class.isAssignableFrom(clazz) && ValueBase.class.isAssignableFrom(clazz) == false) result = "::org::omg::boxedIDL" + result; return result; } protected void doAnalyze() throws RMIIIOPViolationException { super.doAnalyze(); if (cls == String.class) throw IIOPLogger.ROOT_LOGGER.cannotAnalyzeStringType(); if (cls == Class.class) throw IIOPLogger.ROOT_LOGGER.cannotAnalyzeClassType(); if (Remote.class.isAssignableFrom(cls)) throw IIOPLogger.ROOT_LOGGER.valueTypeCantImplementRemote(cls.getName(), "1.2.4"); if (cls.getName().indexOf('$') != -1) throw IIOPLogger.ROOT_LOGGER.valueTypeCantBeProxy(cls.getName()); externalizable = Externalizable.class.isAssignableFrom(cls); if (!externalizable) { // Look for serialPersistentFields field. Field spf = null; try { spf = cls.getField("serialPersistentFields"); } catch (NoSuchFieldException ex) { // ignore } if (spf != null) { // Right modifiers? int mods = spf.getModifiers(); if (!Modifier.isFinal(mods) || !Modifier.isStatic(mods) || !Modifier.isPrivate(mods)) spf = null; // wrong modifiers } if (spf != null) { // Right type? Class type = spf.getType(); if (type.isArray()) { type = type.getComponentType(); if (type != ObjectStreamField.class) spf = null; // Array of wrong type } else spf = null; // Wrong type: Not an array } if (spf != null) { // We have the serialPersistentFields field // Get this constant try { serialPersistentFields = (ObjectStreamField[]) spf.get(null); } catch (IllegalAccessException ex) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(ex); } // Mark this in the fields array for (int i = 0; i < fields.length; ++i) { if (fields[i] == spf) { f_flags[i] |= F_SPFFIELD; break; } } } // Look for a writeObject Method Method wo = null; try { wo = cls.getMethod("writeObject", new Class[]{java.io.OutputStream[].class}); } catch (NoSuchMethodException ex) { // ignore } if (wo != null // Right return type? && wo.getReturnType() != Void.TYPE) { wo = null; // Wrong return type } if (wo != null) { // Right modifiers? int mods = wo.getModifiers(); if (!Modifier.isPrivate(mods)) wo = null; // wrong modifiers } if (wo != null) { // Right arguments? Class[] paramTypes = wo.getParameterTypes(); if (paramTypes.length != 1) wo = null; // Bad number of parameters else if (paramTypes[0] != java.io.OutputStream.class) wo = null; // Bad parameter type } if (wo != null) { // We have the writeObject() method. hasWriteObjectMethod = true; // Mark this in the methods array for (int i = 0; i < methods.length; ++i) { if (methods[i] == wo) { m_flags[i] |= M_WRITEOBJECT; break; } } } } // Map all fields not flagged constant or serialPersistentField. SortedSet m = new TreeSet(new ValueMemberComparator()); for (int i = 0; i < fields.length; ++i) { if (f_flags[i] != 0) continue; // flagged int mods = fields[i].getModifiers(); if (Modifier.isStatic(mods) || Modifier.isTransient(mods)) continue; // don't map this ValueMemberAnalysis vma; vma = new ValueMemberAnalysis(fields[i].getName(), fields[i].getType(), Modifier.isPublic(mods)); m.add(vma); } members = new ValueMemberAnalysis[m.size()]; members = (ValueMemberAnalysis[]) m.toArray(members); // Get superclass analysis Class superClass = cls.getSuperclass(); if (superClass == Object.class) superClass = null; if (superClass == null) superAnalysis = null; else { superAnalysis = getValueAnalysis(superClass); } if (!Serializable.class.isAssignableFrom(cls)) abstractValue = true; fixupCaseNames(); } // Public -------------------------------------------------------- /** * Returns the superclass analysis, or null if this inherits from * java.lang.Object. */ public ValueAnalysis getSuperAnalysis() { return superAnalysis; } /** * Returns true if this value is abstract. */ public boolean isAbstractValue() { return abstractValue; } /** * Returns true if this value is custom. */ public boolean isCustom() { return externalizable || hasWriteObjectMethod; } /** * Returns true if this value implements java.io.Externalizable. */ public boolean isExternalizable() { return externalizable; } /** * Return the value members of this value class. */ public ValueMemberAnalysis[] getMembers() { return members.clone(); } /** * Analyse attributes. * This will fill in the <code>attributes</code> array. * Here we override the implementation in ContainerAnalysis and create an * empty array, because for valuetypes we don't want to analyse IDL * attributes or operations (as in "rmic -idl -noValueMethods"). */ protected void analyzeAttributes() throws RMIIIOPViolationException { attributes = new AttributeAnalysis[0]; } /** * Return a list of all the entries contained here. * */ protected ArrayList getContainedEntries() { final ArrayList ret = new ArrayList(constants.length + attributes.length + members.length); for (int i = 0; i < constants.length; ++i) ret.add(constants[i]); for (int i = 0; i < attributes.length; ++i) ret.add(attributes[i]); for (int i = 0; i < members.length; ++i) ret.add(members[i]); return ret; } /** * A <code>Comparator</code> for the field ordering specified at the * end of section 1.3.5.6. */ private static class ValueMemberComparator implements Comparator { public int compare(final Object o1, final Object o2) { if (o1 == o2) return 0; final ValueMemberAnalysis m1 = (ValueMemberAnalysis) o1; final ValueMemberAnalysis m2 = (ValueMemberAnalysis) o2; final boolean p1 = m1.getCls().isPrimitive(); final boolean p2 = m2.getCls().isPrimitive(); if (p1 && !p2) return -1; if (!p1 && p2) return 1; return m1.getJavaName().compareTo(m2.getJavaName()); } } }
10,931
31.927711
104
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi/ConstantAnalysis.java
/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk.rmi; import org.omg.CORBA.Any; import org.wildfly.iiop.openjdk.logging.IIOPLogger; /** * Constant analysis. * <p/> * Routines here are conforming to the "Java(TM) Language to IDL Mapping * Specification", version 1.1 (01-06-07). * * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a> * @version $Revision: 81018 $ */ public class ConstantAnalysis extends AbstractAnalysis { // Constants ----------------------------------------------------- // Attributes ---------------------------------------------------- // Static -------------------------------------------------------- // Constructors -------------------------------------------------- ConstantAnalysis(String javaName, Class type, Object value) { super(javaName); if (type == Void.TYPE || !type.isPrimitive() && type != String.class) throw IIOPLogger.ROOT_LOGGER.badConstantType(type.getName()); this.type = type; this.value = value; } // Public -------------------------------------------------------- /** * Return my Java type. */ public Class getType() { return type; } /** * Return my value. */ public Object getValue() { return value; } /** * Insert the constant value into the argument Any. */ public void insertValue(Any any) { if (type == String.class) any.insert_wstring((String) value); // 1.3.5.10 Map to wstring else Util.insertAnyPrimitive(any, value); } // Protected ----------------------------------------------------- // Private ------------------------------------------------------- /** * Java type of constant. */ private Class type; /** * The value of the constant. */ private Object value; }
2,930
28.31
74
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi/RMIIIOPNotImplementedException.java
/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk.rmi; /** * Exception denoting a part of RMI/IIOP not yet implemented here. * * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a> */ public class RMIIIOPNotImplementedException extends RMIIIOPViolationException { public RMIIIOPNotImplementedException(String msg) { super(msg); } }
1,377
36.243243
81
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi/RMIIIOPViolationException.java
/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk.rmi; /** * Exception denoting an RMI/IIOP subset violation. * * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a> */ public class RMIIIOPViolationException extends Exception { /** * The section violated. */ private final String section; public RMIIIOPViolationException(String msg) { this(msg, null); } public RMIIIOPViolationException(String msg, String section) { super(msg); this.section = section; } /** * Return the section violated. */ public String getSection() { return section; } }
1,662
29.236364
70
java
null
wildfly-main/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi/ValueMemberAnalysis.java
/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.iiop.openjdk.rmi; /** * Value member analysis. * <p/> * Routines here are conforming to the "Java(TM) Language to IDL Mapping * Specification", version 1.1 (01-06-07). * * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a> * @version $Revision: 81018 $ */ public class ValueMemberAnalysis extends AbstractAnalysis { /** * Java type. */ private final Class cls; /** * Flags that this member is public. */ private final boolean publicMember; ValueMemberAnalysis(final String javaName, final Class cls, final boolean publicMember) { super(javaName); this.cls = cls; this.publicMember = publicMember; } /** * Return my Java type. */ public Class getCls() { return cls; } /** * Returns true iff this member has private visibility. */ public boolean isPublic() { return publicMember; } }
1,985
27.782609
93
java