cancel
Showing results for 
Search instead for 
Did you mean: 

Authenticate user from web service

Former Member
0 Kudos

Hello,

I am trying to create content in KM using a web service but all I get is a "com.sapportals.wcm.repository.AccessDeniedException: User <myuser> is not authenticated" error.

I have been able to create folders in KM with my web service using a service user (cmadmin_service) but I would like to do it with any user. (Actually I don't know why service users work)

This is my method to create folders:

	public String createFolder(String parentRID, String folderName, String user) {

		com.sapportals.portal.security.usermanagement.IUser iUser = null;
		String respuesta = null;		

		RID rid = RID.getRID(parentRID);

		try {

			iUser = WPUMFactory.getUserFactory().getUser(user);
			
			IResourceFactory factory = ResourceFactory.getInstance();
			IResourceContext context = new ResourceContext(iUser);
			
			ICollection parent = (ICollection)factory.getResource(rid, context);
			
			ICollection collection = parent.createCollection(folderName, null);
			respuesta = collection.getName();
			
		}
		catch(Exception e){
			
			respuesta = e.toString();
						
			
		}
				
		return respuesta;
 		
	}

How can I get "myuser" authenticated?

I hope you may help me, Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos
Former Member
0 Kudos

Thank you for your reply Maksim.

I have read those documents and tried with this code:

IResourceAclManager aclManager = ((IAclSecurityManager)parent.getRepositoryManager().getSecurityManager(parent)).getAclManager();
														
IResourceAcl resourceAcl = aclManager.createAcl(parent);
IUMPrincipal principal = WPUMFactory.getUserFactory().getEP5Principal(user);
							
IAclPermission fullControl = aclManager.getPermission(IAclPermission.ACL_PERMISSION_FULL_CONTROL);
IResourceAclEntry aclEntry = aclManager.createAclEntry(principal, false, fullControl, 0);
resourceAcl.addEntry(aclEntry);

But I get that

parent.getRepositoryManager().getSecurityManager(parent)

is null, so I can't get the IResourceAclManager.

I think this happens because the user is not authenticated, so I'm back to the starting point.

Any idea about how to solve this?

Thanks.

Message was edited by: Antonio David Ramírez Moreno

former_member182372
Active Contributor
0 Kudos

Hello Antonio,

Are you asking where to find KM ACL editor? Content administration->KM Content->Toolbox->Permissions.

Click on "Display and change user permissions" and manage permissions. Pay attention that you have to be one of Permission owners.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Maksim,

I'm not asking that. Anyway, I found an alternative (keep using a service user) for what I wanted to do.

Thanks.

jochen_wilhelm
Explorer
0 Kudos

Hi Antonio,

i have exactly the same issue.

Did you find any other possible because i do not want to use a service-user for traceablitiy reasons.

Thank you very much for your answer!

Best regards

Jochen

Answers (0)