X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fwamblee%2Fphotos%2Fsecurity%2FPhotoAuthorizationRule.java;h=d772e1c92b1d6f34adcdaacf09ddcaa867488a01;hb=0edd451bb32da41f5c54ec2acfb11a693f567ec9;hp=0fab5c563f3c275cbd74256367c49c262ceb557d;hpb=562755fd98ee5661532ae14df234eeaa9f25b5e5;p=photos diff --git a/src/main/java/org/wamblee/photos/security/PhotoAuthorizationRule.java b/src/main/java/org/wamblee/photos/security/PhotoAuthorizationRule.java index 0fab5c5..d772e1c 100644 --- a/src/main/java/org/wamblee/photos/security/PhotoAuthorizationRule.java +++ b/src/main/java/org/wamblee/photos/security/PhotoAuthorizationRule.java @@ -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