Initialization of authorization service from the code is now working.
[photos] / src / main / java / org / wamblee / photos / security / PhotoAuthorizationRule.java
index 0fab5c563f3c275cbd74256367c49c262ceb557d..d772e1c92b1d6f34adcdaacf09ddcaa867488a01 100644 (file)
@@ -17,7 +17,6 @@
 package org.wamblee.photos.security;
 
 import java.util.List;
-
 import javax.inject.Inject;
 import javax.persistence.DiscriminatorValue;
 import javax.persistence.Entity;
@@ -31,6 +30,7 @@ import org.wamblee.security.authorization.AuthorizationResult;
 import org.wamblee.security.authorization.Operation;
 import org.wamblee.security.authorization.ReadOperation;
 import org.wamblee.security.authorization.UrlAuthorizationRule;
+import org.wamblee.security.authorization.UserCondition;
 
 /**
  * Authorization rule for photos. A user has access to all albums owned by his
@@ -46,29 +46,39 @@ public class PhotoAuthorizationRule extends UrlAuthorizationRule {
 
     /**
      * Constructs the authorization rule.
-     * 
      */
     public PhotoAuthorizationRule() {
         // Empty.
     }
 
+    public PhotoAuthorizationRule(UserCondition aUserCondition) {
+        super(AuthorizationResult.GRANTED, aUserCondition, null, PhotoEntry.class, null);
+    }
+
     @PostLoad
     public void init() {
         InjectorBuilder.getInjector().inject(this);
     }
 
-    /* (non-Javadoc)
-     * @see org.wamblee.security.authorization.AuthorizationRule#getSupportedTypes()
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.wamblee.security.authorization.AuthorizationRule#getSupportedTypes()
      */
     public Class[] getSupportedTypes() {
-        return new Class[] { PhotoEntry.class };
+        return new Class[]{PhotoEntry.class};
     }
 
-    /* (non-Javadoc)
-     * @see org.wamblee.security.authorization.AuthorizationRule#isAllowed(java.lang.Object, org.wamblee.security.authorization.Operation, org.wamblee.usermgt.User)
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.wamblee.security.authorization.AuthorizationRule#isAllowed(java.lang
+     * .Object, org.wamblee.security.authorization.Operation,
+     * org.wamblee.usermgt.User)
      */
-    public AuthorizationResult isAllowed(Object aResource,
-        Operation anOperation, String aUser) {
+    public AuthorizationResult isAllowed(Object aResource, Operation anOperation, String aUser) {
         if (!(aResource instanceof PhotoEntry)) {
             return AuthorizationResult.UNSUPPORTED_RESOURCE;
         }
@@ -93,7 +103,9 @@ public class PhotoAuthorizationRule extends UrlAuthorizationRule {
         return ((PhotoEntry) aResource).getPath();
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     *
      * @see java.lang.Object#toString()
      */
     @Override