You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by ad...@apache.org on 2010/10/24 20:08:56 UTC

svn commit: r1026849 - in /shiro/trunk: pom.xml support/crowd/ support/crowd/pom.xml support/crowd/src/main/java/org/apache/shiro/realm/crowd/CrowdRealm.java support/pom.xml

Author: adc
Date: Sun Oct 24 18:08:56 2010
New Revision: 1026849

URL: http://svn.apache.org/viewvc?rev=1026849&view=rev
Log:
SHIRO-18 Merged into trunk

Added:
    shiro/trunk/support/crowd/
      - copied from r1026619, shiro/sandbox/crowd/
Modified:
    shiro/trunk/pom.xml
    shiro/trunk/support/crowd/pom.xml
    shiro/trunk/support/crowd/src/main/java/org/apache/shiro/realm/crowd/CrowdRealm.java
    shiro/trunk/support/pom.xml

Modified: shiro/trunk/pom.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/pom.xml?rev=1026849&r1=1026848&r2=1026849&view=diff
==============================================================================
--- shiro/trunk/pom.xml (original)
+++ shiro/trunk/pom.xml Sun Oct 24 18:08:56 2010
@@ -64,6 +64,7 @@
 
     <properties>
         <shiro.osgi.importRange>[1.1.0, 2.0.0)</shiro.osgi.importRange>
+        <crowd.version>1.5.2</crowd.version>
         <jdk.version>1.5</jdk.version>
         <slf4j.version>1.5.6</slf4j.version>
         <hsqldb.version>1.8.0.7</hsqldb.version>
@@ -287,6 +288,12 @@
 
             <!-- 3rd party dependencies -->
             <dependency>
+                <!-- Used for Atlassian Crowd Realm - not required for the framework: -->
+                <groupId>com.atlassian.crowd</groupId>
+                <artifactId>crowd-integration-client</artifactId>
+                <version>${crowd.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.slf4j</groupId>
                 <artifactId>slf4j-api</artifactId>
                 <version>${slf4j.version}</version>

Modified: shiro/trunk/support/crowd/pom.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/support/crowd/pom.xml?rev=1026849&r1=1026619&r2=1026849&view=diff
==============================================================================
--- shiro/trunk/support/crowd/pom.xml (original)
+++ shiro/trunk/support/crowd/pom.xml Sun Oct 24 18:08:56 2010
@@ -17,76 +17,47 @@
   ~ specific language governing permissions and limitations
   ~ under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<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>
-
     <parent>
-        <groupId>org.apache</groupId>
-        <artifactId>apache</artifactId>
-        <version>6</version>
+        <groupId>org.apache.shiro</groupId>
+        <artifactId>shiro-root</artifactId>
+        <version>1.1.0-SNAPSHOT</version>
     </parent>
 
-    <groupId>org.apache.shiro</groupId>
+    <modelVersion>4.0.0</modelVersion>
     <artifactId>shiro-crowd</artifactId>
-    <version>1.1.0-SNAPSHOT</version>
-    <packaging>jar</packaging>
-    <name>Crowd Realm</name>
+    <name>Apache Shiro :: Support :: Crowd Realm</name>
     <description>An Apache Shiro realm for the Atlassian Crowd API</description>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.0.2</version>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                    <encoding>${project.build.sourceEncoding}</encoding>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+    <packaging>bundle</packaging>
 
     <dependencies>
         <dependency>
             <groupId>com.atlassian.crowd</groupId>
             <artifactId>crowd-integration-client</artifactId>
-            <version>1.5.2</version>
-        </dependency>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.5</version>
-            <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.shiro</groupId>
             <artifactId>shiro-core</artifactId>
-            <version>1.0.0-incubating</version>
         </dependency>
 
         <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
-            <version>2.4</version>
-            <scope>test</scope>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
         </dependency>
 
         <dependency>
             <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.5.8</version>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
         </dependency>
 
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-jdk14</artifactId>
-            <version>1.5.8</version>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
@@ -96,8 +67,7 @@
             <id>central</id>
             <url>https://m2proxy.atlassian.com/repository/public</url>
             <snapshots>
-                <enabled>true</enabled>
-                <updatePolicy>always</updatePolicy>
+                <enabled>false</enabled>
             </snapshots>
             <releases>
                 <enabled>true</enabled>
@@ -105,4 +75,25 @@
         </repository>
     </repositories>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>org.apache.shiro.realm.crowd</Bundle-SymbolicName>
+                        <Export-Package>org.apache.shiro.realm.crowd*;version=${project.version}</Export-Package>
+                        <Import-Package>
+                            org.apache.shiro*;version="${shiro.osgi.importRange}",
+                            com.atlassian.crowd.integration*;version="[1.5.0, 2.0.0)",
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

Modified: shiro/trunk/support/crowd/src/main/java/org/apache/shiro/realm/crowd/CrowdRealm.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/crowd/src/main/java/org/apache/shiro/realm/crowd/CrowdRealm.java?rev=1026849&r1=1026619&r2=1026849&view=diff
==============================================================================
--- shiro/trunk/support/crowd/src/main/java/org/apache/shiro/realm/crowd/CrowdRealm.java (original)
+++ shiro/trunk/support/crowd/src/main/java/org/apache/shiro/realm/crowd/CrowdRealm.java Sun Oct 24 18:08:56 2010
@@ -26,7 +26,6 @@ import com.atlassian.crowd.integration.e
 import com.atlassian.crowd.integration.exception.InvalidAuthorizationTokenException;
 import com.atlassian.crowd.integration.exception.ObjectNotFoundException;
 import com.atlassian.crowd.integration.service.soap.client.SecurityServerClient;
-import com.atlassian.crowd.integration.service.soap.client.SecurityServerClientFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,23 +58,16 @@ import org.apache.shiro.subject.Principa
 public class CrowdRealm extends AuthorizingRealm {
 
     private static final Logger LOG = LoggerFactory.getLogger(CrowdRealm.class);
-    private final SecurityServerClient crowdClient;
+    private SecurityServerClient crowdClient;
     private EnumSet<RoleSource> roleSources = EnumSet.of(RoleSource.ROLES_FROM_CROWD_ROLES);
 
     /**
-     * Initialize the Shiro Crowd realm with an instance of
-     * {@link SecurityServerClient} generated by the factory
-     * {@link SecurityServerClientFactory}.  The method
-     * {@link SecurityServerClient#authenticate} is called by this
-     * constructor.
-     *
-     * @throws InvalidAuthorizationTokenException
-     *                         if the credentials in the <code>crowd.properties</code> are not correct
-     * @throws RemoteException if the client cannot reach the Crowd server
-     */
-    public CrowdRealm() throws InvalidAuthorizationTokenException, RemoteException {
-        crowdClient = SecurityServerClientFactory.getSecurityServerClient();
-        crowdClient.authenticate();
+     * A simple constructor for a Shiro Crowd realm.
+     * <p/>
+     * It is expected that an initialized Crowd client will be subsequently
+     * set using {@link #setCrowdClient(SecurityServerClient)}.
+     */
+    public CrowdRealm() {
     }
 
     /**
@@ -92,6 +84,18 @@ public class CrowdRealm extends Authoriz
     }
 
     /**
+     * Set the client to use when communicating with the Crowd server.
+     * <p/>
+     * It is assumed that the Crowd client has already authenticated with the
+     * Crowd server.
+     *
+     * @param crowdClient the client to use when communicating with the Crowd server
+     */
+    public void setCrowdClient(SecurityServerClient crowdClient) {
+        this.crowdClient = crowdClient;
+    }
+
+    /**
      * Obtain the kinds of Crowd memberships that will serve as sources for
      * Shiro roles.
      *

Modified: shiro/trunk/support/pom.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/support/pom.xml?rev=1026849&r1=1026848&r2=1026849&view=diff
==============================================================================
--- shiro/trunk/support/pom.xml (original)
+++ shiro/trunk/support/pom.xml Sun Oct 24 18:08:56 2010
@@ -32,6 +32,7 @@
 
     <modules>
         <module>aspectj</module>
+        <module>crowd</module>
         <module>ehcache</module>
         <module>groovy</module>
         <module>quartz</module>