FileDocCategorySizeDatePackage
UnresolvedPrincipal.javaAPI DocAndroid 1.5 API4996Wed May 06 22:41:06 BST 2009org.apache.harmony.security

UnresolvedPrincipal

public final class UnresolvedPrincipal extends Object implements Principal
Descriptive implementation of Principal, which holds a name and a classname of unresolved principal. It is used to define an arbitrary Principal which may be not yet instantiated and authenticated.
This concept is somewhat similar to UnresolvedPermission. A principal-based policy may grant permissions depending on what Principals own the current execution thread. So the policy refers to this model definition of acceptable principal and compares it with the actual principal.
see
org.apache.harmony.security.PolicyEntry
see
org.apache.harmony.security.fortress.DefaultPolicy

Fields Summary
public static final String
WILDCARD
Wildcard value denotes any class and/or any name.
private final String
klass
private final String
name
Constructors Summary
public UnresolvedPrincipal(String klass, String name)
Constructs a a new definition of a Principal with specified parameters.

param
klass fully qualified class name, may be wildcard
param
name name of principal, may be wildcard
throws
IllegalArgumentException if klass value is null or is empty string


                                                    
         
        if (klass == null || klass.length() == 0) {
            throw new IllegalArgumentException(Messages.getString("security.91")); //$NON-NLS-1$
        }

        this.klass = klass;
        this.name = name;
    
Methods Summary
public booleanequals(java.lang.Object that)
Returns true if compared object is a Principal matching this definition, or if it is an UnresolvedPrincipal, which defines the same Principal; false otherwise.

        if (that instanceof UnresolvedPrincipal) {
            UnresolvedPrincipal up = (UnresolvedPrincipal) that;
            return klass.equals(up.klass)
                    && (name == null ? up.name == null : name.equals(up.name));
        }
        if (that instanceof Principal) {
            return implies((Principal) that);
        }
        return false;
    
public java.lang.StringgetClassName()
Returns fully qualified class name of a modeled Principal, or wildcard if any class is acceptable.

        return klass;
    
public java.lang.StringgetName()
Returns name of a modeled Principal, or wildcard if any name is acceptable.

        return name;
    
public inthashCode()
Returns the hash code value for this object.

        int hash = 0;
        if (name != null) {
            hash ^= name.hashCode();
        }
        if (klass != null) {
            hash ^= klass.hashCode();
        }
        return hash;
    
public booleanimplies(java.security.Principal another)
Returns true if compared object is a Principal exactly matching this definition. Namely, if the fully qualified name of class of passed Principal is equal to the class name value of this definition and the name of passed Principal is equal to the name value of this definition, or if this definition allows any class or name, respectively. Otherwise returns false .

        return (another != null)
                && (WILDCARD.equals(klass) 
                    || klass.equals(another.getClass().getName())
                && (WILDCARD.equals(name) 
                    || (name == null ? another.getName() == null 
                        : name.equals(another.getName()))));
    
public java.lang.StringtoString()
Returns a string describing this model of Principal. The format is 'Principal classname "name"'.

        return "Principal " + klass + " \"" + name + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$