org.ow2.bonita.identity.impl
Class InMemoryIdentityService

java.lang.Object
  extended by org.ow2.bonita.identity.impl.InMemoryIdentityService
All Implemented Interfaces:
IdentityServiceOp
Direct Known Subclasses:
PersistentIdentityService

public class InMemoryIdentityService
extends java.lang.Object
implements IdentityServiceOp

Author:
"Pierre Vigneras"

Field Summary
protected  java.util.Map<java.lang.String,GroupOp> groupOps
           
protected  int next
           
static java.lang.String ROOT_ID
           
protected  java.util.Map<java.lang.String,UserOp> users
           
 
Constructor Summary
InMemoryIdentityService()
           
 
Method Summary
 java.lang.String authenticateUser(java.lang.String cname, java.lang.String password)
           
 void commit()
          Commit all modifications to the backing store.
 java.lang.String createGroup()
          Create a GroupOp in the identity service backing store and returns the generated id.
 java.lang.String createGroup(GroupOp parent)
          Create a GroupOp in the identity service backing store and returns the generated id.
 java.lang.String createUser()
          Create a UserOp in the identity service backing store and returns the generated id.
 void deleteGroup(java.lang.String id)
          Delete the group mapped to the given id from this service.
 void deleteUser(java.lang.String id)
          Delete the user mapped to the given id from this service.
protected  GroupImpl freshGroup()
           
protected  UserImpl freshUser()
           
 java.util.Collection<GroupOp> getAllGroups()
          Returns a copy of all groupOps present in the backing store Modifications made on the returned collection or on any of its contained GroupOp instances are not propagated to the backing store
 java.util.Collection<UserOp> getAllUsers()
          Returns a copy of all users present in the backing store Modifications made on the returned collection or on any of its contained UserOp instances are not propagated to the backing store
 GroupOp getGroup(java.lang.String id)
          Returns a copy of the group mapped to the given id Modifications made on the return GroupOp instance are not propagated to the backing store
 UserOp getUser(java.lang.String id)
          Returns a copy of the user mapped to the given id Modifications made on the return UserOp instance are not propagated to the backing store
protected  void init()
           
 boolean modifyGroup(GroupOp group)
          Modify the given group.
 boolean modifyUser(UserOp user)
          Modify the given user.
protected  void setMembership(MembershipImpl membership)
           
 Membership setMembership(UserOp user, GroupOp group)
          Make the given user a member of the given group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_ID

public static final java.lang.String ROOT_ID

next

protected int next

users

protected java.util.Map<java.lang.String,UserOp> users

groupOps

protected java.util.Map<java.lang.String,GroupOp> groupOps
Constructor Detail

InMemoryIdentityService

public InMemoryIdentityService()
Method Detail

init

protected void init()

freshGroup

protected GroupImpl freshGroup()

createGroup

public java.lang.String createGroup(GroupOp parent)
Description copied from interface: IdentityServiceOp
Create a GroupOp in the identity service backing store and returns the generated id. The returned group, call it g, will be a child of the given group. Formally, this means that the following expression:
g.getParent().getChildren().contains(g) will return true.

Specified by:
createGroup in interface IdentityServiceOp
Returns:
the generated id

createGroup

public java.lang.String createGroup()
Description copied from interface: IdentityServiceOp
Create a GroupOp in the identity service backing store and returns the generated id. The returned group, call it g, will be a child of its root group. Formally, this means that the following expression:
g.getRoot().getChildren().contains(g) will return true.

Specified by:
createGroup in interface IdentityServiceOp
Returns:
the generated id

deleteGroup

public void deleteGroup(java.lang.String id)
                 throws GroupNotFoundException
Description copied from interface: IdentityServiceOp
Delete the group mapped to the given id from this service.

Specified by:
deleteGroup in interface IdentityServiceOp
Parameters:
id - the group id
Throws:
GroupNotFoundException - if no group is currently mapped to the given id in this IdentityServiceOp

freshUser

protected UserImpl freshUser()

createUser

public java.lang.String createUser()
Description copied from interface: IdentityServiceOp
Create a UserOp in the identity service backing store and returns the generated id.

Specified by:
createUser in interface IdentityServiceOp
Returns:
the generated id

deleteUser

public void deleteUser(java.lang.String id)
                throws UserNotFoundException
Description copied from interface: IdentityServiceOp
Delete the user mapped to the given id from this service.

Specified by:
deleteUser in interface IdentityServiceOp
Parameters:
id - the user id
Throws:
UserNotFoundException - if no user is currently mapped to the given id in this IdentityServiceOp

modifyGroup

public boolean modifyGroup(GroupOp group)
                    throws GroupNotFoundException
Description copied from interface: IdentityServiceOp
Modify the given group.

Specified by:
modifyGroup in interface IdentityServiceOp
Parameters:
group - the modified group
Returns:
true if the given group has been successfully updated, false otherwise
Throws:
GroupNotFoundException - if the given group is not currently mapped in this IdentityServiceOp

modifyUser

public boolean modifyUser(UserOp user)
                   throws UserNotFoundException
Description copied from interface: IdentityServiceOp
Modify the given user.

Specified by:
modifyUser in interface IdentityServiceOp
Parameters:
user - the modified user
Returns:
true if the given user has been successfully updated, false otherwise
Throws:
UserNotFoundException - if the given user is not currently mapped in this IdentityServiceOp

getAllGroups

public java.util.Collection<GroupOp> getAllGroups()
Description copied from interface: IdentityServiceOp
Returns a copy of all groupOps present in the backing store Modifications made on the returned collection or on any of its contained GroupOp instances are not propagated to the backing store

Specified by:
getAllGroups in interface IdentityServiceOp
Returns:
a copy of all groupOps present in the backing store

getAllUsers

public java.util.Collection<UserOp> getAllUsers()
Description copied from interface: IdentityServiceOp
Returns a copy of all users present in the backing store Modifications made on the returned collection or on any of its contained UserOp instances are not propagated to the backing store

Specified by:
getAllUsers in interface IdentityServiceOp
Returns:
a copy of all users present in the backing store

getGroup

public GroupOp getGroup(java.lang.String id)
                 throws GroupNotFoundException
Description copied from interface: IdentityServiceOp
Returns a copy of the group mapped to the given id Modifications made on the return GroupOp instance are not propagated to the backing store

Specified by:
getGroup in interface IdentityServiceOp
Returns:
a copy of the group mapped to the given id
Throws:
GroupNotFoundException - if no group is currently mapped to the given id in this IdentityServiceOp

getUser

public UserOp getUser(java.lang.String id)
               throws UserNotFoundException
Description copied from interface: IdentityServiceOp
Returns a copy of the user mapped to the given id Modifications made on the return UserOp instance are not propagated to the backing store

Specified by:
getUser in interface IdentityServiceOp
Returns:
a copy of the user mapped to the given id, null if no user is currently mapped to the given id.
Throws:
UserNotFoundException - if no user is currently mapped to the given id in this IdentityServiceOp

setMembership

public Membership setMembership(UserOp user,
                                GroupOp group)
                         throws UserNotFoundException,
                                GroupNotFoundException
Description copied from interface: IdentityServiceOp
Make the given user a member of the given group.

Specified by:
setMembership in interface IdentityServiceOp
Returns:
the new membership
Throws:
UserNotFoundException - if the given user is not currently mapped in this IdentityServiceOp
GroupNotFoundException - if the given group is not currently mapped in this IdentityServiceOp
See Also:
Membership

setMembership

protected void setMembership(MembershipImpl membership)

commit

public void commit()
            throws CommitException
Description copied from interface: IdentityServiceOp
Commit all modifications to the backing store.

Specified by:
commit in interface IdentityServiceOp
Throws:
CommitException

authenticateUser

public java.lang.String authenticateUser(java.lang.String cname,
                                         java.lang.String password)


Copyright © 2009 OW2 Consortium. All Rights Reserved.