JSecurity

org.jsecurity.subject
Interface PrincipalCollection

All Superinterfaces:
Iterable, Serializable
All Known Subinterfaces:
MutablePrincipalCollection
All Known Implementing Classes:
SimplePrincipalCollection

public interface PrincipalCollection
extends Iterable, Serializable

A collection of all principals associated with a corresponding Subject.

Since:
0.9
Author:
Les Hazlewood

Method Summary
 List asList()
          Returns a single Subject's principals retrieved from all configured Realms as a List, or an empty List if there are not any principals.
 Set asSet()
          Returns a single Subject's principals retrieved from all configured Realms as a Set, or an empty Set if there are not any principals.
<T> Collection<T>
byType(Class<T> type)
          Returns all principals assignable from the specified type, or an empty Collection if no principals of that type are contained.
 Collection fromRealm(String realmName)
          Returns a single Subject's principals retrieved from the specified Realm only as a Collection, or an empty Collection if there are not any principals from that realm.
 Set<String> getRealmNames()
          Returns the realm names that this collection has principals for.
 boolean isEmpty()
          Returns true if this collection is empty, false otherwise.
<T> T
oneByType(Class<T> type)
          Returns a single principal assignable from the specified type, or null if there are none of the specified type.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

oneByType

<T> T oneByType(Class<T> type)
Returns a single principal assignable from the specified type, or null if there are none of the specified type.

Note that this would return null List always if the corresponding subject has not logged in.

Parameters:
type - the type of the principal that should be returned.
Returns:
a principal of the specified type or null if there isn't one of the specified type.

byType

<T> Collection<T> byType(Class<T> type)
Returns all principals assignable from the specified type, or an empty Collection if no principals of that type are contained.

Note that this would return an empty Collection always if the corresponding subject has not logged in.

Parameters:
type - the type of the principals that should be returned.
Returns:
a Collection of principals that are assignable from the specified type, or an empty Collection if no principals of this type are associated.

asList

List asList()
Returns a single Subject's principals retrieved from all configured Realms as a List, or an empty List if there are not any principals.

Note that this would return an empty List always if the corresponding subject has not logged in.

Returns:
a single Subject's principals retrieved from all configured Realms as a List.

asSet

Set asSet()
Returns a single Subject's principals retrieved from all configured Realms as a Set, or an empty Set if there are not any principals.

Note that this would return an empty Set always if the corresponding subject has not logged in.

Returns:
a single Subject's principals retrieved from all configured Realms as a Set.

fromRealm

Collection fromRealm(String realmName)
Returns a single Subject's principals retrieved from the specified Realm only as a Collection, or an empty Collection if there are not any principals from that realm.

Note that this would return an empty Collection always if the corresponding subject has not logged in.

Parameters:
realmName - the name of the Realm from which the principals were retrieved.
Returns:
the Subject's principals from the specified Realm only as a Collection or an empty Collection if there are not any principals from that realm.

getRealmNames

Set<String> getRealmNames()
Returns the realm names that this collection has principals for.

Returns:
the names of realms that this collection has one or more principals for.

isEmpty

boolean isEmpty()
Returns true if this collection is empty, false otherwise.

Returns:
true if this collection is empty, false otherwise.

JSecurity

Copyright © 2004-2008 JSecurity.