org.wso2.usermanager.custom.jdbc
Class JDBCRealm

java.lang.Object
  extended by org.wso2.usermanager.custom.jdbc.JDBCRealm
All Implemented Interfaces:
Realm

public class JDBCRealm
extends java.lang.Object
implements Realm


Constructor Summary
JDBCRealm()
           
 
Method Summary
 void addRole(java.lang.String roleName)
          Add a role to the userstore
 void addUser(java.lang.String userName, java.lang.Object credential)
          Add a user to the userstore.
 void addUserToRole(java.lang.String userName, java.lang.String roleName)
          Adds a User to the Role
 boolean authenticate(java.lang.String userName, java.lang.Object credentials)
          Authenticates a user against a userstore
 void authorizeRole(java.lang.String roleName, java.lang.String resourceId, java.lang.String action)
          Allows the role to perform the given action on the given resource
 void authorizeUser(java.lang.String userName, java.lang.String resourceId, java.lang.String action)
          Allows the user to perform the given action on the given resource
 void clearResourceAuthorizations(java.lang.String resourceId)
          Removes all authorizations specified on a resource.
 void clearRoleAuthorization(java.lang.String roleName, java.lang.String resourceId, java.lang.String action)
          Removes the "role, action, resource" relationship.
 void clearUserAuthorization(java.lang.String userName, java.lang.String resourceId, java.lang.String action)
          Removes the "user, action, resource" relationship.
 void copyAuthorizations(java.lang.String fromResourceId, java.lang.String toResourceId)
          Copies all authorization of "fromResourceId" to "toResourceId".
 void deleteRole(java.lang.String roleName)
          Delete role from userstore given the rolename.
 void deleteUser(java.lang.String userName)
          Deletes a user in the userstore
 void denyRole(java.lang.String roleName, java.lang.String resourceId, java.lang.String action)
          Blocks the role performing the given action on the given resource
 void denyUser(java.lang.String userName, java.lang.String resourceId, java.lang.String action)
          Blocks the user performing the given action on the given resource
 java.lang.String[] getAllRoleNames()
          Returns an array of all rolenames int the userstore
 java.lang.String[] getAllUserNames()
          Returns an array of Usernames from the userstore
 java.lang.String[] getAuthorizedRolesForResource(java.lang.String resourceId, java.lang.String action)
          Returns a list of roles authorized to perform an action on a resource
 java.lang.String[] getAuthorizedUsersForResource(java.lang.String resourceId, java.lang.String action)
          Returns a list of users authorized to perform an action on a resource
 java.lang.Object getRealmConfiguration()
          Returns the realm configuration bean.
 java.util.Map getRoleProperties(java.lang.String roleName)
          Gets role property
 java.util.Map getUserProperties(java.lang.String userName)
          Gets user property
 java.lang.String[] getUserRoles(java.lang.String userName)
          Returns an array of Role given a user name
 void init(java.lang.Object configBean)
          Initializes the realm using the properties from the configuration bean passed in.
 boolean isRoleAuthorized(java.lang.String roleName, java.lang.String action, java.lang.String resourceId)
          Checks whether the role is allowed to perform the given action on the given resource
 boolean isUserAuthorized(java.lang.String userName, java.lang.String resourceId, java.lang.String action)
          Checks whether the user is allowed to perform the given action on the given resource
 void removeUserFromRole(java.lang.String userName, java.lang.String roleName)
          Removes a user from role
 void setRoleProperties(java.lang.String roleName, java.util.Map properties)
          Sets role property
 void setUserProperties(java.lang.String userName, java.util.Map properties)
          Sets user property
 void updateUser(java.lang.String userName, java.lang.Object credential)
          Updates a user in the userstore.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCRealm

public JDBCRealm()
Method Detail

getRealmConfiguration

public java.lang.Object getRealmConfiguration()
                                       throws UserManagerException
Description copied from interface: Realm
Returns the realm configuration bean.

Specified by:
getRealmConfiguration in interface Realm
Throws:
UserManagerException - TODO

init

public void init(java.lang.Object configBean)
          throws UserManagerException
Description copied from interface: Realm
Initializes the realm using the properties from the configuration bean passed in.

Specified by:
init in interface Realm
Throws:
UserManagerException - TODO

authenticate

public boolean authenticate(java.lang.String userName,
                            java.lang.Object credentials)
                     throws UserManagerException
Description copied from interface: Realm
Authenticates a user against a userstore

Specified by:
authenticate in interface Realm
Throws:
UserManagerException

getUserProperties

public java.util.Map getUserProperties(java.lang.String userName)
                                throws UserManagerException
Description copied from interface: Realm
Gets user property

Specified by:
getUserProperties in interface Realm
Throws:
UserManagerException

getRoleProperties

public java.util.Map getRoleProperties(java.lang.String roleName)
                                throws UserManagerException
Description copied from interface: Realm
Gets role property

Specified by:
getRoleProperties in interface Realm
Throws:
UserManagerException

setUserProperties

public void setUserProperties(java.lang.String userName,
                              java.util.Map properties)
                       throws UserManagerException
Description copied from interface: Realm
Sets user property

Specified by:
setUserProperties in interface Realm
Throws:
UserManagerException

getAllUserNames

public java.lang.String[] getAllUserNames()
                                   throws UserManagerException
Description copied from interface: Realm
Returns an array of Usernames from the userstore

Specified by:
getAllUserNames in interface Realm
Throws:
UserManagerException

setRoleProperties

public void setRoleProperties(java.lang.String roleName,
                              java.util.Map properties)
                       throws UserManagerException
Description copied from interface: Realm
Sets role property

Specified by:
setRoleProperties in interface Realm
Throws:
UserManagerException

addUser

public void addUser(java.lang.String userName,
                    java.lang.Object credential)
             throws UserManagerException
Description copied from interface: Realm
Add a user to the userstore.

Specified by:
addUser in interface Realm
Throws:
UserManagerException

updateUser

public void updateUser(java.lang.String userName,
                       java.lang.Object credential)
                throws UserManagerException
Description copied from interface: Realm
Updates a user in the userstore. Updates his password and properties.

Specified by:
updateUser in interface Realm
Throws:
UserManagerException

deleteUser

public void deleteUser(java.lang.String userName)
                throws UserManagerException
Description copied from interface: Realm
Deletes a user in the userstore

Specified by:
deleteUser in interface Realm
Throws:
UserManagerException

addRole

public void addRole(java.lang.String roleName)
             throws UserManagerException
Description copied from interface: Realm
Add a role to the userstore

Specified by:
addRole in interface Realm
Throws:
UserManagerException

deleteRole

public void deleteRole(java.lang.String roleName)
                throws UserManagerException
Description copied from interface: Realm
Delete role from userstore given the rolename.

Specified by:
deleteRole in interface Realm
Throws:
UserManagerException

getAllRoleNames

public java.lang.String[] getAllRoleNames()
                                   throws UserManagerException
Description copied from interface: Realm
Returns an array of all rolenames int the userstore

Specified by:
getAllRoleNames in interface Realm
Throws:
UserManagerException

getUserRoles

public java.lang.String[] getUserRoles(java.lang.String userName)
                                throws UserManagerException
Description copied from interface: Realm
Returns an array of Role given a user name

Specified by:
getUserRoles in interface Realm
Throws:
UserManagerException

addUserToRole

public void addUserToRole(java.lang.String userName,
                          java.lang.String roleName)
                   throws UserManagerException
Description copied from interface: Realm
Adds a User to the Role

Specified by:
addUserToRole in interface Realm
Throws:
UserManagerException

removeUserFromRole

public void removeUserFromRole(java.lang.String userName,
                               java.lang.String roleName)
                        throws UserManagerException
Description copied from interface: Realm
Removes a user from role

Specified by:
removeUserFromRole in interface Realm
Throws:
UserManagerException

authorizeUser

public void authorizeUser(java.lang.String userName,
                          java.lang.String resourceId,
                          java.lang.String action)
                   throws UserManagerException
Description copied from interface: Realm
Allows the user to perform the given action on the given resource

Specified by:
authorizeUser in interface Realm
Throws:
UserManagerException

denyUser

public void denyUser(java.lang.String userName,
                     java.lang.String resourceId,
                     java.lang.String action)
              throws UserManagerException
Description copied from interface: Realm
Blocks the user performing the given action on the given resource

Specified by:
denyUser in interface Realm
Throws:
UserManagerException

isUserAuthorized

public boolean isUserAuthorized(java.lang.String userName,
                                java.lang.String resourceId,
                                java.lang.String action)
                         throws UserManagerException
Description copied from interface: Realm
Checks whether the user is allowed to perform the given action on the given resource

Specified by:
isUserAuthorized in interface Realm
Throws:
UserManagerException

clearUserAuthorization

public void clearUserAuthorization(java.lang.String userName,
                                   java.lang.String resourceId,
                                   java.lang.String action)
                            throws UserManagerException
Description copied from interface: Realm
Removes the "user, action, resource" relationship. User, action and resource will exist, but the relationship will be removed.

Specified by:
clearUserAuthorization in interface Realm
Throws:
UserManagerException

authorizeRole

public void authorizeRole(java.lang.String roleName,
                          java.lang.String resourceId,
                          java.lang.String action)
                   throws UserManagerException
Description copied from interface: Realm
Allows the role to perform the given action on the given resource

Specified by:
authorizeRole in interface Realm
Throws:
UserManagerException

denyRole

public void denyRole(java.lang.String roleName,
                     java.lang.String resourceId,
                     java.lang.String action)
              throws UserManagerException
Description copied from interface: Realm
Blocks the role performing the given action on the given resource

Specified by:
denyRole in interface Realm
Throws:
UserManagerException

isRoleAuthorized

public boolean isRoleAuthorized(java.lang.String roleName,
                                java.lang.String action,
                                java.lang.String resourceId)
                         throws UserManagerException
Description copied from interface: Realm
Checks whether the role is allowed to perform the given action on the given resource

Specified by:
isRoleAuthorized in interface Realm
Throws:
UserManagerException

clearRoleAuthorization

public void clearRoleAuthorization(java.lang.String roleName,
                                   java.lang.String resourceId,
                                   java.lang.String action)
                            throws UserManagerException
Description copied from interface: Realm
Removes the "role, action, resource" relationship. Role, action and resource will exist, but the relationship will be removed.

Specified by:
clearRoleAuthorization in interface Realm
Throws:
UserManagerException

clearResourceAuthorizations

public void clearResourceAuthorizations(java.lang.String resourceId)
                                 throws UserManagerException
Description copied from interface: Realm
Removes all authorizations specified on a resource.

Specified by:
clearResourceAuthorizations in interface Realm
Throws:
UserManagerException

getAuthorizedUsersForResource

public java.lang.String[] getAuthorizedUsersForResource(java.lang.String resourceId,
                                                        java.lang.String action)
                                                 throws UserManagerException
Description copied from interface: Realm
Returns a list of users authorized to perform an action on a resource

Specified by:
getAuthorizedUsersForResource in interface Realm
Throws:
UserManagerException

getAuthorizedRolesForResource

public java.lang.String[] getAuthorizedRolesForResource(java.lang.String resourceId,
                                                        java.lang.String action)
                                                 throws UserManagerException
Description copied from interface: Realm
Returns a list of roles authorized to perform an action on a resource

Specified by:
getAuthorizedRolesForResource in interface Realm
Throws:
UserManagerException

copyAuthorizations

public void copyAuthorizations(java.lang.String fromResourceId,
                               java.lang.String toResourceId)
                        throws UserManagerException
Description copied from interface: Realm
Copies all authorization of "fromResourceId" to "toResourceId". All means all - including user authorizations and role authorizations.

Specified by:
copyAuthorizations in interface Realm
Throws:
UserManagerException