org.apache.shiro.realm.jndi
Class JndiRealmFactory

java.lang.Object
  extended by org.apache.shiro.jndi.JndiLocator
      extended by 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 specified jndiNames.

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
JndiRealmFactory()
           
 
Method Summary
 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 specified JNDI name and returns all discovered Realms in an ordered collection.
 void setJndiNames(Collection<String> jndiNames)
          Sets the JNDI names that will be used to look up Realm(s) from JNDI.
 void setJndiNames(String commaDelimited)
          Specifies a comma-delimited list of JNDI names to lookup, each one corresponding to a jndi-bound Realm.
 
Methods inherited from class org.apache.shiro.jndi.JndiLocator
convertJndiName, getJndiEnvironment, getJndiTemplate, isResourceRef, lookup, lookup, setJndiEnvironment, setJndiTemplate, setResourceRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiRealmFactory

public JndiRealmFactory()
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 the setJndiNames(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-bound Realm. 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 specified JNDI 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 interface RealmFactory
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.


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.