org.objectweb.jonas.security.realm.factory
Class JResourceLDAP

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.ReconfigDispatcher
          extended by org.objectweb.jonas.security.realm.factory.JResource
              extended by org.objectweb.jonas.security.realm.factory.JResourceLDAP
All Implemented Interfaces:
java.io.Serializable, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.naming.Referenceable, ReconfigDispatcherMBean, JResourceLDAPMBean, JResourceMBean

public class JResourceLDAP
extends JResource
implements JResourceLDAPMBean

This class extends the JResource class for the LDAP implementation.

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

Field Summary
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JResourceLDAP()
          Constructor : use the super constructor
 
Method Summary
 User findUser(java.lang.String username)
          Check if a user is found and return it
 java.lang.String getAlgorithm()
          Get the default algorithm
 java.util.ArrayList getArrayListCombinedRoles(User user)
          Get all the roles (from the roles and from the groups) of the given user
 java.lang.String getAuthenticationMode()
          Get the mode for validate the authentication of this LDAP realm
 java.lang.String getBaseDN()
          Get the DN used for the lookup of this LDAP realm
protected  javax.naming.directory.DirContext getDirContext()
          Return a dircontext for this LDAP server
 java.lang.String getInitialContextFactory()
          Return the initial context factory of this LDAP realm
 java.lang.String getLanguage()
          Get the preferred language to use with the service of this LDAP realm
 java.lang.String getProviderUrl()
          Get the Url of the ldap server of this LDAP realm
 javax.naming.Reference getReference()
          Retrieves the Reference of the object.
 java.lang.String getReferral()
          Get how referrals encountered by the service provider are to be processed
 java.lang.String getRoleDN()
          Get the DN used when searching the role DN.
 java.lang.String getRoleNameAttribute()
          Get the role name when performing a lookup on a role
 java.lang.String getRoleSearchFilter()
          Get the filter used when searching the role
 java.lang.String getSecurityAuthentication()
          Get the authentication used during the authentication to the LDAP server of this LDAP realm
 java.lang.String getSecurityCredentials()
          Get the Credential(password) of the principal of this LDAP realm
 java.lang.String getSecurityPrincipal()
          Get the DN of the Principal(username) of this LDAP realm
 java.lang.String getSecurityProtocol()
          Get the security protocol to use of this LDAP realm
 java.lang.String getStateFactories()
          Get the the list of state factories of this LDAP realm
 java.lang.String getUserDN()
          Get the DN used when searching the user DN.
 java.lang.String getUserPasswordAttribute()
          Get the attribute in order to get the password of this LDAP realm
 java.lang.String getUserRolesAttribute()
          Get the attribute in order to get the user role from the ldap server
 java.lang.String getUserSearchFilter()
          Get the filter used when searching the user
 boolean isValidUser(User user, java.lang.String credentials)
          Check if the given user with the given credential is a valid user
 boolean isValidUserBind(User user, java.lang.String credentials)
          Check if the given user with the given credential is a valid user.
 boolean isValidUserCompare(User user, java.lang.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(java.lang.String algorithm)
          Set the default algorithm to use
 void setAuthenticationMode(java.lang.String authenticationMode)
          Set the mode for validate the authentication of this LDAP realm
 void setBaseDN(java.lang.String baseDN)
          Set the DN used for the lookup of this LDAP realm
 void setInitialContextFactory(java.lang.String initialContextFactory)
          Set the initial context factory of this LDAP realm
 void setLanguage(java.lang.String language)
          Set the preferred language to use with the service of this LDAP realm
 void setProviderUrl(java.lang.String providerUrl)
          Set the Url of the ldap server of this LDAP realm
 void setReferral(java.lang.String referral)
          Set how referrals encountered by the service provider are to be processed
 void setRoleDN(java.lang.String roleDN)
          Set the DN used when searching the role DN.
 void setRoleNameAttribute(java.lang.String roleNameAttribute)
          Set the role name when performing a lookup on a role
 void setRoleSearchFilter(java.lang.String roleSearchFilter)
          Set the filter used when searching the role
 void setSecurityAuthentication(java.lang.String securityAuthentication)
          Set the authentication used during the authentication to the LDAP server of this LDAP realm
 void setSecurityCredentials(java.lang.String securityCredentials)
          Set the Credential(password) of the principal of this LDAP realm
 void setSecurityPrincipal(java.lang.String securityPrincipal)
          Set the DN of the Principal(username) of this LDAP realm
 void setSecurityProtocol(java.lang.String securityProtocol)
          Set the security protocol to use of this LDAP realm
 void setStateFactories(java.lang.String stateFactories)
          Set the the list of state factories of this LDAP realm
 void setUserDN(java.lang.String userDN)
          Set the DN used when searching the user DN.
 void setUserPasswordAttribute(java.lang.String userPasswordAttribute)
          Set the attribute in order to get the password of this LDAP realm
 void setUserRolesAttribute(java.lang.String userRolesAttribute)
          Set the attribute in order to get the user role from the ldap server
 void setUserSearchFilter(java.lang.String userSearchFilter)
          Set the filter used when searching the user
 java.lang.String toString()
          The string representation of this object is an XML value
 java.lang.String toXML()
          String representation of the LDAP realm
 
Methods inherited from class org.objectweb.jonas.security.realm.factory.JResource
clearCache, getLogger, getMBeanServer, getName, getSequenceNumber, getUsers, saveConfig, setLogger, setName, setUsers
 
Methods inherited from class org.objectweb.jonas.management.ReconfigDispatcher
addNotificationListener, getFilter, getHandback, getListener, getNotificationInfo, initLogger, removeNotificationListener, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
handleNotification, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.jonas.security.realm.factory.JResourceLDAPMBean
clearCache
 
Methods inherited from interface org.objectweb.jonas.security.realm.factory.JResourceMBean
getName, saveConfig
 

Constructor Detail

JResourceLDAP

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

Throws:
java.lang.Exception - if the super constructor fail
Method Detail

findUser

public User findUser(java.lang.String username)
              throws JResourceException
Check if a user is found and return it

Specified by:
findUser in class JResource
Parameters:
username - the wanted user name
Returns:
the user found or null
Throws:
JResourceException - if there is a NamingException

isValidUser

public boolean isValidUser(User user,
                           java.lang.String credentials)
Check if the given user with the given credential is a valid user

Specified by:
isValidUser in class JResource
Parameters:
user - the given user
credentials - credential of the user
Returns:
true if the user is valid

isValidUserBind

public boolean isValidUserBind(User user,
                               java.lang.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(User user,
                                  java.lang.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 java.util.ArrayList getArrayListCombinedRoles(User user)
                                              throws JResourceException
Get all the roles (from the roles and from the groups) of the given user

Specified by:
getArrayListCombinedRoles in class JResource
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 java.lang.String toXML()
String representation of the LDAP realm

Returns:
the xml representation of the LDAP realm

toString

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

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

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.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.

Specified by:
getReference in interface javax.naming.Referenceable
Specified by:
getReference in class JResource
Returns:
the non-null Reference of the object.
Throws:
javax.naming.NamingException - if a naming exception was encountered while retrieving the reference.

setInitialContextFactory

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

Specified by:
setInitialContextFactory in interface JResourceLDAPMBean
Parameters:
initialContextFactory - the initial context factory

setProviderUrl

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

Specified by:
setProviderUrl in interface JResourceLDAPMBean
Parameters:
providerUrl - Url of the ldap server

setSecurityAuthentication

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

Specified by:
setSecurityAuthentication in interface JResourceLDAPMBean
Parameters:
securityAuthentication - authentication used during the authentication to the LDAP server

setSecurityPrincipal

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

Specified by:
setSecurityPrincipal in interface JResourceLDAPMBean
Parameters:
securityPrincipal - DN of the Principal(username)

setSecurityCredentials

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

Specified by:
setSecurityCredentials in interface JResourceLDAPMBean
Parameters:
securityCredentials - Credential(password) of the principal

setSecurityProtocol

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

Specified by:
setSecurityProtocol in interface JResourceLDAPMBean
Parameters:
securityProtocol - security protocol to use

setLanguage

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

Specified by:
setLanguage in interface JResourceLDAPMBean
Parameters:
language - preferred language to use with the service

setReferral

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

Specified by:
setReferral in interface JResourceLDAPMBean
Parameters:
referral - how referrals encountered by the service provider are to be processed

setStateFactories

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

Specified by:
setStateFactories in interface JResourceLDAPMBean
Parameters:
stateFactories - list of state factories

setAuthenticationMode

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

Specified by:
setAuthenticationMode in interface JResourceLDAPMBean
Parameters:
authenticationMode - BIND_AUTHENTICATION_MODE or COMPARE_AUTHENTICATION_MODE

setUserPasswordAttribute

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

Specified by:
setUserPasswordAttribute in interface JResourceLDAPMBean
Parameters:
userPasswordAttribute - attribute in order to get the password of this LDAP realm

setUserRolesAttribute

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

Specified by:
setUserRolesAttribute in interface JResourceLDAPMBean
Parameters:
userRolesAttribute - attribute in order to get the user role from the ldap server

setRoleNameAttribute

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

Specified by:
setRoleNameAttribute in interface JResourceLDAPMBean
Parameters:
roleNameAttribute - role name when performing a lookup on a role

setBaseDN

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

Specified by:
setBaseDN in interface JResourceLDAPMBean
Parameters:
baseDN - DN used for the lookup

setUserDN

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

Specified by:
setUserDN in interface JResourceLDAPMBean
Parameters:
userDN - DN used when searching the user DN

setUserSearchFilter

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

Specified by:
setUserSearchFilter in interface JResourceLDAPMBean
Parameters:
userSearchFilter - filter used when searching the user

setRoleDN

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

Specified by:
setRoleDN in interface JResourceLDAPMBean
Parameters:
roleDN - DN used when searching the role DN. Override the baseDN if it is defined

setRoleSearchFilter

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

Specified by:
setRoleSearchFilter in interface JResourceLDAPMBean
Parameters:
roleSearchFilter - filter used when searching the role

setAlgorithm

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

Specified by:
setAlgorithm in interface JResourceLDAPMBean
Parameters:
algorithm - algorithm to be used

getInitialContextFactory

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

Specified by:
getInitialContextFactory in interface JResourceLDAPMBean
Returns:
the initial context factory

getProviderUrl

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

Specified by:
getProviderUrl in interface JResourceLDAPMBean
Returns:
Url of the ldap server

getSecurityAuthentication

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

Specified by:
getSecurityAuthentication in interface JResourceLDAPMBean
Returns:
authentication used during the authentication to the LDAP server

getSecurityPrincipal

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

Specified by:
getSecurityPrincipal in interface JResourceLDAPMBean
Returns:
DN of the Principal(username)

getSecurityCredentials

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

Specified by:
getSecurityCredentials in interface JResourceLDAPMBean
Returns:
Credential(password) of the principal

getSecurityProtocol

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

Specified by:
getSecurityProtocol in interface JResourceLDAPMBean
Returns:
security protocol to use

getLanguage

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

Specified by:
getLanguage in interface JResourceLDAPMBean
Returns:
language preferred language to use with the service

getReferral

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

Specified by:
getReferral in interface JResourceLDAPMBean
Returns:
how referrals encountered by the service provider are to be processed

getStateFactories

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

Specified by:
getStateFactories in interface JResourceLDAPMBean
Returns:
list of state factories

getAuthenticationMode

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

Specified by:
getAuthenticationMode in interface JResourceLDAPMBean
Returns:
BIND_AUTHENTICATION_MODE or COMPARE_AUTHENTICATION_MODE

getUserPasswordAttribute

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

Specified by:
getUserPasswordAttribute in interface JResourceLDAPMBean
Returns:
attribute in order to get the password of this LDAP realm

getUserRolesAttribute

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

Specified by:
getUserRolesAttribute in interface JResourceLDAPMBean
Returns:
attribute in order to get the user role from the ldap server

getRoleNameAttribute

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

Specified by:
getRoleNameAttribute in interface JResourceLDAPMBean
Returns:
role name when performing a lookup on a role

getBaseDN

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

Specified by:
getBaseDN in interface JResourceLDAPMBean
Returns:
baseDN DN used for the lookup

getUserDN

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

Specified by:
getUserDN in interface JResourceLDAPMBean
Returns:
userDN DN used when searching the user DN

getUserSearchFilter

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

Specified by:
getUserSearchFilter in interface JResourceLDAPMBean
Returns:
userSearchFilter filter used when searching the user

getRoleDN

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

Specified by:
getRoleDN in interface JResourceLDAPMBean
Returns:
roleDN DN used when searching the role DN. Override the baseDN if it is defined

getRoleSearchFilter

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

Specified by:
getRoleSearchFilter in interface JResourceLDAPMBean
Returns:
roleSearchFilter filter used when searching the role

getAlgorithm

public java.lang.String getAlgorithm()
Get the default algorithm

Specified by:
getAlgorithm in interface JResourceLDAPMBean
Returns:
the default algorithm

getDirContext

protected javax.naming.directory.DirContext getDirContext()
                                                   throws javax.naming.NamingException
Return a dircontext for this LDAP server

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

removeMBeans

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

Specified by:
removeMBeans in class JResource
Throws:
JResourceException - if the MBeans can not be removed