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

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.JResourceDS
All Implemented Interfaces:
java.io.Serializable, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.naming.Referenceable, ReconfigDispatcherMBean, JResourceDSMBean, JResourceMBean

public class JResourceDS
extends JResource
implements JResourceDSMBean

This class extends the JResource class for the Datasource implementation.

Author:
Florent Benoit
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JResourceDS()
          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 getDsName()
          Get the name of the resource to use
 javax.naming.Reference getReference()
          Retrieves the Reference of the object.
 java.lang.String getRoleTable()
          Get the name of table which have the username/role
 java.lang.String getRoleTableRolenameCol()
          Get the name of the column of the role of the role table
 java.lang.String getRoleTableUsernameCol()
          Get the name of the column of the username of the role table
 java.lang.String getUserTable()
          Get the name of the table which have the username/password
 java.lang.String getUserTablePasswordCol()
          Get the name of column of the password of the user table
 java.lang.String getUserTableUsernameCol()
          Get the name of the column of the username of the user table
 boolean isValidUser(User user, java.lang.String credentials)
          Check if the given credential is the right credential for the given user
 void removeMBeans()
          Remove all the Mbeans used by this resource
 void setAlgorithm(java.lang.String algorithm)
          Set the default algorithm to use
 void setDsName(java.lang.String dsName)
          Set the name of the resource to use
 void setRoleTable(java.lang.String roleTable)
          Set the name of table which have the username/role
 void setRoleTableRolenameCol(java.lang.String roleTableRolenameCol)
          Set the name of the column of the role of the role table
 void setRoleTableUsernameCol(java.lang.String roleTableUsernameCol)
          Set the name of the column of the username of the role table
 java.lang.String setUserPrincipalsQuery()
          Gets the user defined query for retrieving principals
 void setUserPrincipalsQuery(java.lang.String userPrincipalsQuery)
          Set the user defined query for retrieving principals
 java.lang.String setUserRolesQuery()
          Gets the user defined query for retrieving roles
 void setUserRolesQuery(java.lang.String userRolesQuery)
          Set the user defined query for retrieving roles
 void setUserTable(java.lang.String userTable)
          Set the name of the table which have the username/password
 void setUserTablePasswordCol(java.lang.String userTablePasswordCol)
          Set the name of column of the password of the user table
 void setUserTableUsernameCol(java.lang.String userTableUsernameCol)
          Set the name of the column of the username of the user table
 java.lang.String toString()
          The string representation of this realm is the XML
 java.lang.String toXML()
          String representation of the MemoryRealm
 
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.JResourceDSMBean
clearCache
 
Methods inherited from interface org.objectweb.jonas.security.realm.factory.JResourceMBean
getName, saveConfig
 

Constructor Detail

JResourceDS

public JResourceDS()
            throws java.lang.Exception
Constructor. Use the super constructor

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

setDsName

public void setDsName(java.lang.String dsName)
Set the name of the resource to use

Specified by:
setDsName in interface JResourceDSMBean
Parameters:
dsName - name of the resource

setUserTable

public void setUserTable(java.lang.String userTable)
Set the name of the table which have the username/password

Specified by:
setUserTable in interface JResourceDSMBean
Parameters:
userTable - name of the table which have the username/password

setUserTableUsernameCol

public void setUserTableUsernameCol(java.lang.String userTableUsernameCol)
Set the name of the column of the username of the user table

Specified by:
setUserTableUsernameCol in interface JResourceDSMBean
Parameters:
userTableUsernameCol - name of the column of the username of the user table

setUserTablePasswordCol

public void setUserTablePasswordCol(java.lang.String userTablePasswordCol)
Set the name of column of the password of the user table

Specified by:
setUserTablePasswordCol in interface JResourceDSMBean
Parameters:
userTablePasswordCol - name of column of the password of the user table

setRoleTable

public void setRoleTable(java.lang.String roleTable)
Set the name of table which have the username/role

Specified by:
setRoleTable in interface JResourceDSMBean
Parameters:
roleTable - name of table which have the username/role

setRoleTableUsernameCol

public void setRoleTableUsernameCol(java.lang.String roleTableUsernameCol)
Set the name of the column of the username of the role table

Specified by:
setRoleTableUsernameCol in interface JResourceDSMBean
Parameters:
roleTableUsernameCol - name of the column of the username of the role table

setRoleTableRolenameCol

public void setRoleTableRolenameCol(java.lang.String roleTableRolenameCol)
Set the name of the column of the role of the role table

Specified by:
setRoleTableRolenameCol in interface JResourceDSMBean
Parameters:
roleTableRolenameCol - name of the column of the role of the role table

setAlgorithm

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

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

setUserPrincipalsQuery

public void setUserPrincipalsQuery(java.lang.String userPrincipalsQuery)
Set the user defined query for retrieving principals

Parameters:
userPrincipalsQuery - the user defined query for retrieving principals

setUserRolesQuery

public void setUserRolesQuery(java.lang.String userRolesQuery)
Set the user defined query for retrieving roles

Parameters:
userRolesQuery - the user defined query for retrieving roles

getDsName

public java.lang.String getDsName()
Get the name of the resource to use

Specified by:
getDsName in interface JResourceDSMBean
Returns:
name of the resource

getUserTable

public java.lang.String getUserTable()
Get the name of the table which have the username/password

Specified by:
getUserTable in interface JResourceDSMBean
Returns:
name of the table which have the username/password

getUserTableUsernameCol

public java.lang.String getUserTableUsernameCol()
Get the name of the column of the username of the user table

Specified by:
getUserTableUsernameCol in interface JResourceDSMBean
Returns:
name of the column of the username of the user table

getUserTablePasswordCol

public java.lang.String getUserTablePasswordCol()
Get the name of column of the password of the user table

Specified by:
getUserTablePasswordCol in interface JResourceDSMBean
Returns:
name of column of the password of the user table

getRoleTable

public java.lang.String getRoleTable()
Get the name of table which have the username/role

Specified by:
getRoleTable in interface JResourceDSMBean
Returns:
name of table which have the username/role

getRoleTableUsernameCol

public java.lang.String getRoleTableUsernameCol()
Get the name of the column of the username of the role table

Specified by:
getRoleTableUsernameCol in interface JResourceDSMBean
Returns:
name of the column of the username of the role table

getRoleTableRolenameCol

public java.lang.String getRoleTableRolenameCol()
Get the name of the column of the role of the role table

Specified by:
getRoleTableRolenameCol in interface JResourceDSMBean
Returns:
name of the column of the role of the role table

getAlgorithm

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

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

setUserPrincipalsQuery

public java.lang.String setUserPrincipalsQuery()
Gets the user defined query for retrieving principals

Returns:
the user defined query for retrieving principals

setUserRolesQuery

public java.lang.String setUserRolesQuery()
Gets the user defined query for retrieving roles

Returns:
the user defined query for retrieving roles

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 SQLException

isValidUser

public boolean isValidUser(User user,
                           java.lang.String credentials)
Check if the given credential is the right credential for the given user

Specified by:
isValidUser in class JResource
Parameters:
user - user to check its credentials
credentials - the given credentials
Returns:
true if the credential is valid for this user

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 it fails

toXML

public java.lang.String toXML()
String representation of the MemoryRealm

Returns:
the xml representation of the MemoryRealm

toString

public java.lang.String toString()
The string representation of this realm is the XML

Overrides:
toString in class java.lang.Object
Returns:
XML representation

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.

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