org.apache.turbine.util.template
Class TemplateSecurityCheck

java.lang.Object
  extended byorg.apache.turbine.util.template.TemplateSecurityCheck

public class TemplateSecurityCheck
extends java.lang.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: TemplateSecurityCheck.java 534527 2007-05-02 16:10:59Z tv $
Author:
Dave Bryson, Henning P. Schmiedehausen

Constructor Summary
TemplateSecurityCheck(RunData data)
          Generic Constructor.
TemplateSecurityCheck(RunData data, java.lang.String message)
          Constructor.
 
Method Summary
 boolean checkLogin()
          Check that the user has logged in.
 java.lang.String getFailScreen()
          Get the value of failScreen.
 java.lang.String getFailTemplate()
          Get the value of failTemplate.
 java.lang.String getMessage()
          Get the message that should be displayed.
 boolean hasPermission(Permission permission)
          Does the User have this permission?
 boolean hasRole(Role role)
          Does the User have this role?
 void setFailScreen(java.lang.String v)
          Set the value of failScreen.
 void setFailTemplate(java.lang.String v)
          Set the value of failTemplate.
 void setMessage(java.lang.String v)
          Set the message that should be displayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateSecurityCheck

public TemplateSecurityCheck(RunData data,
                             java.lang.String message)
Constructor.

Parameters:
data - A Turbine RunData object.
message - A String with the message to display upon failure.

TemplateSecurityCheck

public TemplateSecurityCheck(RunData data)
Generic Constructor.

Parameters:
data - A Turbine RunData object.
Method Detail

hasRole

public boolean hasRole(Role role)
                throws java.lang.Exception
Does the User have this role?

Parameters:
role - The role to be checked.
Returns:
Whether the user has the role.
Throws:
java.lang.Exception - Trouble validating.

hasPermission

public boolean hasPermission(Permission permission)
                      throws java.lang.Exception
Does the User have this permission?

Parameters:
permission - The permission to be checked.
Returns:
Whether the user has the permission.
Throws:
java.lang.Exception - Trouble validating.

checkLogin

public boolean checkLogin()
                   throws java.lang.Exception
Check that the user has logged in.

Returns:
True if user has logged in.
Throws:
Exception, - a generic exception.
java.lang.Exception

setMessage

public void setMessage(java.lang.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 java.lang.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 java.lang.String getFailScreen()
Get the value of failScreen.

Returns:
A String with the value of failScreen.

setFailScreen

public void setFailScreen(java.lang.String v)
Set the value of failScreen.

Parameters:
v - A String with the value of failScreen.

getFailTemplate

public java.lang.String getFailTemplate()
Get the value of failTemplate.

Returns:
A String with the value of failTemplate.

setFailTemplate

public void setFailTemplate(java.lang.String v)
Set the value of failTemplate.

Parameters:
v - A String with the value of failTemplate.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.