org.wso2.usermanager.readwrite
Class DefaultRealm

java.lang.Object
  extended by org.wso2.usermanager.readwrite.DefaultRealm
All Implemented Interfaces:
Realm

public class DefaultRealm
extends java.lang.Object
implements Realm


Field Summary
static java.lang.String ADD_PERMISSION
           
static java.lang.String ADD_ROLE
           
static java.lang.String ADD_ROLE_ATTRIBUTE
           
static java.lang.String ADD_ROLE_PERMISSION
           
static java.lang.String ADD_USER
           
static java.lang.String ADD_USER_ATTRIBUTE
           
static java.lang.String ADD_USER_PERMISSION
           
static java.lang.String ADD_USER_ROLE
           
static java.lang.String COLUMN_ATTR_NAME
           
static java.lang.String COLUMN_ATTR_VALUE
           
static java.lang.String COLUMN_CREDENTIAL
           
static java.lang.String COLUMN_ID
           
static java.lang.String COLUMN_IS_ALLOWED
           
static java.lang.String COLUMN_ROLE_NAME
           
static java.lang.String COLUMN_USER_NAME
           
static java.lang.String DELETE_PERMISSION_RESOURCE
           
static java.lang.String DELETE_ROLE
           
static java.lang.String DELETE_ROLE_ATTRIBUTE
           
static java.lang.String DELETE_ROLE_PERMISSION
           
static java.lang.String DELETE_USER
           
static java.lang.String DELETE_USER_ATTRIBUTE
           
static java.lang.String DELETE_USER_PERMISSION
           
static java.lang.String DELETE_USER_ROLE
           
static java.lang.String GET_PERMISSION
           
static java.lang.String GET_RESOURCE_PERMISSION_ROLES
           
static java.lang.String GET_RESOURCE_PERMISSION_USERS
           
static java.lang.String GET_ROLE
           
static java.lang.String GET_ROLE_ALLOWED
           
static java.lang.String GET_ROLE_ATTRIBUTES
           
static java.lang.String GET_ROLE_ID
           
static java.lang.String GET_ROLE_PERMISSION
           
static java.lang.String GET_ROLES_ALL
           
static java.lang.String GET_USER
           
static java.lang.String GET_USER_ALLOWED
           
static java.lang.String GET_USER_ATTRIBUTES
           
static java.lang.String GET_USER_ID
           
static java.lang.String GET_USER_PERMISSION
           
static java.lang.String GET_USER_ROLES
           
static java.lang.String GET_USERS_ALL
           
static java.lang.String MAX_PERMISSION
           
static java.lang.String MAX_ROLE
           
static java.lang.String MAX_ROLE_ATTRIBUTE
           
static java.lang.String MAX_ROLE_PERMISSION
           
static java.lang.String MAX_USER
           
static java.lang.String MAX_USER_ATTRIBUTE
           
static java.lang.String MAX_USER_PERMISSION
           
static java.lang.String UPDATE_USER
           
 
Constructor Summary
DefaultRealm()
           
 
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 resourceId, java.lang.String action)
          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
 

Field Detail

ADD_USER

public static final java.lang.String ADD_USER
See Also:
Constant Field Values

ADD_ROLE

public static final java.lang.String ADD_ROLE
See Also:
Constant Field Values

ADD_USER_ROLE

public static final java.lang.String ADD_USER_ROLE
See Also:
Constant Field Values

ADD_USER_ATTRIBUTE

public static final java.lang.String ADD_USER_ATTRIBUTE
See Also:
Constant Field Values

ADD_ROLE_ATTRIBUTE

public static final java.lang.String ADD_ROLE_ATTRIBUTE
See Also:
Constant Field Values

ADD_PERMISSION

public static final java.lang.String ADD_PERMISSION
See Also:
Constant Field Values

ADD_ROLE_PERMISSION

public static final java.lang.String ADD_ROLE_PERMISSION
See Also:
Constant Field Values

ADD_USER_PERMISSION

public static final java.lang.String ADD_USER_PERMISSION
See Also:
Constant Field Values

UPDATE_USER

public static final java.lang.String UPDATE_USER
See Also:
Constant Field Values

DELETE_USER

public static final java.lang.String DELETE_USER
See Also:
Constant Field Values

DELETE_ROLE

public static final java.lang.String DELETE_ROLE
See Also:
Constant Field Values

DELETE_USER_ROLE

public static final java.lang.String DELETE_USER_ROLE
See Also:
Constant Field Values

DELETE_ROLE_ATTRIBUTE

public static final java.lang.String DELETE_ROLE_ATTRIBUTE
See Also:
Constant Field Values

DELETE_USER_ATTRIBUTE

public static final java.lang.String DELETE_USER_ATTRIBUTE
See Also:
Constant Field Values

DELETE_PERMISSION_RESOURCE

public static final java.lang.String DELETE_PERMISSION_RESOURCE
See Also:
Constant Field Values

DELETE_USER_PERMISSION

public static final java.lang.String DELETE_USER_PERMISSION
See Also:
Constant Field Values

DELETE_ROLE_PERMISSION

public static final java.lang.String DELETE_ROLE_PERMISSION
See Also:
Constant Field Values

GET_USER

public static final java.lang.String GET_USER
See Also:
Constant Field Values

GET_ROLE

public static final java.lang.String GET_ROLE
See Also:
Constant Field Values

GET_USER_ROLES

public static final java.lang.String GET_USER_ROLES
See Also:
Constant Field Values

GET_ROLE_ATTRIBUTES

public static final java.lang.String GET_ROLE_ATTRIBUTES
See Also:
Constant Field Values

GET_USER_ATTRIBUTES

public static final java.lang.String GET_USER_ATTRIBUTES
See Also:
Constant Field Values

GET_PERMISSION

public static final java.lang.String GET_PERMISSION
See Also:
Constant Field Values

GET_ROLE_ALLOWED

public static final java.lang.String GET_ROLE_ALLOWED
See Also:
Constant Field Values

GET_USER_ALLOWED

public static final java.lang.String GET_USER_ALLOWED
See Also:
Constant Field Values

GET_RESOURCE_PERMISSION_ROLES

public static final java.lang.String GET_RESOURCE_PERMISSION_ROLES
See Also:
Constant Field Values

GET_RESOURCE_PERMISSION_USERS

public static final java.lang.String GET_RESOURCE_PERMISSION_USERS
See Also:
Constant Field Values

GET_ROLE_PERMISSION

public static final java.lang.String GET_ROLE_PERMISSION
See Also:
Constant Field Values

GET_USER_PERMISSION

public static final java.lang.String GET_USER_PERMISSION
See Also:
Constant Field Values

GET_ROLES_ALL

public static final java.lang.String GET_ROLES_ALL
See Also:
Constant Field Values

GET_USERS_ALL

public static final java.lang.String GET_USERS_ALL
See Also:
Constant Field Values

GET_USER_ID

public static final java.lang.String GET_USER_ID
See Also:
Constant Field Values

GET_ROLE_ID

public static final java.lang.String GET_ROLE_ID
See Also:
Constant Field Values

COLUMN_ATTR_NAME

public static final java.lang.String COLUMN_ATTR_NAME
See Also:
Constant Field Values

COLUMN_ATTR_VALUE

public static final java.lang.String COLUMN_ATTR_VALUE
See Also:
Constant Field Values

COLUMN_ID

public static final java.lang.String COLUMN_ID
See Also:
Constant Field Values

COLUMN_USER_NAME

public static final java.lang.String COLUMN_USER_NAME
See Also:
Constant Field Values

COLUMN_ROLE_NAME

public static final java.lang.String COLUMN_ROLE_NAME
See Also:
Constant Field Values

COLUMN_IS_ALLOWED

public static final java.lang.String COLUMN_IS_ALLOWED
See Also:
Constant Field Values

COLUMN_CREDENTIAL

public static final java.lang.String COLUMN_CREDENTIAL
See Also:
Constant Field Values

MAX_USER

public static final java.lang.String MAX_USER
See Also:
Constant Field Values

MAX_ROLE

public static final java.lang.String MAX_ROLE
See Also:
Constant Field Values

MAX_USER_ATTRIBUTE

public static final java.lang.String MAX_USER_ATTRIBUTE
See Also:
Constant Field Values

MAX_ROLE_ATTRIBUTE

public static final java.lang.String MAX_ROLE_ATTRIBUTE
See Also:
Constant Field Values

MAX_PERMISSION

public static final java.lang.String MAX_PERMISSION
See Also:
Constant Field Values

MAX_ROLE_PERMISSION

public static final java.lang.String MAX_ROLE_PERMISSION
See Also:
Constant Field Values

MAX_USER_PERMISSION

public static final java.lang.String MAX_USER_PERMISSION
See Also:
Constant Field Values
Constructor Detail

DefaultRealm

public DefaultRealm()
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

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

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

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

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

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

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

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

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

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 resourceId,
                                java.lang.String action)
                         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