cancel
Showing results for 
Search instead for 
Did you mean: 

Difference Between Authorities & Person, User, Role, Group

pramodkhare
Champ in-the-making
Champ in-the-making
Hi I want to know the Concept of Alfresco Authority.  (Note - I am using Alfresco Foundation APi)

When I create User I create Authentication for that user and then I create person node for that user


if(!authenticationService.authenticationExists(userName)){
              authenticationService.createAuthentication(userName, userName.toCharArray());
              if(perService.personExists(userName)){
                 HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
                   properties.put(ContentModel.PROP_USERNAME, userName);
                   properties.put(ContentModel.PROP_PASSWORD, userName);
                   properties.put(ContentModel.PROP_FIRSTNAME, userName);
                   properties.put(ContentModel.PROP_LASTNAME, userName);
                  
                 perService.createPerson(properties);
              }
           }else{
              System.out.println("Usr already exists");
           }

Now there is Concept of USER Authority TYPE also. So If I try to create USER authority form AuthorityService then it gives Exception.

AuthorityService authorityService = serviceRegistry.getAuthorityService();
authService.createAuthority(AuthorityType.USER, "tempUser");
Now if I create User using Person service and then When I want to add user to a UserGroup it gives Exception No Authority Found for user

So I am not able to add Users to user-Groups.

There is one more thing I want to know-
What is the Concept of ROLE,USER,Usergroup authority in alfresco? How they differ from each other?

Now can users be added to ROLE, like user group?

Can a Role be assigned permissions -like Read,Write or any custom permission -group created in permissionDefinition.xml?

In a Usergroup and Role and User, what is precedence level of permission on a node, consider its a permission on node (and not global permission or inherited permission)?

Sorry I am asking too many questions. but I have gone through Alfresco Wiki , but there is no clear difference mentioned there.
3 REPLIES 3

anujs86
Champ in-the-making
Champ in-the-making
What is the Concept of ROLE,USER,User group authority in alfresco? How they differ from each other?

USER - A person with some properties
ROLE - Entitlements assigned to User
User Group - A group in which users gets added/removed.

Check wiki for more detailed information.

pramodkhare
Champ in-the-making
Champ in-the-making
Hi Anuj,

Thanks for your reply.


Can you tell me more about -
"User A" exists, he is added to "Group_A", and "ROLE_A"

1) On a Node, if all of them have certain access, which will precede,

2) As allow takes precedence than deny, in case of node_level_permissions, what will be the access precedence.


And one more thing, I am facing a weird issue,
I am creating a user using -

if(!authenticationService.authenticationExists(userName)){
              authenticationService.createAuthentication(userName, userName.toCharArray());
              if(perService.personExists(userName)){
                 HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
                   properties.put(ContentModel.PROP_USERNAME, userName);
                   properties.put(ContentModel.PROP_PASSWORD, userName);
                   properties.put(ContentModel.PROP_FIRSTNAME, userName);
                   properties.put(ContentModel.PROP_LASTNAME, userName);
                 
                 perService.createPerson(properties);
              }
           }else{
              System.out.println("Usr already exists");
           }
by this code, Person with user details is created, but when I try to check if that person authority exists, then it fails..i.e., Person is created but User Authority is not created, so I am not able to add this user to a group or a role, and not able to authenticate user with AuthenticationService.authenticate to access ServiceRegistry, it says Authority doesn't exist.

if(!authService.authorityExists(authService.getName(AuthorityType.USER, "myUsername"))){
              System.out.println("Usr Authority doesn't exists");
           }else{
              System.out.println("Usr Authority exists");
           }

anujs86
Champ in-the-making
Champ in-the-making
    if(!authenticationService.authenticationExists(userName)){
                  authenticationService.createAuthentication(userName, userName.toCharArray());
                  if(perService.personExists(userName)){
                     HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
                       properties.put(ContentModel.PROP_USERNAME, userName);
                       properties.put(ContentModel.PROP_PASSWORD, userName);
                       properties.put(ContentModel.PROP_FIRSTNAME, userName);
                       properties.put(ContentModel.PROP_LASTNAME, userName);
                    
                     perService.createPerson(properties);
                  }
               }else{
                  System.out.println("Usr already exists");
               }

Above code will only create the user.
You need to explicitly need to give permissions to it and have to set up some home space too.

You can test your code by adding that user to any of the role and group and then giving permissions to some space from Alfresco administration.

Or you can do it programatically using permission services.