diff --git a/distribution/adapters/as7-adapter-zip/assembly.xml b/distribution/adapters/as7-adapter-zip/assembly.xml index 9eacaec106..7c141ff108 100755 --- a/distribution/adapters/as7-adapter-zip/assembly.xml +++ b/distribution/adapters/as7-adapter-zip/assembly.xml @@ -17,7 +17,6 @@ org/keycloak/keycloak-core/** org/keycloak/keycloak-adapter-core/** org/keycloak/keycloak-jboss-adapter-core/** - org/keycloak/keycloak-undertow-adapter/** org/keycloak/keycloak-as7-adapter/** org/keycloak/keycloak-as7-subsystem/** diff --git a/distribution/adapters/eap6-adapter-zip/assembly.xml b/distribution/adapters/eap6-adapter-zip/assembly.xml index 172047687e..6247e93af4 100755 --- a/distribution/adapters/eap6-adapter-zip/assembly.xml +++ b/distribution/adapters/eap6-adapter-zip/assembly.xml @@ -11,15 +11,14 @@ ${project.build.directory}/unpacked - net/iharder/base64/** org/bouncycastle/** + net/iharder/base64/** org/apache/httpcomponents/** org/keycloak/keycloak-core/** org/keycloak/keycloak-adapter-core/** org/keycloak/keycloak-jboss-adapter-core/** - org/keycloak/keycloak-undertow-adapter/** org/keycloak/keycloak-as7-adapter/** - org/keycloak/keycloak-subsystem/** + org/keycloak/keycloak-as7-subsystem/** **/*.war diff --git a/integration/keycloak-as7-subsystem/pom.xml b/integration/as7-subsystem/pom.xml similarity index 91% rename from integration/keycloak-as7-subsystem/pom.xml rename to integration/as7-subsystem/pom.xml index f1ee2ed8f3..bc1c727fa9 100755 --- a/integration/keycloak-as7-subsystem/pom.xml +++ b/integration/as7-subsystem/pom.xml @@ -31,14 +31,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - ${maven.compiler.source} - ${maven.compiler.target} - - org.apache.maven.plugins maven-surefire-plugin diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialAddHandler.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialAddHandler.java similarity index 69% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialAddHandler.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialAddHandler.java index 51bde28214..47de3b7926 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialAddHandler.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialAddHandler.java @@ -15,8 +15,9 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; +import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; @@ -24,6 +25,8 @@ import org.jboss.as.controller.ServiceVerificationHandler; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; +import java.util.Collection; +import java.util.LinkedList; import java.util.List; /** @@ -31,15 +34,28 @@ import java.util.List; * * @author Stan Silvert ssilvert@redhat.com (C) 2014 Red Hat Inc. */ -public class CredentialAddHandler extends AbstractAddStepHandlerWithAttributes { +public class CredentialAddHandler extends AbstractAddStepHandler { - public CredentialAddHandler(AttributeDefinition... attributes) { - super(attributes); + protected Collection attributes = new LinkedList<>(); + + public CredentialAddHandler(AttributeDefinition... attrs) { + for (AttributeDefinition attr : attrs) { + attributes.add(attr); + } + } + + @Override + protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { + if (attributes != null) { + for (AttributeDefinition attr : attributes) { + attr.validateAndSet(operation, model); + } + } } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List> newControllers) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); ckService.addCredential(operation, context.resolveExpressions(model)); } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialDefinition.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialDefinition.java similarity index 83% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialDefinition.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialDefinition.java index 681d4d9caa..7b0257b6d7 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialDefinition.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialDefinition.java @@ -14,20 +14,19 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; +import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.operations.validation.StringLengthValidator; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.dmr.ModelType; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE; - /** * Defines attributes and operations for a credential. * @@ -39,7 +38,6 @@ public class CredentialDefinition extends SimpleResourceDefinition { protected static final AttributeDefinition VALUE = new SimpleAttributeDefinitionBuilder("value", ModelType.STRING, false) - .setXmlName("value") .setAllowExpression(true) .setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, false, true)) .build(); @@ -54,8 +52,7 @@ public class CredentialDefinition extends SimpleResourceDefinition { @Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); - resourceRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE); - //resourceRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); + resourceRegistration.registerOperationHandler(ModelDescriptionConstants.DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE); } @Override diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialReadWriteAttributeHandler.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialReadWriteAttributeHandler.java old mode 100755 new mode 100644 similarity index 96% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialReadWriteAttributeHandler.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialReadWriteAttributeHandler.java index 6289ff4539..d068b1d936 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialReadWriteAttributeHandler.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialReadWriteAttributeHandler.java @@ -15,7 +15,7 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.OperationContext; @@ -33,7 +33,7 @@ public class CredentialReadWriteAttributeHandler extends AbstractWriteAttributeH protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, AbstractWriteAttributeHandler.HandbackHolder hh) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); ckService.updateCredential(operation, attributeName, resolvedValue); hh.setHandback(ckService); diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialRemoveHandler.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialRemoveHandler.java old mode 100755 new mode 100644 similarity index 95% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialRemoveHandler.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialRemoveHandler.java index 1cad10bfb0..b4815dbcc4 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/CredentialRemoveHandler.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/CredentialRemoveHandler.java @@ -15,7 +15,7 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AbstractRemoveStepHandler; import org.jboss.as.controller.OperationContext; @@ -35,7 +35,7 @@ public final class CredentialRemoveHandler extends AbstractRemoveStepHandler { @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); ckService.removeCredential(operation); } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakAdapterConfigDeploymentProcessor.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakAdapterConfigDeploymentProcessor.java similarity index 82% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakAdapterConfigDeploymentProcessor.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakAdapterConfigDeploymentProcessor.java index d9e4e7d406..184de35860 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakAdapterConfigDeploymentProcessor.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakAdapterConfigDeploymentProcessor.java @@ -15,13 +15,12 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; 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.server.deployment.Phase; import org.jboss.as.web.deployment.WarMetaData; import org.jboss.logging.Logger; import org.jboss.metadata.javaee.spec.ParamValueMetaData; @@ -29,7 +28,7 @@ import org.jboss.metadata.web.jboss.JBossWebMetaData; import org.jboss.metadata.web.jboss.ValveMetaData; import org.jboss.metadata.web.spec.LoginConfigMetaData; import org.keycloak.adapters.jbossweb.KeycloakAuthenticatorValve; -import org.keycloak.subsystem.logging.KeycloakLogger; +import org.keycloak.subsystem.as7.logging.KeycloakLogger; import java.util.ArrayList; import java.util.List; @@ -47,38 +46,47 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP // two places to avoid dependency between Keycloak Subsystem and Keyclaok Undertow Integration. public static final String AUTH_DATA_PARAM_NAME = "org.keycloak.json.adapterConfig"; - public static final Phase PHASE = Phase.INSTALL; - // needs to run before INSTALL_WAR_DEPLOYMENT so that valves are added. - public static final int PRIORITY = Phase.INSTALL_WAR_DEPLOYMENT - 1; - - @Override - public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { - DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); + // not sure if we need this yet, keeping here just in case + protected void addSecurityDomain(DeploymentUnit deploymentUnit, KeycloakAdapterConfigService service) { String deploymentName = deploymentUnit.getName(); - - KeycloakAdapterConfigService service = KeycloakAdapterConfigService.find(phaseContext.getServiceRegistry()); - //log.info("********* CHECK KEYCLOAK DEPLOYMENT: " + deploymentName); - if (service.isKeycloakDeployment(deploymentName)) { - - addKeycloakAuthData(phaseContext, deploymentName, service); + if (!service.isSecureDeployment(deploymentName)) { return; } - - // else check to see if KEYCLOAK is specified as login config WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) return; JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); if (webMetaData == null) return; LoginConfigMetaData loginConfig = webMetaData.getLoginConfig(); - if (loginConfig != null && "KEYCLOAK".equalsIgnoreCase(loginConfig.getAuthMethod())) { - addValve(webMetaData); + if (loginConfig == null || !loginConfig.getAuthMethod().equalsIgnoreCase("KEYCLOAK")) { + return; } + + webMetaData.setSecurityDomain("keycloak"); } - private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, String deploymentName, KeycloakAdapterConfigService service) { + @Override + public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { + DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); + + String deploymentName = deploymentUnit.getName(); + KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance(); + if (service.isSecureDeployment(deploymentName)) { + addKeycloakAuthData(phaseContext, deploymentName, service); + } + + // FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK + + // todo notsure if we need this + // addSecurityDomain(deploymentUnit, service); + } + + private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, String deploymentName, KeycloakAdapterConfigService service) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); + if (warMetaData == null) { + throw new DeploymentUnitProcessingException("WarMetaData not found for " + deploymentName + ". Make sure you have specified a WAR as your secure-deployment in the Keycloak subsystem."); + } addJSONData(service.getJSON(deploymentName), warMetaData); JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); @@ -86,6 +94,7 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP webMetaData = new JBossWebMetaData(); warMetaData.setMergedJBossWebMetaData(webMetaData); } + addValve(webMetaData); LoginConfigMetaData loginConfig = webMetaData.getLoginConfig(); diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakAdapterConfigService.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakAdapterConfigService.java similarity index 69% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakAdapterConfigService.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakAdapterConfigService.java index eb820fcff8..af9e74fa88 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakAdapterConfigService.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakAdapterConfigService.java @@ -15,19 +15,11 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; -import org.jboss.as.controller.OperationContext; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.jboss.logging.Logger; -import org.jboss.msc.service.Service; -import org.jboss.msc.service.ServiceController; -import org.jboss.msc.service.ServiceName; -import org.jboss.msc.service.ServiceRegistry; -import org.jboss.msc.service.StartContext; -import org.jboss.msc.service.StartException; -import org.jboss.msc.service.StopContext; import java.util.HashMap; import java.util.Map; @@ -40,36 +32,23 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public final class KeycloakAdapterConfigService implements Service { +public final class KeycloakAdapterConfigService { protected Logger log = Logger.getLogger(KeycloakAdapterConfigService.class); private static final String CREDENTIALS_JSON_NAME = "credentials"; - // Right now this is used as a service, but I'm not sure it really needs to be implemented that way. - // It's also a singleton serving the entire subsystem, but the INSTANCE variable is currently only - // used during initialization of the subsystem. - public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("KeycloakAdapterConfigService"); - public static final KeycloakAdapterConfigService INSTANCE = new KeycloakAdapterConfigService(); + private static final KeycloakAdapterConfigService INSTANCE = new KeycloakAdapterConfigService(); + + public static KeycloakAdapterConfigService getInstance() { + return INSTANCE; + } + + private final Map realms = new HashMap(); + + // keycloak-secured deployments + private final Map secureDeployments = new HashMap(); - private Map realms = new HashMap(); - private Map deployments = new HashMap(); private KeycloakAdapterConfigService() { - - } - - @Override - public void start(StartContext sc) throws StartException { - - } - - @Override - public void stop(StopContext sc) { - - } - - @Override - public KeycloakAdapterConfigService getValue() throws IllegalStateException, IllegalArgumentException { - return this; } public void addRealm(ModelNode operation, ModelNode model) { @@ -87,16 +66,16 @@ public final class KeycloakAdapterConfigService implements Service container = registry.getService(KeycloakAdapterConfigService.SERVICE_NAME); - if (container != null) { - KeycloakAdapterConfigService service = (KeycloakAdapterConfigService)container.getValue(); - return service; - } - return null; - } - - static KeycloakAdapterConfigService find(OperationContext context) { - return find(context.getServiceRegistry(true)); + return this.secureDeployments.containsKey(deploymentName); } } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakDependencyProcessor.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakDependencyProcessor.java similarity index 77% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakDependencyProcessor.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakDependencyProcessor.java index c9a32d6dba..60a51a668f 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakDependencyProcessor.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakDependencyProcessor.java @@ -15,7 +15,7 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; @@ -32,32 +32,33 @@ import org.jboss.modules.ModuleLoader; * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public class KeycloakDependencyProcessor implements DeploymentUnitProcessor { +public abstract class KeycloakDependencyProcessor implements DeploymentUnitProcessor { - private static final ModuleIdentifier KEYCLOAK_AS7_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-as7-adapter"); - private static final ModuleIdentifier KEYCLOAK_CORE_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-adapter-core"); private static final ModuleIdentifier KEYCLOAK_JBOSS_CORE_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-jboss-adapter-core"); + private static final ModuleIdentifier KEYCLOAK_CORE_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-adapter-core"); private static final ModuleIdentifier KEYCLOAK_CORE = ModuleIdentifier.create("org.keycloak.keycloak-core"); - //private static final ModuleIdentifier APACHE_HTTPCOMPONENTS = ModuleIdentifier.create("org.apache.httpcomponents"); @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); - addModules(deploymentUnit); - } + // Next phase, need to detect if this is a Keycloak deployment. If not, don't add the modules. - private void addModules(DeploymentUnit deploymentUnit) { final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); + addCommonModules(moduleSpecification, moduleLoader); + addPlatformSpecificModules(moduleSpecification, moduleLoader); + } - moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_AS7_ADAPTER, false, false, true, false)); + private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { + // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified) moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false)); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false)); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false)); - //moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, APACHE_HTTPCOMPONENTS, false, false, true, false)); } + abstract protected void addPlatformSpecificModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader); + @Override public void undeploy(DeploymentUnit du) { diff --git a/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakDependencyProcessorAS7.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakDependencyProcessorAS7.java new file mode 100644 index 0000000000..c8935d44d5 --- /dev/null +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakDependencyProcessorAS7.java @@ -0,0 +1,19 @@ +package org.keycloak.subsystem.as7; + +import org.jboss.as.server.deployment.module.ModuleDependency; +import org.jboss.as.server.deployment.module.ModuleSpecification; +import org.jboss.modules.ModuleIdentifier; +import org.jboss.modules.ModuleLoader; + +/** + * @author Marko Strukelj + */ +public class KeycloakDependencyProcessorAS7 extends KeycloakDependencyProcessor { + + private static final ModuleIdentifier KEYCLOAK_AS7_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-as7-adapter"); + + @Override + protected void addPlatformSpecificModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { + // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified) + moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_AS7_ADAPTER, false, false, true, false)); + }} diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakExtension.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakExtension.java similarity index 82% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakExtension.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakExtension.java index a47c165742..2db933684c 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakExtension.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakExtension.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.Extension; import org.jboss.as.controller.ExtensionContext; @@ -24,7 +24,7 @@ import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; -import org.keycloak.subsystem.logging.KeycloakLogger; +import org.keycloak.subsystem.as7.logging.KeycloakLogger; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; @@ -37,20 +37,20 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUB public class KeycloakExtension implements Extension { public static final String SUBSYSTEM_NAME = "keycloak"; - public static final String NAMESPACE = "urn:jboss:domain:keycloak:1.0"; + public static final String NAMESPACE = "urn:jboss:domain:keycloak:1.1"; private static final KeycloakSubsystemParser PARSER = new KeycloakSubsystemParser(); static final PathElement PATH_SUBSYSTEM = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); private static final String RESOURCE_NAME = KeycloakExtension.class.getPackage().getName() + ".LocalDescriptions"; - private static final int MANAGEMENT_API_MAJOR_VERSION = 1; - private static final int MANAGEMENT_API_MINOR_VERSION = 0; - private static final int MANAGEMENT_API_MICRO_VERSION = 0; - protected static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); + private static final int MGMT_API_VERSION_MAJOR = 1; + private static final int MGMT_API_VERSION_MINOR = 1; + + static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); private static final ResourceDefinition KEYCLOAK_SUBSYSTEM_RESOURCE = new KeycloakSubsystemDefinition(); static final RealmDefinition REALM_DEFINITION = new RealmDefinition(); static final SecureDeploymentDefinition SECURE_DEPLOYMENT_DEFINITION = new SecureDeploymentDefinition(); static final CredentialDefinition CREDENTIAL_DEFINITION = new CredentialDefinition(); - static StandardResourceDescriptionResolver getResourceDescriptionResolver(final String... keyPrefix) { + public static StandardResourceDescriptionResolver getResourceDescriptionResolver(final String... keyPrefix) { StringBuilder prefix = new StringBuilder(SUBSYSTEM_NAME); for (String kp : keyPrefix) { prefix.append('.').append(kp); @@ -72,11 +72,10 @@ public class KeycloakExtension implements Extension { @Override public void initialize(final ExtensionContext context) { KeycloakLogger.ROOT_LOGGER.debug("Activating Keycloak Extension"); - final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, - MANAGEMENT_API_MINOR_VERSION); + final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MGMT_API_VERSION_MAJOR, MGMT_API_VERSION_MINOR); ManagementResourceRegistration registration = subsystem.registerSubsystemModel(KEYCLOAK_SUBSYSTEM_RESOURCE); - ManagementResourceRegistration realmRegistration = registration.registerSubModel(REALM_DEFINITION); + registration.registerSubModel(REALM_DEFINITION); ManagementResourceRegistration secureDeploymentRegistration = registration.registerSubModel(SECURE_DEPLOYMENT_DEFINITION); secureDeploymentRegistration.registerSubModel(CREDENTIAL_DEFINITION); diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemAdd.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemAdd.java similarity index 63% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemAdd.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemAdd.java index 232532a23f..f1a4019cdf 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemAdd.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemAdd.java @@ -14,7 +14,8 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; + import org.jboss.as.controller.AbstractBoottimeAddStepHandler; import org.jboss.as.controller.OperationContext; @@ -24,6 +25,7 @@ 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.jboss.msc.service.ServiceController; import java.util.List; @@ -37,40 +39,22 @@ class KeycloakSubsystemAdd extends AbstractBoottimeAddStepHandler { static final KeycloakSubsystemAdd INSTANCE = new KeycloakSubsystemAdd(); - @Override - protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { - model.setEmptyObject(); - } - @Override protected void performBoottime(final OperationContext context, ModelNode operation, final ModelNode model, ServiceVerificationHandler verificationHandler, List> newControllers) { context.addStep(new AbstractDeploymentChainStep() { @Override protected void execute(DeploymentProcessorTarget processorTarget) { - processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, 0, new KeycloakDependencyProcessor()); - - - processorTarget.addDeploymentProcessor(KeycloakAdapterConfigDeploymentProcessor.PHASE, - KeycloakAdapterConfigDeploymentProcessor.PRIORITY, - new KeycloakAdapterConfigDeploymentProcessor()); + processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, 0, new KeycloakDependencyProcessorAS7()); + processorTarget.addDeploymentProcessor( + Phase.POST_MODULE, // PHASE + Phase.POST_MODULE_VALIDATOR_FACTORY - 1, // PRIORITY + new KeycloakAdapterConfigDeploymentProcessor()); } }, OperationContext.Stage.RUNTIME); } @Override - protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List> newControllers) throws OperationFailedException { - super.performRuntime(context, operation, model, verificationHandler, newControllers); - - ServiceController controller = context.getServiceTarget() - .addService(KeycloakAdapterConfigService.SERVICE_NAME, KeycloakAdapterConfigService.INSTANCE) - .addListener(verificationHandler) - .setInitialMode(ServiceController.Mode.ACTIVE) - .install(); - newControllers.add(controller); - } - - @Override - protected boolean requiresRuntimeVerification() { - return false; + protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { + model.setEmptyObject(); } } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemDefinition.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemDefinition.java old mode 100755 new mode 100644 similarity index 73% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemDefinition.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemDefinition.java index d3b3f69af7..cae933f939 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemDefinition.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemDefinition.java @@ -15,9 +15,8 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; -import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; @@ -25,8 +24,6 @@ import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE; - /** * Definition of subsystem=keycloak. * @@ -34,7 +31,7 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DES */ public class KeycloakSubsystemDefinition extends SimpleResourceDefinition { protected KeycloakSubsystemDefinition() { - super(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, KeycloakExtension.SUBSYSTEM_NAME), + super(KeycloakExtension.SUBSYSTEM_PATH, KeycloakExtension.getResourceDescriptionResolver("subsystem"), KeycloakSubsystemAdd.INSTANCE, ReloadRequiredRemoveStepHandler.INSTANCE @@ -44,8 +41,7 @@ public class KeycloakSubsystemDefinition extends SimpleResourceDefinition { @Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); - resourceRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE); - //resourceRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); + resourceRegistration.registerOperationHandler(ModelDescriptionConstants.DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE); } } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemParser.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemParser.java similarity index 98% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemParser.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemParser.java index 9856e69484..5c61e55e58 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/KeycloakSubsystemParser.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/KeycloakSubsystemParser.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathAddress; @@ -114,7 +114,7 @@ class KeycloakSubsystemParser implements XMLStreamConstants, XMLElementReader
  • { - - public RealmWriteAttributeHandler(List definitions) { - this(definitions.toArray(new AttributeDefinition[definitions.size()])); - } +class RealmWriteAttributeHandler extends AbstractWriteAttributeHandler { public RealmWriteAttributeHandler(AttributeDefinition... definitions) { super(definitions); @@ -43,7 +39,7 @@ public class RealmWriteAttributeHandler extends AbstractWriteAttributeHandler hh) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); ckService.updateRealm(operation, attributeName, resolvedValue); hh.setHandback(ckService); diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentAddHandler.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentAddHandler.java similarity index 76% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentAddHandler.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentAddHandler.java index 99267dbe18..da84fcb2e1 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentAddHandler.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentAddHandler.java @@ -15,7 +15,7 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; @@ -27,27 +27,20 @@ import org.jboss.msc.service.ServiceController; import java.util.List; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; - /** * Add a deployment to a realm. * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public final class SecureDeploymentAddHandler extends AbstractAddStepHandler { +final class SecureDeploymentAddHandler extends AbstractAddStepHandler { public static SecureDeploymentAddHandler INSTANCE = new SecureDeploymentAddHandler(); - private SecureDeploymentAddHandler() {} + private SecureDeploymentAddHandler() { + } @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { - // TODO: localize exception. get id number - if (!operation.get(OP).asString().equals(ADD)) { - throw new OperationFailedException("Unexpected operation for add secure deployment. operation=" + operation.toString()); - } - for (AttributeDefinition attr : SecureDeploymentDefinition.ALL_ATTRIBUTES) { attr.validateAndSet(operation, model); } @@ -55,7 +48,7 @@ public final class SecureDeploymentAddHandler extends AbstractAddStepHandler { @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List> newControllers) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); ckService.addSecureDeployment(operation, context.resolveExpressions(model)); } } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentDefinition.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentDefinition.java similarity index 91% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentDefinition.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentDefinition.java index 60c65fb509..1aeeddfcb3 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentDefinition.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentDefinition.java @@ -14,13 +14,14 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; +import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.operations.validation.StringLengthValidator; import org.jboss.as.controller.registry.ManagementResourceRegistration; @@ -33,14 +34,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE; - /** * Defines attributes and operations for a secure-deployment. * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public class SecureDeploymentDefinition extends SimpleResourceDefinition { +class SecureDeploymentDefinition extends SimpleResourceDefinition { public static final String TAG_NAME = "secure-deployment"; @@ -116,8 +115,7 @@ public class SecureDeploymentDefinition extends SimpleResourceDefinition { @Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); - resourceRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE); - //resourceRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); + resourceRegistration.registerOperationHandler(ModelDescriptionConstants.DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE); } @Override diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentRemoveHandler.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentRemoveHandler.java old mode 100755 new mode 100644 similarity index 90% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentRemoveHandler.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentRemoveHandler.java index da0ca7e19d..e638f42eb3 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentRemoveHandler.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentRemoveHandler.java @@ -15,7 +15,7 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AbstractRemoveStepHandler; import org.jboss.as.controller.OperationContext; @@ -27,7 +27,7 @@ import org.jboss.dmr.ModelNode; * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public final class SecureDeploymentRemoveHandler extends AbstractRemoveStepHandler { +final class SecureDeploymentRemoveHandler extends AbstractRemoveStepHandler { public static SecureDeploymentRemoveHandler INSTANCE = new SecureDeploymentRemoveHandler(); @@ -35,7 +35,7 @@ public final class SecureDeploymentRemoveHandler extends AbstractRemoveStepHandl @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); ckService.removeSecureDeployment(operation); } } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentWriteAttributeHandler.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentWriteAttributeHandler.java similarity index 92% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentWriteAttributeHandler.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentWriteAttributeHandler.java index 2caca6ae64..95ae08484d 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SecureDeploymentWriteAttributeHandler.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SecureDeploymentWriteAttributeHandler.java @@ -15,7 +15,7 @@ * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; @@ -31,7 +31,7 @@ import java.util.List; * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public class SecureDeploymentWriteAttributeHandler extends AbstractWriteAttributeHandler { +class SecureDeploymentWriteAttributeHandler extends AbstractWriteAttributeHandler { public SecureDeploymentWriteAttributeHandler(List definitions) { this(definitions.toArray(new AttributeDefinition[definitions.size()])); @@ -44,7 +44,7 @@ public class SecureDeploymentWriteAttributeHandler extends AbstractWriteAttribut @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder hh) throws OperationFailedException { - KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.find(context); + KeycloakAdapterConfigService ckService = KeycloakAdapterConfigService.getInstance(); hh.setHandback(ckService); ckService.updateSecureDeployment(operation, attributeName, resolvedValue); return false; diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SharedAttributeDefinitons.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SharedAttributeDefinitons.java similarity index 97% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SharedAttributeDefinitons.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SharedAttributeDefinitons.java index f19d4d0ee9..c4fdf4e7a3 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/SharedAttributeDefinitons.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/SharedAttributeDefinitons.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; @@ -31,7 +31,7 @@ import java.util.List; * * @author Stan Silvert ssilvert@redhat.com (C) 2013 Red Hat Inc. */ -public class SharedAttributeDefinitons { +class SharedAttributeDefinitons { protected static final SimpleAttributeDefinition REALM_PUBLIC_KEY = new SimpleAttributeDefinitionBuilder("realm-public-key", ModelType.STRING, true) @@ -120,16 +120,15 @@ public class SharedAttributeDefinitons { .build(); protected static final SimpleAttributeDefinition CORS_ALLOWED_METHODS = new SimpleAttributeDefinitionBuilder("cors-allowed-methods", ModelType.STRING, true) - .setXmlName("cors-allowed-methods") .setAllowExpression(true) .setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, true, true)) .build(); protected static final SimpleAttributeDefinition EXPOSE_TOKEN = new SimpleAttributeDefinitionBuilder("expose-token", ModelType.BOOLEAN, true) - .setXmlName("expose-token") - .setAllowExpression(true) - .setDefaultValue(new ModelNode(false)) - .build(); + .setXmlName("expose-token") + .setAllowExpression(true) + .setDefaultValue(new ModelNode(false)) + .build(); protected static final SimpleAttributeDefinition AUTH_SERVER_URL_FOR_BACKEND_REQUESTS = new SimpleAttributeDefinitionBuilder("auth-server-url-for-backend-requests", ModelType.STRING, true) .setXmlName("auth-server-url-for-backend-requests") @@ -168,6 +167,7 @@ public class SharedAttributeDefinitons { .build(); + protected static final List ATTRIBUTES = new ArrayList(); static { ATTRIBUTES.add(REALM_PUBLIC_KEY); @@ -209,7 +209,7 @@ public class SharedAttributeDefinitons { if (isSet(attributes, SSL_REQUIRED) && attributes.get(SSL_REQUIRED.getName()).asString().equals("none")) { return true; } - + //TODO, look into alternatives & requires properties on AttributeDefinition return isSet(attributes, TRUSTSTORE) && isSet(attributes, TRUSTSTORE_PASSWORD); } diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/Util.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/Util.java old mode 100755 new mode 100644 similarity index 94% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/Util.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/Util.java index 9d376e274d..f55410c618 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/Util.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/Util.java @@ -1,42 +1,42 @@ -package org.keycloak.subsystem.extension; - -import org.jboss.as.controller.PathAddress; -import org.jboss.as.controller.descriptions.ModelDescriptionConstants; -import org.jboss.dmr.ModelNode; - -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class Util { - public static ModelNode createAddOperation(final PathAddress address) { - return createOperation(ModelDescriptionConstants.ADD, address); - } - - public static ModelNode createAddOperation() { - return createEmptyOperation(ModelDescriptionConstants.ADD, null); - } - - public static ModelNode createRemoveOperation(final PathAddress address) { - return createOperation(ModelDescriptionConstants.REMOVE, address); - } - - public static ModelNode createOperation(final String operationName, final PathAddress address) { - return createEmptyOperation(operationName, address); - } - - public static ModelNode createEmptyOperation(String operationName, final PathAddress address) { - ModelNode op = new ModelNode(); - op.get(OP).set(operationName); - if (address != null) { - op.get(OP_ADDR).set(address.toModelNode()); - } else { - // Just establish the standard structure; caller can fill in address later - op.get(OP_ADDR); - } - return op; - } -} +package org.keycloak.subsystem.as7; + +import org.jboss.as.controller.PathAddress; +import org.jboss.as.controller.descriptions.ModelDescriptionConstants; +import org.jboss.dmr.ModelNode; + +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class Util { + public static ModelNode createAddOperation(final PathAddress address) { + return createOperation(ModelDescriptionConstants.ADD, address); + } + + public static ModelNode createAddOperation() { + return createEmptyOperation(ModelDescriptionConstants.ADD, null); + } + + public static ModelNode createRemoveOperation(final PathAddress address) { + return createOperation(ModelDescriptionConstants.REMOVE, address); + } + + public static ModelNode createOperation(final String operationName, final PathAddress address) { + return createEmptyOperation(operationName, address); + } + + public static ModelNode createEmptyOperation(String operationName, final PathAddress address) { + ModelNode op = new ModelNode(); + op.get(OP).set(operationName); + if (address != null) { + op.get(OP_ADDR).set(address.toModelNode()); + } else { + // Just establish the standard structure; caller can fill in address later + op.get(OP_ADDR); + } + return op; + } +} diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/logging/KeycloakLogger.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/logging/KeycloakLogger.java similarity index 97% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/logging/KeycloakLogger.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/logging/KeycloakLogger.java index 65ad2870c9..df8ec0ea0b 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/logging/KeycloakLogger.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/logging/KeycloakLogger.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.logging; +package org.keycloak.subsystem.as7.logging; import org.jboss.logging.BasicLogger; import org.jboss.logging.LogMessage; diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/logging/KeycloakMessages.java b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/logging/KeycloakMessages.java similarity index 96% rename from integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/logging/KeycloakMessages.java rename to integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/logging/KeycloakMessages.java index 06a6678b26..3e7a1600ad 100755 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/logging/KeycloakMessages.java +++ b/integration/as7-subsystem/src/main/java/org/keycloak/subsystem/as7/logging/KeycloakMessages.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.logging; +package org.keycloak.subsystem.as7.logging; import org.jboss.logging.MessageBundle; import org.jboss.logging.Messages; diff --git a/integration/as7-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension b/integration/as7-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension new file mode 100755 index 0000000000..1615116b4f --- /dev/null +++ b/integration/as7-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension @@ -0,0 +1 @@ +org.keycloak.subsystem.as7.KeycloakExtension diff --git a/integration/keycloak-as7-subsystem/src/main/resources/org/keycloak/subsystem/extension/LocalDescriptions.properties b/integration/as7-subsystem/src/main/resources/org/keycloak/subsystem/as7/LocalDescriptions.properties similarity index 100% rename from integration/keycloak-as7-subsystem/src/main/resources/org/keycloak/subsystem/extension/LocalDescriptions.properties rename to integration/as7-subsystem/src/main/resources/org/keycloak/subsystem/as7/LocalDescriptions.properties diff --git a/integration/as7-subsystem/src/main/resources/schema/keycloak_1_1.xsd b/integration/as7-subsystem/src/main/resources/schema/keycloak_1_1.xsd new file mode 100755 index 0000000000..269b3232dd --- /dev/null +++ b/integration/as7-subsystem/src/main/resources/schema/keycloak_1_1.xsd @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The name of the realm. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The name of the realm. + + + + + + + + + + + + diff --git a/integration/keycloak-as7-subsystem/src/test/java/org/keycloak/subsystem/extension/RealmDefinitionTestCase.java b/integration/as7-subsystem/src/test/java/org/keycloak/subsystem/as7/RealmDefinitionTestCase.java similarity index 98% rename from integration/keycloak-as7-subsystem/src/test/java/org/keycloak/subsystem/extension/RealmDefinitionTestCase.java rename to integration/as7-subsystem/src/test/java/org/keycloak/subsystem/as7/RealmDefinitionTestCase.java index 8bae47167a..b44f8339ee 100755 --- a/integration/keycloak-as7-subsystem/src/test/java/org/keycloak/subsystem/extension/RealmDefinitionTestCase.java +++ b/integration/as7-subsystem/src/test/java/org/keycloak/subsystem/as7/RealmDefinitionTestCase.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.keycloak.subsystem.extension; +package org.keycloak.subsystem.as7; import org.jboss.dmr.ModelNode; diff --git a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/AbstractAddStepHandlerWithAttributes.java b/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/AbstractAddStepHandlerWithAttributes.java deleted file mode 100755 index db5d1e5fc2..0000000000 --- a/integration/keycloak-as7-subsystem/src/main/java/org/keycloak/subsystem/extension/AbstractAddStepHandlerWithAttributes.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.keycloak.subsystem.extension; - -import org.jboss.as.controller.AbstractAddStepHandler; -import org.jboss.as.controller.AttributeDefinition; -import org.jboss.as.controller.OperationFailedException; -import org.jboss.dmr.ModelNode; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class AbstractAddStepHandlerWithAttributes extends AbstractAddStepHandler { - protected Collection attributes; - - public AbstractAddStepHandlerWithAttributes(){ //default constructor to preserve backward compatibility - - } - - public AbstractAddStepHandlerWithAttributes(Collection attributes) { - this.attributes = attributes; - } - - /** - * Constructs add handler - * - * @param attributes for which model will be populated - */ - public AbstractAddStepHandlerWithAttributes(AttributeDefinition... attributes) { - if (attributes.length > 0) { - this.attributes = Arrays.asList(attributes); - } else { - this.attributes = Collections.emptySet(); - } - } - - /** - * Populate the given node in the persistent configuration model based on the values in the given operation. - * - * @param operation the operation - * @param model persistent configuration model node that corresponds to the address of {@code operation} - * - * @throws org.jboss.as.controller.OperationFailedException if {@code operation} is invalid or populating the model otherwise fails - */ - protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { - if (attributes != null) { - for (AttributeDefinition attr : attributes) { - attr.validateAndSet(operation, model); - } - } - } - - -} diff --git a/integration/keycloak-as7-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension b/integration/keycloak-as7-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension deleted file mode 100755 index 6a7d631da0..0000000000 --- a/integration/keycloak-as7-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension +++ /dev/null @@ -1 +0,0 @@ -org.keycloak.subsystem.extension.KeycloakExtension diff --git a/integration/keycloak-as7-subsystem/src/main/resources/schema/keycloak_1_0.xsd b/integration/keycloak-as7-subsystem/src/main/resources/schema/keycloak_1_0.xsd deleted file mode 100755 index 10257d4a20..0000000000 --- a/integration/keycloak-as7-subsystem/src/main/resources/schema/keycloak_1_0.xsd +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - The name of the realm. - - - - - - - - - - - - The name of the deployment. - - - - - - - - - - - - - - - - - - The name of the credential. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/integration/pom.xml b/integration/pom.xml index 5c1f1328c8..c46e116914 100755 --- a/integration/pom.xml +++ b/integration/pom.xml @@ -23,7 +23,7 @@ jetty undertow wildfly - keycloak-as7-subsystem + as7-subsystem js installed admin-client diff --git a/pom.xml b/pom.xml index 5c529c7c8c..50c63bf7be 100755 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,12 @@ 9.0.0.CR1 1.0.0.CR1 1.0.0.Alpha8 - 7.1.1.Final + + + 7.5.0.Final-redhat-15 + + + 1.0.2.Final 2.2 1.14.1-beta @@ -1248,44 +1253,6 @@ liquibase-maven-plugin ${liquibase.version} - org.wildfly.build wildfly-feature-pack-build-maven-plugin @@ -1301,6 +1268,37 @@ + + + jboss-earlyaccess-repository + + true + + + + jboss-earlyaccess-repository + http://maven.repository.redhat.com/earlyaccess/all/ + + true + + + false + + + + + + jboss-earlyaccess-plugin-repository + http://maven.repository.redhat.com/earlyaccess/all/ + + true + + + false + + + + distribution