Skip to content

Commit

Permalink
Security Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Aug 24, 2011
1 parent 839d51e commit 04fe489
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 81 deletions.

This file was deleted.

Expand Up @@ -52,6 +52,7 @@ public EjbAnnotationProcessor() {

//security annotations
factories.add(new RunAsAnnotationInformationFactory());
factories.add(new SecurityDomainAnnotationInformationFactory());

this.factories = Collections.unmodifiableList(factories);
}
Expand Down
@@ -0,0 +1,43 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb3.deployment.processors.annotation;

import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory;
import org.jboss.ejb3.annotation.SecurityDomain;
import org.jboss.jandex.AnnotationInstance;

/**
* Processes the {@link org.jboss.ejb3.annotation.SecurityDomain} annotation on a session bean
*
* @author Stuart Douglas
*/
public class SecurityDomainAnnotationInformationFactory extends ClassAnnotationInformationFactory<SecurityDomain, String> {

protected SecurityDomainAnnotationInformationFactory() {
super(SecurityDomain.class, null);
}

@Override
protected String fromAnnotation(final AnnotationInstance annotationInstance) {
return annotationInstance.value().asString();
}
}
@@ -0,0 +1,68 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb3.deployment.processors.merging;

import org.jboss.as.ee.component.EEApplicationClasses;
import org.jboss.as.ee.component.EEModuleClassDescription;
import org.jboss.as.ee.metadata.ClassAnnotationInformation;
import org.jboss.as.ejb3.component.EJBComponentDescription;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
import org.jboss.ejb3.annotation.SecurityDomain;
import org.jboss.logging.Logger;

/**
* @author Stuart Douglas
*/
public class SecurityDomainMergingProcessor extends AbstractMergingProcessor<EJBComponentDescription> {

private static final Logger logger = Logger.getLogger(SecurityDomainMergingProcessor.class);

public SecurityDomainMergingProcessor() {
super(EJBComponentDescription.class);
}

@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
final EEModuleClassDescription clazz = applicationClasses.getClassByName(componentClass.getName());
//we only care about annotations on the bean class itself
if (clazz == null) {
return;
}
final ClassAnnotationInformation<SecurityDomain, String> securityDomain = clazz.getAnnotationInformation(SecurityDomain.class);
if (securityDomain == null) {
return;
}
if (!securityDomain.getClassLevelAnnotations().isEmpty()) {
if (logger.isDebugEnabled()) {
logger.debug("EJB " + description.getEJBName() + " is part of security domain " + securityDomain.getClassLevelAnnotations().get(0));
}
description.setSecurityDomain(securityDomain.getClassLevelAnnotations().get(0));
}
}

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {

}
}
Expand Up @@ -48,7 +48,6 @@
import org.jboss.as.ejb3.deployment.processors.MethodPermissionDDProcessor;
import org.jboss.as.ejb3.deployment.processors.PermitAllProcessor;
import org.jboss.as.ejb3.deployment.processors.RolesAllowedProcessor;
import org.jboss.as.ejb3.deployment.processors.SecurityDomainProcessor;
import org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory;
import org.jboss.as.ejb3.deployment.processors.SessionSynchronizationProcessor;
import org.jboss.as.ejb3.deployment.processors.StatefulTimeoutAnnotationProcessor;
Expand All @@ -65,6 +64,7 @@
import org.jboss.as.ejb3.deployment.processors.merging.RemoveMethodMergingProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.ResourceAdaptorMergingProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.RunAsMergingProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.SecurityDomainMergingProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.StartupMergingProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.TransactionAttributeMergingProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.TransactionManagementMergingProcessor;
Expand Down Expand Up @@ -151,7 +151,6 @@ protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_EJB_DD_INTERCEPTORS, new InterceptorClassDeploymentDescriptorProcessor());
processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_EJB_ASSEMBLY_DESC_DD, new AssemblyDescriptorProcessor());
processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_EJB_SECURITY_ROLE_REF_DD, new SecurityRoleRefDDProcessor());
processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_EJB_SECURITY_DOMAIN_ANNOTATION, new SecurityDomainProcessor());

processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB, new EjbDependencyDeploymentUnitProcessor());

Expand All @@ -175,6 +174,7 @@ protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(Phase.POST_MODULE, Phase.POST_MODULE_EJB_RESOURCE_ADAPTER_MERGE, new ResourceAdaptorMergingProcessor());
processorTarget.addDeploymentProcessor(Phase.POST_MODULE, Phase.POST_MODULE_EJB_REMOVE_METHOD, new RemoveMethodMergingProcessor());
processorTarget.addDeploymentProcessor(Phase.POST_MODULE, Phase.POST_MODULE_EJB_STARTUP_MERGE, new StartupMergingProcessor());
processorTarget.addDeploymentProcessor(Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_DOMAIN, new SecurityDomainMergingProcessor());

processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_RESOLVE_EJB_INJECTIONS, new EjbInjectionResolutionProcessor());
processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_DEPENDS_ON_ANNOTATION, new EjbDependsOnAnnotationProcessor());
Expand Down
19 changes: 10 additions & 9 deletions server/src/main/java/org/jboss/as/server/deployment/Phase.java
Expand Up @@ -304,6 +304,16 @@ public AttachmentKey<?> getPhaseKey() {
public static final int POST_MODULE_EJB_METHOD_PERMISSION_DD = 0x0505;
public static final int POST_MODULE_EJB_TIMER_METADATA_MERGE = 0x0506;
public static final int POST_MODULE_EJB_DD_INTERCEPTORS = 0x0600;
public static final int POST_MODULE_EJB_TIMER_SERVICE = 0x0601;
public static final int POST_MODULE_EJB_TRANSACTION_MANAGEMENT = 0x0602;
public static final int POST_MODULE_EJB_TX_ATTR_MERGE = 0x0603;
public static final int POST_MODULE_EJB_CONCURRENCY_MANAGEMENT_MERGE= 0x0604;
public static final int POST_MODULE_EJB_CONCURRENCY_MERGE = 0x0605;
public static final int POST_MODULE_EJB_RUN_AS_MERGE = 0x0606;
public static final int POST_MODULE_EJB_RESOURCE_ADAPTER_MERGE = 0x0607;
public static final int POST_MODULE_EJB_REMOVE_METHOD = 0x0608;
public static final int POST_MODULE_EJB_STARTUP_MERGE = 0x0609;
public static final int POST_MODULE_EJB_SECURITY_DOMAIN = 0x060A;
public static final int POST_MODULE_WELD_COMPONENT_INTEGRATION = 0x0800;
public static final int POST_MODULE_INSTALL_EXTENSION = 0x0A00;
public static final int POST_MODULE_VALIDATOR_FACTORY = 0x0B00;
Expand All @@ -323,15 +333,6 @@ public AttachmentKey<?> getPhaseKey() {
public static final int POST_MODULE_JAXRS_SCANNING = 0x1A00;
public static final int POST_MODULE_JAXRS_COMPONENT = 0x1B00;
public static final int POST_MODULE_JAXRS_CDI_INTEGRATION = 0x1C00;
public static final int POST_MODULE_EJB_TIMER_SERVICE = 0x1D00;
public static final int POST_MODULE_EJB_TRANSACTION_MANAGEMENT = 0x1F00;
public static final int POST_MODULE_EJB_TX_ATTR_MERGE = 0x1F01;
public static final int POST_MODULE_EJB_CONCURRENCY_MANAGEMENT_MERGE= 0x2000;
public static final int POST_MODULE_EJB_CONCURRENCY_MERGE = 0x2100;
public static final int POST_MODULE_EJB_RUN_AS_MERGE = 0x2200;
public static final int POST_MODULE_EJB_RESOURCE_ADAPTER_MERGE = 0x2300;
public static final int POST_MODULE_EJB_REMOVE_METHOD = 0x2400;
public static final int POST_MODULE_EJB_STARTUP_MERGE = 0x2500;

// INSTALL
public static final int INSTALL_JNDI_DEPENDENCY_SETUP = 0x0100;
Expand Down

0 comments on commit 04fe489

Please sign in to comment.