java.rmi.constraint
Class ClientMaxPrincipal

java.lang.Object
  |
  +--java.rmi.constraint.ClientMaxPrincipal
All Implemented Interfaces:
SecurityConstraint, java.io.Serializable

public final class ClientMaxPrincipal
extends java.lang.Object
implements SecurityConstraint, java.io.Serializable

Represents a constraint on the client, such that if the client authenticates itself, then it may only authenticate itself as one or more of the specified principals. A client can use this to limit how much of its identity is exposed in remote calls.

The use of an instance of this constraint does not directly imply a ClientAuthentication.YES constraint; that must be specified separately to ensure that the client actually authenticates itself.

Since:
1.4
See Also:
AuthenticationPermission, Serialized Form

Constructor Summary
ClientMaxPrincipal(java.util.Collection c)
          Creates a constraint containing the specified principals, with duplicates removed.
ClientMaxPrincipal(java.security.Principal p)
          Creates a constraint containing the specified principal.
ClientMaxPrincipal(java.security.Principal[] principals)
          Creates a constraint containing the specified principals, with duplicates removed.
 
Method Summary
 java.util.Set elements()
          Returns an immutable set of all of the principals.
 boolean equals(java.lang.Object obj)
          Two instances of this class are equal if they have the same principals (ignoring order).
 int hashCode()
          Returns a hash code value for this object.
 SecurityConstraint reduceBy(SecurityConstraint c)
          Returns the smallest representable subset of this constraint that contains the intersection of this constraint with the specified constraint, or null if there is no intersection.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientMaxPrincipal

public ClientMaxPrincipal(java.security.Principal p)
Creates a constraint containing the specified principal. This constructor is equivalent to calling a constructor with a single-element array containing the specified principal.
Parameters:
p - the principal
Throws:
java.lang.IllegalArgumentException - if the parameter is not an instance of a trusted principal class
NullPointerException - if the parameter is null

ClientMaxPrincipal

public ClientMaxPrincipal(java.security.Principal[] principals)
Creates a constraint containing the specified principals, with duplicates removed. The parameter passed to the constructor is neither modified nor retained; subsequent changes to that parameter have no effect on the instance created.
Parameters:
principals - the principals
Throws:
java.lang.IllegalArgumentException - if the parameter is empty or the elements are not all instances of trusted principal classes
NullPointerException - if the parameter is null or any element is null

ClientMaxPrincipal

public ClientMaxPrincipal(java.util.Collection c)
Creates a constraint containing the specified principals, with duplicates removed. The parameter passed to the constructor is neither modified nor retained; subsequent changes to that parameter have no effect on the instance created.
Parameters:
c - the principals
Throws:
java.lang.IllegalArgumentException - if the parameter is empty or the elements are not all instances of trusted principal classes
NullPointerException - if the parameter is null or any element is null
Method Detail

elements

public java.util.Set elements()
Returns an immutable set of all of the principals. Any attempt to modify the set results in an UnsupportedOperationException being thrown.
Returns:
an immutable set of all of the principals

reduceBy

public SecurityConstraint reduceBy(SecurityConstraint c)
Returns the smallest representable subset of this constraint that contains the intersection of this constraint with the specified constraint, or null if there is no intersection.

For any instances c1 and c2 of this class, c1.reduceBy(c2) returns a ClientMaxPrincipal constructed from the principals common to both c1 and c2, or null if there are no principals in common.

For any instance c1 of this class and any ClientMaxPrincipalType instance c2, c1.reduceBy(c2) returns a ClientMaxPrincipal constructed from the principals of c1 that are instances of at least one of the classes in c2, or null if there are no such principals.

For any instance c1 of this class and any ClientMinPrincipal instance c2, c1.reduceBy(c2) returns null if the principals in c2 are not a subset of the principals in c1, and returns c1 otherwise.

For any instance c1 of this class and any ClientMinPrincipalType instance c2, c1.reduceBy(c2) returns null if there exists a class in c2 such that no principal in c1 is an instance of that class, and returns c1 otherwise.

For any instance c of this class, c.reduceBy(ClientAuthentication.NO) returns ClientAuthentication.NO.

For any instance c1 of this class and any ConstraintAlternatives instance c2 containing ClientMaxPrincipal or ClientMaxPrincipalType instances, c1.reduceBy(c2) returns the result of calling ConstraintAlternatives.create with all of the non-null values returned by c1.reduceBy(c) for each element c of c2, or null if there are no non-null values.

For any instance c1 of this class and any ConstraintAlternatives instance c2 containing ClientMinPrincipal or ClientMinPrincipalType instances, c1.reduceBy(c2) returns null if c1.reduceBy(c) returns null for every element c of c2, and returns c1 otherwise.

For any instance c1 of this class and any other constraint instance c2 not previously mentioned, c1.reduceBy(c2) returns c1.

Specified by:
reduceBy in interface SecurityConstraint
Following copied from interface: java.rmi.constraint.SecurityConstraint
Parameters:
c - a constraint
Returns:
the smallest representable subset of this constraint that intersects with the specified constraint, or null if there is no intersection

hashCode

public int hashCode()
Returns a hash code value for this object.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Two instances of this class are equal if they have the same principals (ignoring order).
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object


Copyright © 2000 Sun Microsystems, Inc. All rights reserved