directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r351578 - in /directory/authx/trunk: example/ example/src/etc/ example/src/webapp/ example/src/webapp/WEB-INF/ jdbc/ script/ script/src/test/org/apache/authx/script/common/ script/src/test/org/apache/authx/script/groovy/
Date Fri, 02 Dec 2005 04:21:33 GMT
Author: vtence
Date: Thu Dec  1 20:21:26 2005
New Revision: 351578

URL: http://svn.apache.org/viewcvs?rev=351578&view=rev
Log:
Upgraded to latest groovy, which fixes a nasty bug preventing to access resource real path
from ServletContext. Updated all groovy scripts syntax accordingly. Added jetty config example.

Added:
    directory/authx/trunk/example/src/etc/
    directory/authx/trunk/example/src/etc/jetty.xml
Modified:
    directory/authx/trunk/example/project.xml
    directory/authx/trunk/example/src/webapp/WEB-INF/nanocontainer.groovy
    directory/authx/trunk/example/src/webapp/WEB-INF/treasure.groovy
    directory/authx/trunk/example/src/webapp/security.groovy
    directory/authx/trunk/example/src/webapp/shop.groovy
    directory/authx/trunk/jdbc/project.xml
    directory/authx/trunk/script/project.xml
    directory/authx/trunk/script/src/test/org/apache/authx/script/common/canadians.groovy
    directory/authx/trunk/script/src/test/org/apache/authx/script/groovy/geeks.groovy

Modified: directory/authx/trunk/example/project.xml
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/example/project.xml?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/example/project.xml (original)
+++ directory/authx/trunk/example/project.xml Thu Dec  1 20:21:26 2005
@@ -40,7 +40,7 @@
         <dependency>
             <groupId>dom4j</groupId>
             <artifactId>dom4j</artifactId>
-            <version>1.4</version>
+            <version>1.6.1</version>
             <properties>
                 <war.bundle>true</war.bundle>
             </properties>
@@ -73,7 +73,7 @@
         <dependency>
             <groupId>nanocontainer</groupId>
             <artifactId>nanocontainer</artifactId>
-            <version>1.0-beta-3</version>
+            <version>1.0-beta-4</version>
             <properties>
                 <war.bundle>true</war.bundle>
             </properties>
@@ -81,38 +81,20 @@
         <dependency>
             <groupId>nanocontainer</groupId>
             <artifactId>nanocontainer-nanowar</artifactId>
-            <version>1.0-beta-3</version>
+            <version>1.0-beta-4</version>
             <properties>
                 <war.bundle>true</war.bundle>
             </properties>
         </dependency>
         <dependency>
             <groupId>groovy</groupId>
-            <artifactId>groovy</artifactId>
-            <version>1.0-beta-9</version>
-            <properties>
-                <war.bundle>true</war.bundle>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>asm</groupId>
-            <artifactId>asm</artifactId>
-            <version>1.5.2</version>
+            <artifactId>groovy-all</artifactId>
+            <version>1.0-jsr-04</version>
             <properties>
                 <war.bundle>true</war.bundle>
             </properties>
         </dependency>
         <dependency>
-            <groupId>asm</groupId>
-            <artifactId>asm-util</artifactId>
-            <version>1.5.2</version>
-            <properties>
-                <war.bundle>true</war.bundle>
-                <gump.project>asm</gump.project>
-                <gump.id>asm-util</gump.id>
-            </properties>
-        </dependency>
-        <dependency>
             <groupId>velocity</groupId>
             <artifactId>velocity</artifactId>
             <version>1.4</version>
@@ -125,7 +107,7 @@
         <dependency>
             <groupId>velocity-tools</groupId>
             <artifactId>velocity-tools-view</artifactId>
-            <version>1.0</version>
+            <version>1.1</version>
             <properties>
                 <war.bundle>true</war.bundle>
                 <gump.project>jakarta-velocity-tools</gump.project>

Added: directory/authx/trunk/example/src/etc/jetty.xml
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/example/src/etc/jetty.xml?rev=351578&view=auto
==============================================================================
--- directory/authx/trunk/example/src/etc/jetty.xml (added)
+++ directory/authx/trunk/example/src/etc/jetty.xml Thu Dec  1 20:21:26 2005
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
+<Configure class="org.mortbay.jetty.Server">
+    <Call name="addListener">
+        <Arg>
+            <New class="org.mortbay.http.SocketListener">
+                <Set name="Port">
+                    <SystemProperty name="jetty.port" default="8081"/>
+                </Set>
+            </New>
+        </Arg>
+    </Call>
+
+    <Call name="addWebApplication">
+        <Arg>/</Arg>
+        <Arg>src/webapp</Arg>
+    </Call>
+</Configure>
\ No newline at end of file

Modified: directory/authx/trunk/example/src/webapp/WEB-INF/nanocontainer.groovy
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/example/src/webapp/WEB-INF/nanocontainer.groovy?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/example/src/webapp/WEB-INF/nanocontainer.groovy (original)
+++ directory/authx/trunk/example/src/webapp/WEB-INF/nanocontainer.groovy Thu Dec  1 20:21:26
2005
@@ -4,9 +4,8 @@
 {
     // Let's define users of the system from an XML file containing usernames/passwords
     realm = new org.apache.authx.authentication.realm.MemoryRealm()
-    // A nasty groovy bug prevents us from using servlet context to get the file real path
-    // See http://jira.codehaus.org/browse/GROOVY-210
-    users = new java.io.FileReader( "/opt/jakarta-tomcat-5.0.28/webapps/authx-example/WEB-INF/users.xml"
)
+
+    users = new java.io.InputStreamReader( assemblyScope.getResourceAsStream( "/WEB-INF/users.xml"
) )
     realmBuilder = org.apache.authx.script.xml.Dom4JRealmBuilder.fromReader( users )
     realmBuilder.buildRealm( realm )
 
@@ -17,11 +16,11 @@
     // Users in our system can have groups and roles
     // Let's build the respective providers from their XML definitions
     roleProvider = new org.apache.authx.authentication.attribute.AttributeProvider()
-    roles = new java.io.FileReader( "/opt/jakarta-tomcat-5.0.28/webapps/authx-example/WEB-INF/roles.xml"
)
+    roles = new java.io.InputStreamReader( assemblyScope.getResourceAsStream( "/WEB-INF/roles.xml"
) )
     roleBuilder = org.apache.authx.script.xml.Dom4JRoleBuilder.fromReader( roles )
     roleBuilder.buildProvider( roleProvider )
     groupProvider = new org.apache.authx.authentication.attribute.AttributeProvider()
-    groups = new java.io.FileReader( "/opt/jakarta-tomcat-5.0.28/webapps/authx-example/WEB-INF/groups.xml"
)
+    groups = new java.io.InputStreamReader( assemblyScope.getResourceAsStream( "/WEB-INF/groups.xml"
) )
     groupBuilder = org.apache.authx.script.xml.Dom4JGroupBuilder.fromReader( groups )
     groupBuilder.buildProvider( groupProvider )
 
@@ -33,20 +32,20 @@
     // Next we have to define the system policy
     // Let's first read some rules from an XML file - notice the custom condition builder
used
     policy = new org.apache.authx.authorization.Policy( new org.apache.authx.authorization.effect.PermitOverridesEffect()
)
-    permissions = new java.io.FileReader( "/opt/jakarta-tomcat-5.0.28/webapps/authx-example/WEB-INF/permissions.xml"
)
+    permissions = new java.io.InputStreamReader( assemblyScope.getResourceAsStream( "/WEB-INF/permissions.xml"
) )
     policyBuilder = org.apache.authx.script.xml.Dom4JRuleSetBuilder.fromReader( permissions
)
     policyBuilder.registerBuilder( new org.apache.authx.example.web.CanPurchaseConditionBuilder()
)
     policyBuilder.buildRuleSet( policy )
 
     // Rules can also be defined in groovy
-    specials = new java.io.File( "/opt/jakarta-tomcat-5.0.28/webapps/authx-example/WEB-INF/treasure.groovy"
)
-    // Rule classes can have dependencies that will be pulled out from the pico container
+    specials = assemblyScope.getResource( "/WEB-INF/treasure.groovy" )
+    // Rule classes can have dependencies that will be pulled out from pico
     pico.registerComponentInstance( new org.apache.authx.example.web.Treasure( 500 ) )
 
     picoFactory = new org.apache.authx.script.common.PicoContainerFactory( pico )
     groovyLoader = new org.apache.authx.script.groovy.GroovyRuleLoader( picoFactory )
     scriptedBuilder = new org.apache.authx.script.common.ScriptedRuleSetBuilder( groovyLoader
)
-    scriptedBuilder.addScript( specials.toURL() )
+    scriptedBuilder.addScript( specials )
     scriptedBuilder.buildRuleSet( policy )
 
     // Now that the policy is ready, let's define and register the authorizer

Modified: directory/authx/trunk/example/src/webapp/WEB-INF/treasure.groovy
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/example/src/webapp/WEB-INF/treasure.groovy?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/example/src/webapp/WEB-INF/treasure.groovy (original)
+++ directory/authx/trunk/example/src/webapp/WEB-INF/treasure.groovy Thu Dec  1 20:21:26 2005
@@ -1,27 +1,27 @@
 class TreasureLimit {
 
-    cash
+    def cash
 
     TreasureLimit( org.apache.authx.example.web.Treasure treasure )
     {
         cash = treasure
     }
 
-    evaluate( request )
+    def evaluate( request )
     {
         if ( !rich( request.getSubject() ) ) return
         if ( hasEnoughCash( request.getPermission() ) ) request.grant()
     }
 
-    rich( subject )
+    def rich( subject )
     {
-        rich = new org.apache.authx.authentication.attribute.GroupPrincipal( "rich" )
+        def rich = new org.apache.authx.authentication.attribute.GroupPrincipal( "rich" )
         return subject.getPrincipals().contains( rich )
     }
 
-    hasEnoughCash( purchase )
+    def hasEnoughCash( purchase )
     {
-        limit = new org.apache.authx.example.web.PurchasePermission( cash.getAmount() )
+        def limit = new org.apache.authx.example.web.PurchasePermission( cash.getAmount()
)
         return limit.implies( purchase )
     }
 }

Modified: directory/authx/trunk/example/src/webapp/security.groovy
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/example/src/webapp/security.groovy?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/example/src/webapp/security.groovy (original)
+++ directory/authx/trunk/example/src/webapp/security.groovy Thu Dec  1 20:21:26 2005
@@ -8,32 +8,33 @@
 
 class Security {
 
-    authenticator
-    username
-    password
-    context
+    def authenticator
+    def context
+
+    @Property username
+    @Property password
 
     Security( Authenticator authenticator, SecurityContext context ) {
         this.authenticator = authenticator
         this.context = context
     }
 
-    login() {
+    def login() {
         return "login"
     }
 
-    authenticate() {
-        creds = new CredentialSet()
+    def authenticate() {
+        def creds = new CredentialSet()
         creds.add( new UsernameCredential( username ) )
         creds.add( new PasswordCredential( password ) )
-        subject = authenticator.authenticate( creds )
+        def subject = authenticator.authenticate( creds )
         if ( subject == null ) return "try_again"
 
         context.login( subject )
         return "home"
     }
 
-    logout() {
+    def logout() {
         return "index"
     }
 }

Modified: directory/authx/trunk/example/src/webapp/shop.groovy
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/example/src/webapp/shop.groovy?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/example/src/webapp/shop.groovy (original)
+++ directory/authx/trunk/example/src/webapp/shop.groovy Thu Dec  1 20:21:26 2005
@@ -5,12 +5,13 @@
 
 class Shop {
 
-    authorizer
-    context
-    catalog
-    key
-    item
-    username
+    def authorizer
+    def context
+
+    @Property catalog
+    @Property item
+    @Property username
+    @Property key
 
     Shop( Authorizer authorizer, SecurityContext context ) {
         this.authorizer = authorizer
@@ -21,30 +22,30 @@
         catalog.put( "mug", new Item( "Purple Java Mug", 10 ) )
     }
 
-    list() {
+    def list() {
         return "catalog"
     }
 
-    view() {
+    def view() {
         item = lookup( key )
         return "item_details"
     }
 
-    buy() {
+    def buy() {
         item = lookup( key )
-        purchase = new PurchasePermission( item.getPrice() )
-        me = context.getSubject()
+        def purchase = new PurchasePermission( item.getPrice() )
+        def me = context.getSubject()
         username = context.getUsername()
         if ( !authorizer.renderDecision( me, purchase ) ) return "denied"
 
         return "receipt"
     }
 
-    exit() {
+    def exit() {
         return "home"
     }
 
-    lookup( key ) {
+    def lookup( key ) {
         return catalog.get( key )
     }
 }

Modified: directory/authx/trunk/jdbc/project.xml
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/project.xml?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/jdbc/project.xml (original)
+++ directory/authx/trunk/jdbc/project.xml Thu Dec  1 20:21:26 2005
@@ -21,7 +21,7 @@
         <dependency>
             <groupId>hsqldb</groupId>
             <artifactId>hsqldb</artifactId>
-            <version>1.7.2.2</version>
+            <version>1.7.3.3</version>
         </dependency>
     </dependencies>
 </project>

Modified: directory/authx/trunk/script/project.xml
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/script/project.xml?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/script/project.xml (original)
+++ directory/authx/trunk/script/project.xml Thu Dec  1 20:21:26 2005
@@ -23,7 +23,7 @@
         <dependency>
             <groupId>dom4j</groupId>
             <artifactId>dom4j</artifactId>
-            <version>1.4</version>
+            <version>1.6.1</version>
         </dependency>
         <dependency>
             <groupId>xerces</groupId>
@@ -41,22 +41,8 @@
         <!-- Groovy -->
         <dependency>
             <groupId>groovy</groupId>
-            <artifactId>groovy</artifactId>
-            <version>1.0-beta-9</version>
-        </dependency>
-        <dependency>
-            <groupId>asm</groupId>
-            <artifactId>asm</artifactId>
-            <version>1.5.2</version>
-        </dependency>
-        <dependency>
-            <groupId>asm</groupId>
-            <artifactId>asm-util</artifactId>
-            <version>1.5.2</version>
-            <properties>
-                <gump.project>asm</gump.project>
-                <gump.id>asm-util</gump.id>
-            </properties>
+            <artifactId>groovy-all</artifactId>
+            <version>1.0-jsr-04</version>
         </dependency>
         <dependency>
             <groupId>picocontainer</groupId>

Modified: directory/authx/trunk/script/src/test/org/apache/authx/script/common/canadians.groovy
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/script/src/test/org/apache/authx/script/common/canadians.groovy?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/script/src/test/org/apache/authx/script/common/canadians.groovy
(original)
+++ directory/authx/trunk/script/src/test/org/apache/authx/script/common/canadians.groovy
Thu Dec  1 20:21:26 2005
@@ -1,8 +1,8 @@
 class Canadians {
 
-    evaluate( request )
+    void evaluate( request )
     {
-        canadians = new org.apache.authx.authentication.attribute.GroupPrincipal( "canadians"
);
+        def canadians = new org.apache.authx.authentication.attribute.GroupPrincipal( "canadians"
);
         if ( request.getSubject().getPrincipals().contains( canadians ) ) request.deny();
     }
 

Modified: directory/authx/trunk/script/src/test/org/apache/authx/script/groovy/geeks.groovy
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/script/src/test/org/apache/authx/script/groovy/geeks.groovy?rev=351578&r1=351577&r2=351578&view=diff
==============================================================================
--- directory/authx/trunk/script/src/test/org/apache/authx/script/groovy/geeks.groovy (original)
+++ directory/authx/trunk/script/src/test/org/apache/authx/script/groovy/geeks.groovy Thu
Dec  1 20:21:26 2005
@@ -1,8 +1,8 @@
 class Geeks {
 
-    evaluate( request )
+    void evaluate( request )
     {
-        geeks = new org.apache.authx.authentication.attribute.GroupPrincipal( "geeks" );
+        def geeks = new org.apache.authx.authentication.attribute.GroupPrincipal( "geeks"
);
         if ( request.getSubject().getPrincipals().contains( geeks ) ) request.grant();
     }
 



Mime
View raw message