org.ow2.jonas.security.internal.realm.factory
Class JResourceLDAP

java.lang.Object
  extended by org.ow2.jonas.lib.management.javaee.ManagedObject
      extended by org.ow2.jonas.security.internal.realm.factory.AbstractJResource
          extended by org.ow2.jonas.security.internal.realm.factory.JResourceLDAP
All Implemented Interfaces:
Serializable, Referenceable, JResource

public class JResourceLDAP
extends AbstractJResource

This class extends the JResource class for the LDAP implementation.

Author:
Florent Benoit, Emmanuel Rias (12/03 some improvements)
See Also:
Serialized Form

Constructor Summary
JResourceLDAP()
          Constructor : use the super constructor
 
Method Summary
 JUser findUser(String username)
          Check if a user is found and return it
 String getAlgorithm()
          Get the default algorithm
 ArrayList getArrayListCombinedRoles(JUser user)
          Get all the roles (from the roles and from the groups) of the given user
 String getAuthenticationMode()
          Get the mode for validate the authentication of this LDAP realm
 String getBaseDN()
          Get the DN used for the lookup of this LDAP realm
protected  DirContext getDirContext()
          Return a dircontext for this LDAP server
 String getInitialContextFactory()
          Return the initial context factory of this LDAP realm
 String getLanguage()
          Get the preferred language to use with the service of this LDAP realm
 String getProviderUrl()
          Get the Url of the ldap server of this LDAP realm
 Reference getReference()
          Retrieves the Reference of the object.
 String getReferral()
          Get how referrals encountered by the service provider are to be processed
 String getRoleDN()
          Get the DN used when searching the role DN.
 String getRoleNameAttribute()
          Get the role name when performing a lookup on a role
 String getRoleSearchFilter()
          Get the filter used when searching the role
 String getSecurityAuthentication()
          Get the authentication used during the authentication to the LDAP server of this LDAP realm
 String getSecurityCredentials()
          Get the Credential(password) of the principal of this LDAP realm
 String getSecurityPrincipal()
          Get the DN of the Principal(username) of this LDAP realm
 String getSecurityProtocol()
          Get the security protocol to use of this LDAP realm
 String getStateFactories()
          Get the the list of state factories of this LDAP realm
 String getUserDN()
          Get the DN used when searching the user DN.
 String getUserPasswordAttribute()
          Get the attribute in order to get the password of this LDAP realm
 String getUserRolesAttribute()
          Get the attribute in order to get the user role from the ldap server
 String getUserSearchFilter()
          Get the filter used when searching the user
 boolean isValidUser(JUser user, String credentials)
          Check if the given user with the given credential is a valid user
 boolean isValidUserBind(JUser user, String credentials)
          Check if the given user with the given credential is a valid user.
 boolean isValidUserCompare(JUser user, String credentials)
          Check if the given user with the given credential is a valid user.
 void removeMBeans()
          Remove all the Mbeans used by this resource
 void setAlgorithm(String algorithm)
          Set the default algorithm to use
 void setAuthenticationMode(String authenticationMode)
          Set the mode for validate the authentication of this LDAP realm
 void setBaseDN(String baseDN)
          Set the DN used for the lookup of this LDAP realm
 void setInitialContextFactory(String initialContextFactory)
          Set the initial context factory of this LDAP realm
 void setLanguage(String language)
          Set the preferred language to use with the service of this LDAP realm
 void setProviderUrl(String providerUrl)
          Set the Url of the ldap server of this LDAP realm
 void setReferral(String referral)
          Set how referrals encountered by the service provider are to be processed
 void setRoleDN(String roleDN)
          Set the DN used when searching the role DN.
 void setRoleNameAttribute(String roleNameAttribute)
          Set the role name when performing a lookup on a role
 void setRoleSearchFilter(String roleSearchFilter)
          Set the filter used when searching the role
 void setSecurityAuthentication(String securityAuthentication)
          Set the authentication used during the authentication to the LDAP server of this LDAP realm
 void setSecurityCredentials(String securityCredentials)
          Set the Credential(password) of the principal of this LDAP realm
 void setSecurityPrincipal(String securityPrincipal)
          Set the DN of the Principal(username) of this LDAP realm
 void setSecurityProtocol(String securityProtocol)
          Set the security protocol to use of this LDAP realm
 void setStateFactories(String stateFactories)
          Set the the list of state factories of this LDAP realm
 void setUserDN(String userDN)
          Set the DN used when searching the user DN.
 void setUserPasswordAttribute(String userPasswordAttribute)
          Set the attribute in order to get the password of this LDAP realm
 void setUserRolesAttribute(String userRolesAttribute)
          Set the attribute in order to get the user role from the ldap server
 void setUserSearchFilter(String userSearchFilter)
          Set the filter used when searching the user
 String toString()
          The string representation of this object is an XML value
 String toXML()
          String representation of the LDAP realm
 
Methods inherited from class org.ow2.jonas.security.internal.realm.factory.AbstractJResource
clearCache, getLogger, getName, getSequenceNumber, getUsers, registerGroupMBean, registerRoleMBean, registerUserMBean, saveConfig, setDomainName, setJmxService, setLogger, setName, setSecurityService, setUsers, unregisterGroupMBean, unregisterRoleMBean, unregisterUserMBean
 
Methods inherited from class org.ow2.jonas.lib.management.javaee.ManagedObject
getModelMBean, sendNotification, sendReconfigNotification, sendSaveNotification, setModelMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JResourceLDAP

public JResourceLDAP()
              throws Exception
Constructor : use the super constructor

Throws:
Exception - if the super constructor fail
Method Detail

findUser

public JUser findUser(String username)
               throws JResourceException
Check if a user is found and return it

Parameters:
username - the wanted user name
Returns:
the user found or null
Throws:
JResourceException - if there is a NamingException

isValidUser

public boolean isValidUser(JUser user,
                           String credentials)
Check if the given user with the given credential is a valid user

Parameters:
user - the given user
credentials - credential of the user
Returns:
true if the user is valid

isValidUserBind

public boolean isValidUserBind(JUser user,
                               String credentials)
Check if the given user with the given credential is a valid user. Check is done by binding to the LDAP server with the specific principal/credential.

Parameters:
user - the given user
credentials - credential of the user
Returns:
true if the user is valid

isValidUserCompare

public boolean isValidUserCompare(JUser user,
                                  String credentials)
Check if the given user with the given credential is a valid user. Check is done by comparing the given credential with the credential which is retrieved from the LDAP server.

Parameters:
user - the given user
credentials - credential of the user
Returns:
true if the user is valid

getArrayListCombinedRoles

public ArrayList getArrayListCombinedRoles(JUser user)
                                    throws JResourceException
Get all the roles (from the roles and from the groups) of the given user

Parameters:
user - the given user
Returns:
the array list of all the roles for a given user
Throws:
JResourceException - if there is a naming exception

toXML

public String toXML()
String representation of the LDAP realm

Returns:
the xml representation of the LDAP realm

toString

public String toString()
The string representation of this object is an XML value

Overrides:
toString in class Object
Returns:
the xml representation of this object

getReference

public Reference getReference()
                       throws NamingException
Retrieves the Reference of the object. The Reference contains the factory used to create this object and the optional parameters used to configure the factory.

Returns:
the non-null Reference of the object.
Throws:
NamingException - if a naming exception was encountered while retrieving the reference.

setInitialContextFactory

public void setInitialContextFactory(String initialContextFactory)
Set the initial context factory of this LDAP realm

Parameters:
initialContextFactory - the initial context factory

setProviderUrl

public void setProviderUrl(String providerUrl)
Set the Url of the ldap server of this LDAP realm

Parameters:
providerUrl - Url of the ldap server

setSecurityAuthentication

public void setSecurityAuthentication(String securityAuthentication)
Set the authentication used during the authentication to the LDAP server of this LDAP realm

Parameters:
securityAuthentication - authentication used during the authentication to the LDAP server

setSecurityPrincipal

public void setSecurityPrincipal(String securityPrincipal)
Set the DN of the Principal(username) of this LDAP realm

Parameters:
securityPrincipal - DN of the Principal(username)

setSecurityCredentials

public void setSecurityCredentials(String securityCredentials)
Set the Credential(password) of the principal of this LDAP realm

Parameters:
securityCredentials - Credential(password) of the principal

setSecurityProtocol

public void setSecurityProtocol(String securityProtocol)
Set the security protocol to use of this LDAP realm

Parameters:
securityProtocol - security protocol to use

setLanguage

public void setLanguage(String language)
Set the preferred language to use with the service of this LDAP realm

Parameters:
language - preferred language to use with the service

setReferral

public void setReferral(String referral)
Set how referrals encountered by the service provider are to be processed

Parameters:
referral - how referrals encountered by the service provider are to be processed

setStateFactories

public void setStateFactories(String stateFactories)
Set the the list of state factories of this LDAP realm

Parameters:
stateFactories - list of state factories

setAuthenticationMode

public void setAuthenticationMode(String authenticationMode)
Set the mode for validate the authentication of this LDAP realm

Parameters:
authenticationMode - BIND_AUTHENTICATION_MODE or COMPARE_AUTHENTICATION_MODE

setUserPasswordAttribute

public void setUserPasswordAttribute(String userPasswordAttribute)
Set the attribute in order to get the password of this LDAP realm

Parameters:
userPasswordAttribute - attribute in order to get the password of this LDAP realm

setUserRolesAttribute

public void setUserRolesAttribute(String userRolesAttribute)
Set the attribute in order to get the user role from the ldap server

Parameters:
userRolesAttribute - attribute in order to get the user role from the ldap server

setRoleNameAttribute

public void setRoleNameAttribute(String roleNameAttribute)
Set the role name when performing a lookup on a role

Parameters:
roleNameAttribute - role name when performing a lookup on a role

setBaseDN

public void setBaseDN(String baseDN)
Set the DN used for the lookup of this LDAP realm

Parameters:
baseDN - DN used for the lookup

setUserDN

public void setUserDN(String userDN)
Set the DN used when searching the user DN. Override the baseDN if it is defined

Parameters:
userDN - DN used when searching the user DN

setUserSearchFilter

public void setUserSearchFilter(String userSearchFilter)
Set the filter used when searching the user

Parameters:
userSearchFilter - filter used when searching the user

setRoleDN

public void setRoleDN(String roleDN)
Set the DN used when searching the role DN. Override the baseDN if it is defined

Parameters:
roleDN - DN used when searching the role DN. Override the baseDN if it is defined

setRoleSearchFilter

public void setRoleSearchFilter(String roleSearchFilter)
Set the filter used when searching the role

Parameters:
roleSearchFilter - filter used when searching the role

setAlgorithm

public void setAlgorithm(String algorithm)
Set the default algorithm to use

Parameters:
algorithm - algorithm to be used

getInitialContextFactory

public String getInitialContextFactory()
Return the initial context factory of this LDAP realm

Returns:
the initial context factory

getProviderUrl

public String getProviderUrl()
Get the Url of the ldap server of this LDAP realm

Returns:
Url of the ldap server

getSecurityAuthentication

public String getSecurityAuthentication()
Get the authentication used during the authentication to the LDAP server of this LDAP realm

Returns:
authentication used during the authentication to the LDAP server

getSecurityPrincipal

public String getSecurityPrincipal()
Get the DN of the Principal(username) of this LDAP realm

Returns:
DN of the Principal(username)

getSecurityCredentials

public String getSecurityCredentials()
Get the Credential(password) of the principal of this LDAP realm

Returns:
Credential(password) of the principal

getSecurityProtocol

public String getSecurityProtocol()
Get the security protocol to use of this LDAP realm

Returns:
security protocol to use

getLanguage

public String getLanguage()
Get the preferred language to use with the service of this LDAP realm

Returns:
language preferred language to use with the service

getReferral

public String getReferral()
Get how referrals encountered by the service provider are to be processed

Returns:
how referrals encountered by the service provider are to be processed

getStateFactories

public String getStateFactories()
Get the the list of state factories of this LDAP realm

Returns:
list of state factories

getAuthenticationMode

public String getAuthenticationMode()
Get the mode for validate the authentication of this LDAP realm

Returns:
BIND_AUTHENTICATION_MODE or COMPARE_AUTHENTICATION_MODE

getUserPasswordAttribute

public String getUserPasswordAttribute()
Get the attribute in order to get the password of this LDAP realm

Returns:
attribute in order to get the password of this LDAP realm

getUserRolesAttribute

public String getUserRolesAttribute()
Get the attribute in order to get the user role from the ldap server

Returns:
attribute in order to get the user role from the ldap server

getRoleNameAttribute

public String getRoleNameAttribute()
Get the role name when performing a lookup on a role

Returns:
role name when performing a lookup on a role

getBaseDN

public String getBaseDN()
Get the DN used for the lookup of this LDAP realm

Returns:
baseDN DN used for the lookup

getUserDN

public String getUserDN()
Get the DN used when searching the user DN. Override the baseDN if it is defined

Returns:
userDN DN used when searching the user DN

getUserSearchFilter

public String getUserSearchFilter()
Get the filter used when searching the user

Returns:
userSearchFilter filter used when searching the user

getRoleDN

public String getRoleDN()
Get the DN used when searching the role DN. Override the baseDN if it is defined

Returns:
roleDN DN used when searching the role DN. Override the baseDN if it is defined

getRoleSearchFilter

public String getRoleSearchFilter()
Get the filter used when searching the role

Returns:
roleSearchFilter filter used when searching the role

getAlgorithm

public String getAlgorithm()
Get the default algorithm

Returns:
the default algorithm

getDirContext

protected DirContext getDirContext()
                            throws NamingException
Return a dircontext for this LDAP server

Returns:
a dircontext for this LDAP server
Throws:
NamingException - if we can't retrieve a DirContext

removeMBeans

public void removeMBeans()
                  throws JResourceException
Remove all the Mbeans used by this resource

Throws:
JResourceException - if the MBeans can not be removed


Copyright © 2011 OW2 Consortium. All Rights Reserved.