Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFLY-10172 Add support for JSR-375 EE Security
- Loading branch information
1 parent
aa1549c
commit 8f303e3
Showing
37 changed files
with
1,062 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,110 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- | |||
~ 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. | |||
--> | |||
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
|
|||
<parent> | |||
<groupId>org.wildfly</groupId> | |||
<artifactId>wildfly-parent</artifactId> | |||
<!-- | |||
Maintain separation between the artifact id and the version to help prevent | |||
merge conflicts between commits changing the GA and those changing the V. | |||
--> | |||
<version>13.0.0.Alpha1-SNAPSHOT</version> | |||
</parent> | |||
|
|||
<artifactId>wildfly-ee-security</artifactId> | |||
|
|||
<name>WildFly: Java EE Security</name> | |||
|
|||
<dependencies> | |||
|
|||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>wildfly-ee</artifactId> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>wildfly-weld</artifactId> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.jboss.logging</groupId> | |||
<artifactId>jboss-logging</artifactId> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.glassfish.soteria</groupId> | |||
<artifactId>javax.security.enterprise</artifactId> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.jboss.logging</groupId> | |||
<artifactId>jboss-logging-annotations</artifactId> | |||
<!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other | |||
projects that depend on this project.--> | |||
<scope>provided</scope> | |||
<optional>true</optional> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.jboss.logging</groupId> | |||
<artifactId>jboss-logging-processor</artifactId> | |||
<!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other | |||
projects that depend on this project.--> | |||
<scope>provided</scope> | |||
<optional>true</optional> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.jboss.msc</groupId> | |||
<artifactId>jboss-msc</artifactId> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.wildfly.core</groupId> | |||
<artifactId>wildfly-subsystem-test</artifactId> | |||
<type>pom</type> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
|
|||
<build> | |||
<resources> | |||
<resource> | |||
<directory>src/main/resources</directory> | |||
<filtering>true</filtering> | |||
</resource> | |||
</resources> | |||
</build> | |||
</project> |
79 changes: 79 additions & 0 deletions
79
...ecurity/src/main/java/org/wildfly/extension/eesecurity/EESecurityAnnotationProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,79 @@ | |||
/* | |||
* Copyright (C) 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 library 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 library 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 library; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301 USA | |||
*/ | |||
package org.wildfly.extension.eesecurity; | |||
|
|||
import org.jboss.as.server.deployment.AttachmentKey; | |||
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.server.deployment.annotation.CompositeIndex; | |||
import org.jboss.jandex.DotName; | |||
|
|||
class EESecurityAnnotationProcessor implements DeploymentUnitProcessor { | |||
|
|||
static final AttachmentKey<Boolean> SECURITY_PRESENT = AttachmentKey.create(Boolean.class); | |||
|
|||
static final DotName[] ANNOTATIONS = { | |||
DotName.createSimple("javax.security.enterprise.authentication.mechanism.http.BasicAuthenticationMechanismDefinition"), | |||
DotName.createSimple("javax.security.enterprise.authentication.mechanism.http.CustomFormAuthenticationMechanismDefinition"), | |||
DotName.createSimple("javax.security.enterprise.authentication.mechanism.http.FormAuthenticationMechanismDefinition"), | |||
DotName.createSimple("javax.security.enterprise.identitystore.DatabaseIdentityStoreDefinition"), | |||
DotName.createSimple("javax.security.enterprise.identitystore.LdapIdentityStoreDefinition") | |||
}; | |||
|
|||
static final DotName[] INTERFACES = { | |||
DotName.createSimple("javax.security.enterprise.authentication.mechanism.http.HttpAuthenticationMechanism"), | |||
DotName.createSimple("javax.security.enterprise.identitystore.IdentityStoreHandler"), | |||
DotName.createSimple("javax.security.enterprise.identitystore.IdentityStore"), | |||
DotName.createSimple("javax.security.enterprise.identitystore.RememberMeIdentityStore") | |||
}; | |||
|
|||
@Override | |||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { | |||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); | |||
CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); | |||
for (DotName annotation : ANNOTATIONS) { | |||
if (!index.getAnnotations(annotation).isEmpty()) { | |||
markAsEESecurity(deploymentUnit); | |||
return; | |||
} | |||
} | |||
for (DotName annotation : INTERFACES) { | |||
if (!index.getAllKnownImplementors(annotation).isEmpty()) { | |||
markAsEESecurity(deploymentUnit); | |||
return; | |||
} | |||
} | |||
|
|||
} | |||
|
|||
private void markAsEESecurity(DeploymentUnit deploymentUnit) { | |||
DeploymentUnit top = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent(); | |||
top.putAttachment(SECURITY_PRESENT, true); | |||
} | |||
|
|||
@Override | |||
public void undeploy(DeploymentUnit context) { | |||
|
|||
} | |||
} |
56 changes: 56 additions & 0 deletions
56
...ecurity/src/main/java/org/wildfly/extension/eesecurity/EESecurityDependencyProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
/* | |||
* Copyright (C) 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 library 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 library 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 library; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301 USA | |||
*/ | |||
package org.wildfly.extension.eesecurity; | |||
|
|||
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.server.deployment.module.ModuleDependency; | |||
import org.jboss.as.server.deployment.module.ModuleSpecification; | |||
import org.jboss.modules.Module; | |||
import org.jboss.modules.ModuleIdentifier; | |||
import org.jboss.modules.ModuleLoader; | |||
|
|||
class EESecurityDependencyProcessor implements DeploymentUnitProcessor { | |||
@Override | |||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { | |||
|
|||
final DeploymentUnit unit = phaseContext.getDeploymentUnit(); | |||
final DeploymentUnit top = unit.getParent() == null ? unit : unit.getParent(); | |||
final ModuleLoader moduleLoader = Module.getBootModuleLoader(); | |||
|
|||
final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION); | |||
moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("javax.security.enterprise.api"), false, false, true, false)); | |||
|
|||
Boolean securityPresent = top.getAttachment(EESecurityAnnotationProcessor.SECURITY_PRESENT); | |||
if(securityPresent != null && securityPresent) { | |||
moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("org.glassfish.soteria"), false, false, true, false)); | |||
} | |||
|
|||
} | |||
|
|||
@Override | |||
public void undeploy(DeploymentUnit deploymentUnit) { | |||
|
|||
} | |||
} |
Oops, something went wrong.