// Path: app/controllers/deadbolt/DeadboltHandler.java
// public interface DeadboltHandler
// {
//     /**
//      * Invoked immediately before controller or view restrictions are checked.  This forms the integration with any
//      * authentication actions that may need to occur.
//      */
//     void beforeRoleCheck();
// 
//     /**
//      * Gets the current {@link RoleHolder}, e.g. the current user.
//      *
//      * @return the current role holder
//      */
//     RoleHolder getRoleHolder();
// 
//     /**
//      * Invoked when an access failure is detected on <i>controllerClassName</i>.
//      *
//      * @param controllerClassName the name of the controller access was denied to
//      */
//     void onAccessFailure(String controllerClassName);
// 
//     /**
//      * Gets the accessor used to determine restrictions from an external source.
//      *
//      * @return the accessor for externalised restrictions.  May be null.
//      */
//     ExternalizedRestrictionsAccessor getExternalizedRestrictionsAccessor();
// 
//     /**
//      * Gets the handler used for dealing with resources restricted to specific users/groups.
//      *
//      * @return the handler for restricted resources.  May be null.
//      */
//     RestrictedResourcesHandler getRestrictedResourcesHandler();
// }
// 
// Path: app/controllers/deadbolt/ExternalizedRestrictionsAccessor.java
// public interface ExternalizedRestrictionsAccessor
// {
//     ExternalizedRestrictions getExternalizedRestrictions(String name);
// }
// 
// Path: app/controllers/deadbolt/RestrictedResourcesHandler.java
// public interface RestrictedResourcesHandler
// {
//     /**
//      * Check the access of someone, typically the current user, for the named resource.
//      *
//      * <ul>
//      * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and
//      * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is false, access is denied.</li>
//      * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and
//      * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is true, any further Restrict or
//      * Restrictions annotations are processed.  Note that if no Restrict or Restrictions annotations are present,
//      * access will be allowed.</li>
//      * </ul>
//      *
//      * @param resourceNames the names of the resource
//      * @param resourceParameters additional information on the resource
//      * @return {@link AccessResult#ALLOWED} if access is permitted.  {@link AccessResult#DENIED} if access is denied.
//      * {@link AccessResult#NOT_SPECIFIED} if access is not specified.
//      */
//     AccessResult checkAccess(List<String> resourceNames,
//                              Map<String, String> resourceParameters);
// }
// 
// Path: samples-and-tests/acl/app/model/AclUser.java
// @Entity
// public class AclUser extends Model implements RoleHolder
// {
//     @Required
//     public String userName;
// 
//     public String fullName;
// 
//     @Required
//     @ManyToOne
//     public AclApplicationRole role;
// 
//     @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE, CascadeType.DETACH})
//     public List<AclUser> friends;
// 
//     @ManyToMany(cascade = CascadeType.ALL)
//     public List<Photo> photos;
// 
//     @ManyToMany(cascade = CascadeType.ALL)
//     public List<StatusUpdate> statusUpdates;
// 
//     @OneToOne(cascade = CascadeType.ALL)
//     public AccessControlPreference accessControlPreference;
// 
//     public AclUser(String userName,
//                    String fullName,
//                    AclApplicationRole role)
//     {
//         this.userName = userName;
//         this.fullName = fullName;
//         this.role = role;
//         this.accessControlPreference = new AccessControlPreference();
//     }
// 
//     public static AclUser getByUserName(String userName)
//     {
//         return find("byUserName", userName).first();
//     }
// 
//     public List<? extends Role> getRoles()
//     {
//         return Arrays.asList(role);
//     }
// 
//     public void addPhoto(Photo photo)
//     {
//         if (photos == null)
//         {
//             photos = new ArrayList<Photo>();
//         }
//         photos.add(photo);
//     }
// 
//     public void addStatusUpdate(StatusUpdate statusUpdate)
//     {
//         if (statusUpdates == null)
//         {
//             statusUpdates = new ArrayList<StatusUpdate>();
//         }
//         statusUpdates.add(statusUpdate);
//     }
// 
//     public void addFriend(AclUser friend)
//     {
//         if (friends == null)
//         {
//             friends = new ArrayList<AclUser>();
//         }
//         friends.add(friend);
//     }
// 
//     public boolean isFriend(AclUser user)
//     {
//         return friends != null && friends.contains(user);
//     }
// 
//     @Override
//     public String toString()
//     {
//         return this.userName;
//     }
// }
// 
// Path: app/models/deadbolt/ExternalizedRestrictions.java
// public interface ExternalizedRestrictions
// {
//     /**
//      * Gets all the {@link ExternalizedRestriction}s associated with a target.
//      *
//      * @return
//      */
//     List<ExternalizedRestriction> getExternalisedRestrictions();
// }
// 
// Path: app/models/deadbolt/RoleHolder.java
// public interface RoleHolder
// {
//     /**
//      * A list of {@link Role}s held by the role holder.
//      *
//      * @return a list of roles
//      */
//     List<? extends Role> getRoles();
// }


import controllers.deadbolt.DeadboltHandler;
import controllers.deadbolt.ExternalizedRestrictionsAccessor;
import controllers.deadbolt.RestrictedResourcesHandler;
import model.AclUser;
import models.deadbolt.ExternalizedRestrictions;
import models.deadbolt.RoleHolder;
import play.mvc.Controller;
            {
                // handle this in an app-specific way
            }
        }
    }

    public RoleHolder getRoleHolder()
    {
        String userName = Secure.Security.connected();
        return AclUser.getByUserName(userName);
    }

    public void onAccessFailure(String controllerClassName)
    {
       forbidden();
    }

    public ExternalizedRestrictionsAccessor getExternalizedRestrictionsAccessor()
    {
        return new ExternalizedRestrictionsAccessor()
        {
            public ExternalizedRestrictions getExternalizedRestrictions(String name)
            {
                return null;
            }
        };
    }

    public RestrictedResourcesHandler getRestrictedResourcesHandler()
    {
// Path: app/controllers/deadbolt/DeadboltHandler.java
// public interface DeadboltHandler
// {
//     /**
//      * Invoked immediately before controller or view restrictions are checked.  This forms the integration with any
//      * authentication actions that may need to occur.
//      */
//     void beforeRoleCheck();
// 
//     /**
//      * Gets the current {@link RoleHolder}, e.g. the current user.
//      *
//      * @return the current role holder
//      */
//     RoleHolder getRoleHolder();
// 
//     /**
//      * Invoked when an access failure is detected on <i>controllerClassName</i>.
//      *
//      * @param controllerClassName the name of the controller access was denied to
//      */
//     void onAccessFailure(String controllerClassName);
// 
//     /**
//      * Gets the accessor used to determine restrictions from an external source.
//      *
//      * @return the accessor for externalised restrictions.  May be null.
//      */
//     ExternalizedRestrictionsAccessor getExternalizedRestrictionsAccessor();
// 
//     /**
//      * Gets the handler used for dealing with resources restricted to specific users/groups.
//      *
//      * @return the handler for restricted resources.  May be null.
//      */
//     RestrictedResourcesHandler getRestrictedResourcesHandler();
// }
// 
// Path: app/controllers/deadbolt/ExternalizedRestrictionsAccessor.java
// public interface ExternalizedRestrictionsAccessor
// {
//     ExternalizedRestrictions getExternalizedRestrictions(String name);
// }
// 
// Path: app/controllers/deadbolt/RestrictedResourcesHandler.java
// public interface RestrictedResourcesHandler
// {
//     /**
//      * Check the access of someone, typically the current user, for the named resource.
//      *
//      * <ul>
//      * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and
//      * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is false, access is denied.</li>
//      * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and
//      * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is true, any further Restrict or
//      * Restrictions annotations are processed.  Note that if no Restrict or Restrictions annotations are present,
//      * access will be allowed.</li>
//      * </ul>
//      *
//      * @param resourceNames the names of the resource
//      * @param resourceParameters additional information on the resource
//      * @return {@link AccessResult#ALLOWED} if access is permitted.  {@link AccessResult#DENIED} if access is denied.
//      * {@link AccessResult#NOT_SPECIFIED} if access is not specified.
//      */
//     AccessResult checkAccess(List<String> resourceNames,
//                              Map<String, String> resourceParameters);
// }
// 
// Path: samples-and-tests/acl/app/model/AclUser.java
// @Entity
// public class AclUser extends Model implements RoleHolder
// {
//     @Required
//     public String userName;
// 
//     public String fullName;
// 
//     @Required
//     @ManyToOne
//     public AclApplicationRole role;
// 
//     @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE, CascadeType.DETACH})
//     public List<AclUser> friends;
// 
//     @ManyToMany(cascade = CascadeType.ALL)
//     public List<Photo> photos;
// 
//     @ManyToMany(cascade = CascadeType.ALL)
//     public List<StatusUpdate> statusUpdates;
// 
//     @OneToOne(cascade = CascadeType.ALL)
//     public AccessControlPreference accessControlPreference;
// 
//     public AclUser(String userName,
//                    String fullName,
//                    AclApplicationRole role)
//     {
//         this.userName = userName;
//         this.fullName = fullName;
//         this.role = role;
//         this.accessControlPreference = new AccessControlPreference();
//     }
// 
//     public static AclUser getByUserName(String userName)
//     {
//         return find("byUserName", userName).first();
//     }
// 
//     public List<? extends Role> getRoles()
//     {
//         return Arrays.asList(role);
//     }
// 
//     public void addPhoto(Photo photo)
//     {
//         if (photos == null)
//         {
//             photos = new ArrayList<Photo>();
//         }
//         photos.add(photo);
//     }
// 
//     public void addStatusUpdate(StatusUpdate statusUpdate)
//     {
//         if (statusUpdates == null)
//         {
//             statusUpdates = new ArrayList<StatusUpdate>();
//         }
//         statusUpdates.add(statusUpdate);
//     }
// 
//     public void addFriend(AclUser friend)
//     {
//         if (friends == null)
//         {
//             friends = new ArrayList<AclUser>();
//         }
//         friends.add(friend);
//     }
// 
//     public boolean isFriend(AclUser user)
//     {
//         return friends != null && friends.contains(user);
//     }
// 
//     @Override
//     public String toString()
//     {
//         return this.userName;
//     }
// }
// 
// Path: app/models/deadbolt/ExternalizedRestrictions.java
// public interface ExternalizedRestrictions
// {
//     /**
//      * Gets all the {@link ExternalizedRestriction}s associated with a target.
//      *
//      * @return
//      */
//     List<ExternalizedRestriction> getExternalisedRestrictions();
// }
// 
// Path: app/models/deadbolt/RoleHolder.java
// public interface RoleHolder
// {
//     /**
//      * A list of {@link Role}s held by the role holder.
//      *
//      * @return a list of roles
//      */
//     List<? extends Role> getRoles();
// }


// Path: samples-and-tests/acl/app/controllers/AclDeadboltHandler.java
import controllers.deadbolt.DeadboltHandler;
import controllers.deadbolt.ExternalizedRestrictionsAccessor;
import controllers.deadbolt.RestrictedResourcesHandler;
import model.AclUser;
import models.deadbolt.ExternalizedRestrictions;
import models.deadbolt.RoleHolder;
import play.mvc.Controller;

            {
                // handle this in an app-specific way
            }
        }
    }

    public RoleHolder getRoleHolder()
    {
        String userName = Secure.Security.connected();
        return AclUser.getByUserName(userName);
    }

    public void onAccessFailure(String controllerClassName)
    {
       forbidden();
    }

    public ExternalizedRestrictionsAccessor getExternalizedRestrictionsAccessor()
    {
        return new ExternalizedRestrictionsAccessor()
        {
            public ExternalizedRestrictions getExternalizedRestrictions(String name)
            {
                return null;
            }
        };
    }

    public RestrictedResourcesHandler getRestrictedResourcesHandler()
    {
        return RESTRICTED_RESOURCES_HANDLER;