FileDocCategorySizeDatePackage
MethodPermission.javaAPI DocGlassfish v2 API5118Fri May 04 22:31:22 BST 2007com.sun.enterprise.deployment

MethodPermission

public class MethodPermission extends Descriptor
Represents a method permission. A method permission can be associated to a role, be unchecked or excluded.
author
Jerome Dochez
version

Fields Summary
private static MethodPermission
unchecked
private static MethodPermission
excluded
private boolean
isUnchecked
private boolean
isExcluded
private com.sun.enterprise.deployment.Role
role
Constructors Summary
public MethodPermission(com.sun.enterprise.deployment.Role role)
construct a new MethodPermission based on a security role

param
role the security role associated to the method permission

    
                             
       
        this.role = role;
    
private MethodPermission()

    
Methods Summary
public booleanequals(java.lang.Object other)

	boolean ret = false;
	if(other instanceof MethodPermission) {
            MethodPermission o = (MethodPermission) other;
            if (isRoleBased()) {
	        ret = role.equals(o.getRole());
            } else {
                ret = (isExcluded == o.isExcluded()) && (isUnchecked == o.isUnchecked());
            }
	}	
	return ret;
    
public static com.sun.enterprise.deployment.MethodPermissiongetExcludedMethodPermission()

return
an ecluded method permission. Methods associated with such a method permission cannot be invoked by anyone.

        if (excluded==null) {
            excluded = new MethodPermission();
            excluded.isExcluded=true;   
        }
        return excluded;
    
public com.sun.enterprise.deployment.RolegetRole()

return
the security role associated with this method permission when applicable (role based method permission)

        return role;
    
public static com.sun.enterprise.deployment.MethodPermissiongetUncheckedMethodPermission()

return
an unchecked method permission. Methods associated with such a method permission can be invoked by anyone

        if (unchecked==null) {
            unchecked = new MethodPermission();
            unchecked.isUnchecked=true;   
        }
        return unchecked;
    
public inthashCode()

        if (role!=null)
            return role.hashCode();
        else
            return super.hashCode();
    
public booleanisExcluded()

return
true if the method permission is excluded

        return isExcluded;
    
public booleanisRoleBased()

return
true if the method permission is based on a security role

        return role!=null;
    
public booleanisUnchecked()

return
true if the method permission is unchecked

        return isUnchecked;
    
public voidprint(java.lang.StringBuffer toStringBuffer)

        if (isRoleBased()) {
            toStringBuffer.append(role.toString());
        } else {
            if (isExcluded) 
                toStringBuffer.append("excluded");
            else 
                toStringBuffer.append("unchecked");
        }