Skip to content

Commit

Permalink
security transformers - non deprecated api
Browse files Browse the repository at this point in the history
  • Loading branch information
ctomc committed May 22, 2017
1 parent b5a90d5 commit 5e1b5c3
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 29 deletions.
Expand Up @@ -33,10 +33,6 @@
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.ManagementResourceRegistration;
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;
import org.jboss.as.security.elytron.ElytronIntegrationResourceDefinitions; import org.jboss.as.security.elytron.ElytronIntegrationResourceDefinitions;
import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceName;


Expand Down Expand Up @@ -116,9 +112,6 @@ public void initialize(ExtensionContext context) {
// register the subsystem XML persister. // register the subsystem XML persister.
subsystem.registerXMLElementWriter(SecuritySubsystemPersister.INSTANCE); subsystem.registerXMLElementWriter(SecuritySubsystemPersister.INSTANCE);


if (context.isRegisterTransformers()) {
registerTransformers(subsystem);
}
} }


@Override @Override
Expand All @@ -128,26 +121,4 @@ public void initializeParsers(ExtensionParsingContext context) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.SECURITY_1_2.getUriString(), SecuritySubsystemParser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.SECURITY_1_2.getUriString(), SecuritySubsystemParser::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.SECURITY_3_0.getUriString(), SecuritySubsystemParser_3_0::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.SECURITY_3_0.getUriString(), SecuritySubsystemParser_3_0::new);
} }

private void registerTransformers(SubsystemRegistration subsystemRegistration) {
// only register transformers for model version 1.3.0 (EAP 6.2+).
registerTransformers_1_3_0(subsystemRegistration);
}

private void registerTransformers_1_3_0(SubsystemRegistration subsystemRegistration) {
ResourceTransformationDescriptionBuilder builder = ResourceTransformationDescriptionBuilder.Factory.createSubsystemInstance();
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_REALM));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_KEY_STORE));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_TRUST_STORE));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_KEY_MANAGER));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_TRUST_MANAGER));
builder.addChildResource(PathElement.pathElement(Constants.SECURITY_MANAGEMENT))
.getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.DEFINED, SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC)
.setDiscard(DiscardAttributeChecker.UNDEFINED, SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC);

SecurityDomainResourceDefinition.registerTransformers_1_3_0(builder);

TransformationDescription.Tools.register(builder.build(), subsystemRegistration, ModelVersion.create(1, 3, 0));
}
} }
@@ -0,0 +1,65 @@
/*
* 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.jboss.as.security;

import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
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;

/**
* @author Tomaz Cerar (c) 2017 Red Hat Inc.
*/
public class SecurityTransformers implements ExtensionTransformerRegistration {
@Override
public String getSubsystemName() {
return SecurityExtension.SUBSYSTEM_NAME;
}

@Override
public void registerTransformers(SubsystemTransformerRegistration subsystemRegistration) {
// only register transformers for model version 1.3.0 (EAP 6.2+).
registerTransformers_1_3_0(subsystemRegistration);
}

private void registerTransformers_1_3_0(SubsystemTransformerRegistration subsystemRegistration) {
ResourceTransformationDescriptionBuilder builder = ResourceTransformationDescriptionBuilder.Factory.createSubsystemInstance();
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_REALM));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_KEY_STORE));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_TRUST_STORE));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_KEY_MANAGER));
builder.rejectChildResource(PathElement.pathElement(Constants.ELYTRON_TRUST_MANAGER));
builder.addChildResource(PathElement.pathElement(Constants.SECURITY_MANAGEMENT))
.getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.DEFINED, SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC)
.setDiscard(DiscardAttributeChecker.UNDEFINED, SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC);

SecurityDomainResourceDefinition.registerTransformers_1_3_0(builder);

TransformationDescription.Tools.register(builder.build(), subsystemRegistration, ModelVersion.create(1, 3, 0));
}
}
@@ -0,0 +1,23 @@
#
# 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.
#

org.jboss.as.security.SecurityTransformers

0 comments on commit 5e1b5c3

Please sign in to comment.