public class SimplePrincipalCollection extends Object implements MutablePrincipalCollection
MutablePrincipalCollection
interface that tracks principals internally
by storing them in a LinkedHashMap
.Constructor and Description |
---|
SimplePrincipalCollection() |
SimplePrincipalCollection(Collection principals,
String realmName) |
SimplePrincipalCollection(Object principal,
String realmName) |
SimplePrincipalCollection(PrincipalCollection principals) |
Modifier and Type | Method and Description |
---|---|
void |
add(Object principal,
String realmName)
Adds the given principal to this collection.
|
void |
addAll(Collection principals,
String realmName)
Adds all of the principals in the given collection to this collection.
|
void |
addAll(PrincipalCollection principals)
Adds all of the principals from the given principal collection to this collection.
|
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.
|
void |
clear()
Removes all Principals in this collection.
|
boolean |
equals(Object o) |
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.
|
Object |
getPrimaryPrincipal()
Returns the first available principal from any of the
Realm principals, or null if there are
no principals yet. |
protected Collection |
getPrincipalsLazy(String realmName) |
Set<String> |
getRealmNames()
Returns the realm names that this collection has principals for.
|
int |
hashCode() |
boolean |
isEmpty()
Returns
true if this collection is empty, false otherwise. |
Iterator |
iterator() |
<T> T |
oneByType(Class<T> type)
Returns the first discovered principal assignable from the specified type, or
null if there are none
of the specified type. |
String |
toString()
Returns a simple string representation suitable for printing.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public SimplePrincipalCollection()
public SimplePrincipalCollection(Object principal, String realmName)
public SimplePrincipalCollection(Collection principals, String realmName)
public SimplePrincipalCollection(PrincipalCollection principals)
protected Collection getPrincipalsLazy(String realmName)
public Object getPrimaryPrincipal()
Realm
principals, or null
if there are
no principals yet.
The 'first available principal' is interpreted as the principal that would be returned by
iterator()
.next()
.
getPrimaryPrincipal
in interface PrincipalCollection
public void add(Object principal, String realmName)
MutablePrincipalCollection
add
in interface MutablePrincipalCollection
principal
- the principal to be added.realmName
- the realm this principal came from.public void addAll(Collection principals, String realmName)
MutablePrincipalCollection
addAll
in interface MutablePrincipalCollection
principals
- the principals to be added.realmName
- the realm these principals came from.public void addAll(PrincipalCollection principals)
MutablePrincipalCollection
addAll
in interface MutablePrincipalCollection
principals
- the principals to add.public <T> T oneByType(Class<T> type)
PrincipalCollection
null
if there are none
of the specified type.
Note that this will return null
if the 'owning' subject has not yet logged in.oneByType
in interface PrincipalCollection
type
- the type of the principal that should be returned.null
if there isn't one of the specified type.public <T> Collection<T> byType(Class<T> type)
PrincipalCollection
byType
in interface PrincipalCollection
type
- the type of the principals that should be returned.public List asList()
PrincipalCollection
asList
in interface PrincipalCollection
public Set asSet()
PrincipalCollection
asSet
in interface PrincipalCollection
public Collection fromRealm(String realmName)
PrincipalCollection
fromRealm
in interface PrincipalCollection
realmName
- the name of the Realm from which the principals were retrieved.public Set<String> getRealmNames()
PrincipalCollection
getRealmNames
in interface PrincipalCollection
public boolean isEmpty()
PrincipalCollection
true
if this collection is empty, false
otherwise.isEmpty
in interface PrincipalCollection
true
if this collection is empty, false
otherwise.public void clear()
MutablePrincipalCollection
clear
in interface MutablePrincipalCollection
Copyright © 2004–2016 The Apache Software Foundation. All rights reserved.