Class TemplateSecurityCheck


  • public class TemplateSecurityCheck
    extends Object
    Utility class to help check for proper authorization when using template screens. Sample usages:
     TemplateSecurityCheck secCheck = new TemplateSecurityCheck( data );
     secCheck.setMessage( "Sorry, you do not have permission to " +
                          "access this area." );
     secCheck.setFailTemplate("login.wm");
     if ( !secCheck.hasRole("ADMIN") )
         return;
     
    Version:
    $Id$
    Author:
    Dave Bryson, Henning P. Schmiedehausen
    • Constructor Detail

      • TemplateSecurityCheck

        public TemplateSecurityCheck​(PipelineData pipelineData,
                                     String message)
        Constructor.
        Parameters:
        pipelineData - A Turbine PipelineData object.
        message - A String with the message to display upon failure.
    • Method Detail

      • hasRole

        public boolean hasRole​(org.apache.fulcrum.security.entity.Role role)
                        throws Exception
        Does the User have this role?
        Parameters:
        role - The role to be checked.
        Returns:
        Whether the user has the role.
        Throws:
        Exception - Trouble validating.
      • hasPermission

        public boolean hasPermission​(org.apache.fulcrum.security.entity.Permission permission)
                              throws Exception
        Does the User have this permission?
        Parameters:
        permission - The permission to be checked.
        Returns:
        Whether the user has the permission.
        Throws:
        Exception - Trouble validating.
      • checkLogin

        public boolean checkLogin()
                           throws Exception
        Check that the user has logged in.
        Returns:
        True if user has logged in.
        Throws:
        Exception - a generic exception.
      • setMessage

        public void setMessage​(String v)
        Set the message that should be displayed. This is initialized in the constructor.
        Parameters:
        v - A String with the message that should be displayed.
      • getMessage

        public String getMessage()
        Get the message that should be displayed. This is initialized in the constructor.
        Returns:
        A String with the message that should be displayed.
      • getFailScreen

        public String getFailScreen()
        Get the value of failScreen.
        Returns:
        A String with the value of failScreen.
      • setFailScreen

        public void setFailScreen​(String v)
        Set the value of failScreen.
        Parameters:
        v - A String with the value of failScreen.
      • getFailTemplate

        public String getFailTemplate()
        Get the value of failTemplate.
        Returns:
        A String with the value of failTemplate.
      • setFailTemplate

        public void setFailTemplate​(String v)
        Set the value of failTemplate.
        Parameters:
        v - A String with the value of failTemplate.