net.jini.core.constraint
Class ClientMaxPrincipal

java.lang.Object
  extended by net.jini.core.constraint.ClientMaxPrincipal
All Implemented Interfaces:
Serializable, InvocationConstraint

public final class ClientMaxPrincipal
extends Object
implements InvocationConstraint, 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. The mechanisms and credentials used to authenticate the client as those principals are not specified by this constraint. A client can use this constraint to limit how much of its identity is exposed in remote calls. For example, if the client's subject contains sufficient information to authenticate as two distinct principals, the client might wish to limit authentication to just one of the two, if the client believes the other is unnecessary for authorization at the server and wants to avoid revealing that part of its identity to the server.

The use of an instance of this class does not directly imply a ClientAuthentication.YES constraint; that must be specified separately to ensure that the client actually authenticates itself. Because this constraint is conditional on client authentication, it does not conflict with ClientAuthentication.NO.

Since:
2.0
Author:
Sun Microsystems, Inc.
See Also:
ClientAuthentication, ClientMaxPrincipalType, ClientMinPrincipal, ClientMinPrincipalType, AuthenticationPermission, Serialized Form

Field Summary
private  Principal[] principals
          The principals.
private static ObjectStreamField[] serialPersistentFields
           
private static long serialVersionUID
           
 
Constructor Summary
ClientMaxPrincipal(Collection c)
          Creates a constraint containing the specified principals, with duplicates removed.
ClientMaxPrincipal(Principal p)
          Creates a constraint containing the specified principal.
ClientMaxPrincipal(Principal[] principals)
          Creates a constraint containing the specified principals, with duplicates removed.
 
Method Summary
 Set elements()
          Returns an immutable set of all of the principals.
 boolean equals(Object obj)
          Two instances of this class are equal if they have the same principals (ignoring order).
(package private)  Principal[] getPrincipals()
          Returns the principals, without copying.
 int hashCode()
          Returns a hash code value for this object.
private  void readObject(ObjectInputStream s)
          Verifies that there is at least one principal, that none of the principals is null, and that there are no duplicates.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

serialPersistentFields

private static final ObjectStreamField[] serialPersistentFields

principals

private final Principal[] principals
The principals.

Constructor Detail

ClientMaxPrincipal

public ClientMaxPrincipal(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:
NullPointerException - if the argument is null

ClientMaxPrincipal

public ClientMaxPrincipal(Principal[] principals)
Creates a constraint containing the specified principals, with duplicates removed. The argument passed to the constructor is neither modified nor retained; subsequent changes to that argument have no effect on the instance created.

Parameters:
principals - the principals
Throws:
IllegalArgumentException - if the argument is empty
NullPointerException - if the argument is null or any element is null

ClientMaxPrincipal

public ClientMaxPrincipal(Collection c)
Creates a constraint containing the specified principals, with duplicates removed. The argument passed to the constructor is neither modified nor retained; subsequent changes to that argument have no effect on the instance created.

Parameters:
c - the principals
Throws:
IllegalArgumentException - if the argument is empty or the elements do not all implement the Principal interface
NullPointerException - if the argument is null or any element is null
Method Detail

elements

public 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

getPrincipals

Principal[] getPrincipals()
Returns the principals, without copying.


hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object

equals

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

Overrides:
equals in class Object

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

readObject

private void readObject(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
Verifies that there is at least one principal, that none of the principals is null, and that there are no duplicates.

Throws:
InvalidObjectException - if there are no principals, or any principal is null, or if there are duplicate principals
IOException
ClassNotFoundException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.