Package org.apache.shiro.realm.jndi
Class JndiRealmFactory
- java.lang.Object
-
- org.apache.shiro.jndi.JndiLocator
-
- org.apache.shiro.realm.jndi.JndiRealmFactory
-
- All Implemented Interfaces:
RealmFactory
public class JndiRealmFactory extends JndiLocator implements RealmFactory
Looks up one or more Realm instances from JNDI using specifiedjndiNames
.This is primarily provided to support Realm instances configured in JEE and EJB environments, but will work in any environment where
Realm
instances are bound in JNDI instead of using programmatic or text-based configuration.- Since:
- 0.9
-
-
Field Summary
-
Fields inherited from class org.apache.shiro.jndi.JndiLocator
CONTAINER_PREFIX
-
-
Constructor Summary
Constructors Constructor Description JndiRealmFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>
getJndiNames()
Returns the JNDI names that will be used to look up Realm(s) from JNDI.Collection<Realm>
getRealms()
Performs the JNDI lookups for each specifiedJNDI name
and returns all discovered Realms in an ordered collection.void
setJndiNames(String commaDelimited)
Specifies a comma-delimited list of JNDI names to lookup, each one corresponding to a jndi-boundRealm
.void
setJndiNames(Collection<String> jndiNames)
Sets the JNDI names that will be used to look up Realm(s) from JNDI.-
Methods inherited from class org.apache.shiro.jndi.JndiLocator
convertJndiName, getJndiEnvironment, getJndiTemplate, isResourceRef, lookup, lookup, setJndiEnvironment, setJndiTemplate, setResourceRef
-
-
-
-
Method Detail
-
getJndiNames
public Collection<String> getJndiNames()
Returns the JNDI names that will be used to look up Realm(s) from JNDI.- Returns:
- the JNDI names that will be used to look up Realm(s) from JNDI.
- See Also:
setJndiNames(String)
,setJndiNames(Collection)
-
setJndiNames
public void setJndiNames(Collection<String> jndiNames)
Sets the JNDI names that will be used to look up Realm(s) from JNDI. The order of the collection determines the order that the Realms will be returned to the SecurityManager. If you find it easier to specify these names as a comma-delmited string, you may use thesetJndiNames(String)
method instead.- Parameters:
jndiNames
- the JNDI names that will be used to look up Realm(s) from JNDI.- See Also:
setJndiNames(String)
-
setJndiNames
public void setJndiNames(String commaDelimited) throws IllegalStateException
Specifies a comma-delimited list of JNDI names to lookup, each one corresponding to a jndi-boundRealm
. The Realms will be made available to the SecurityManager in the order they are defined.- Parameters:
commaDelimited
- a comma-delimited list of JNDI names, each representing the JNDI name used to look up a corresponding jndi-bound Realm.- Throws:
IllegalStateException
- if the specified argument is null or the empty string.
-
getRealms
public Collection<Realm> getRealms() throws IllegalStateException
Performs the JNDI lookups for each specifiedJNDI name
and returns all discovered Realms in an ordered collection.The returned Collection is in the same order as the specified
jndiNames
- Specified by:
getRealms
in interfaceRealmFactory
- Returns:
- an ordered collection of the
specified Realms
found in JNDI. - Throws:
IllegalStateException
- if any of the JNDI names fails to successfully look up a Realm instance.
-
-