forked from seam/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
142 changed files
with
7,425 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,293 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>seam-security-example-authorization</artifactId> | ||
<packaging>war</packaging> | ||
<name>Seam Security Authorization Example</name> | ||
|
||
<parent> | ||
<groupId>org.jboss.seam.security</groupId> | ||
<artifactId>seam-security-parent</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<!-- | ||
Explicitly declaring the source encoding eliminates the following message: | ||
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! | ||
--> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<!-- Seam Security --> | ||
<dependency> | ||
<groupId>org.jboss.seam.security</groupId> | ||
<artifactId>seam-security</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.drools</groupId> | ||
<artifactId>drools-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.drools</groupId> | ||
<artifactId>drools-compiler</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.seam.faces</groupId> | ||
<artifactId>seam-faces</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.seam.faces</groupId> | ||
<artifactId>seam-faces-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
</dependency> | ||
|
||
<!-- CDI (JSR-299) --> | ||
<dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hibernate.javax.persistence</groupId> | ||
<artifactId>hibernate-jpa-2.0-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Bean Validation (JSR-303) --> | ||
<dependency> | ||
<groupId>javax.validation</groupId> | ||
<artifactId>validation-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- JSF --> | ||
<dependency> | ||
<groupId>javax.faces</groupId> | ||
<artifactId>jsf-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-container</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.arquillian.ajocado</groupId> | ||
<artifactId>arquillian-ajocado-junit</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<finalName>security-authorization</finalName> | ||
<!-- Prevent us from running functional tests as unit tests--> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>distribution</id> | ||
<activation> | ||
<property> | ||
<name>release</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>glassfish</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>glassfish-remote-3.1</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>ftest</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<includes> | ||
<include>**/*Test.java</include> | ||
</includes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>integration-test</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>integration-test</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>verify</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>jbossas-managed-6</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>jbossas-managed-6</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.seam.test</groupId> | ||
<artifactId>jbossas-managed-6</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>jbossas-remote-6</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>jbossas-remote-6</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.seam.test</groupId> | ||
<artifactId>jbossas-remote-6</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>jbossas-remote-7</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>jbossas-remote-7</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.seam.test</groupId> | ||
<artifactId>jbossas-remote-7</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>jbossas-managed-7</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>jbossas-managed-7</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.seam.test</groupId> | ||
<artifactId>jbossas-managed-7</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>glassfish-remote-3.1</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>glassfish-remote-3.1</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.seam.test</groupId> | ||
<artifactId>glassfish-remote-3.1</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>openshift-express</id> | ||
<activation> | ||
<property> | ||
<name>arquillian</name> | ||
<value>openshift-express</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.seam.test</groupId> | ||
<artifactId>openshift-express</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
</profiles> | ||
</project> |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> | ||
<id>security-example-authorization-distribution</id> | ||
<formats> | ||
<format>zip</format> | ||
</formats> | ||
<baseDirectory>${project.build.finalName}</baseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.basedir}</directory> | ||
<useDefaultExcludes>true</useDefaultExcludes> | ||
<excludes> | ||
<exclude>${project.build.directory}/**</exclude> | ||
<exclude>.classpath</exclude> | ||
<exclude>.project</exclude> | ||
<exclude>.settings/**</exclude> | ||
<exclude>src/main/assembly/**</exclude> | ||
</excludes> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
34 changes: 34 additions & 0 deletions
34
...ation/src/main/java/org/jboss/seam/security/examples/authorization/AuthenticatorImpl.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jboss.seam.security.examples.authorization; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.seam.security.Authenticator; | ||
import org.jboss.seam.security.BaseAuthenticator; | ||
import org.jboss.seam.security.Credentials; | ||
import org.jboss.seam.security.Identity; | ||
import org.picketlink.idm.impl.api.model.SimpleUser; | ||
|
||
/** | ||
* @author Shane Bryzak | ||
*/ | ||
public class AuthenticatorImpl extends BaseAuthenticator implements Authenticator { | ||
@Inject | ||
Identity identity; | ||
@Inject | ||
Credentials credentials; | ||
|
||
@Override | ||
public void authenticate() { | ||
if ("demo".equals(credentials.getUsername())) { | ||
identity.addRole("admin", "USERS", "GROUP"); | ||
} | ||
|
||
if ("user".equals(credentials.getUsername())) { | ||
identity.addGroup("USERS", "GROUP"); | ||
} | ||
|
||
// Let any user log in | ||
setStatus(AuthenticationStatus.SUCCESS); | ||
setUser(new SimpleUser(credentials.getUsername())); | ||
} | ||
} |
Oops, something went wrong.