cancel
Showing results for 
Search instead for 
Did you mean: 

ResourceContext(IUser) constructor is undefined,problem of Deprecated IUser

Former Member
0 Kudos

Hi Experts,

I have created an IUser as follows:

com.sap.security.api.IUser user = UMFactory.getUserFactory().getUserByLogonID("Kmuser");

now i m using this user into the following:

IResourceContext resourceContext = new ResourceContext(user);

For this i m getting a compiler error that constructor for ResourceContext(user) doesnt exist.

I did explored and studied about the IUser then i came to know that thare are two types of IUser one is com.sapportals.wcm.util.usermanagement.IUser which is deprecated and the newer one is com.sap.security.api.IUser.

ResourceContext class has all the constructor which takes only the deprecated IUser.

So does SAP APIs provides any other ResourceContext class which Works well with com.sap.security.api.IUser?????

Or is there any way to cast com.sap.security.api.IUser to com.sapportals.wcm.util.usermanagement.IUser????

Please help me out

Help will be appreciated and rewarded

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi,

To convert com.sap.security.api.IUser to com.sapportals.wcm.util.usermanagement.IUser, you can user the following code:

IUser ep5User =

WPUMFactory.getUserFactory().getEP5User(sapUser);

For me it looks like a security breach if you can create ResourceContext with some others userID.

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

This statement:

IUser ep5User =
WPUMFactory.getUserFactory().getEP5User(sapUser);

Throws a nulpointer exception to me.

Former Member
0 Kudos

Hi Praveen,

I m also getting NullPointerException while using the following statement:

IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");

I think i m getting Exception due to this function call "getServiceUser("cmadmin_service")"

Can u tell me the reason?

Wat is "cmadmin_service"?

Does it need any setup on the SAP Server m/c for "cmadmin_service"?

0 Kudos

Hi,

cmadmin_service is a predefined service user in the portal.

To create ResourceContext with service user, check my answers in this thread:

/thread/307251 [original link is broken]

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

I dont want to create Service user.

Can u please tell me why i m getting NullPointerException in using WPUMFactory

0 Kudos

Hi,

It is clear for me that you do not want to create Service user, but just to create a ReosurceContext for the service user <b>cmadmin_service</b>

This is the code to create ReosurceContext for the service user:

Object serviceContext = null;

try {

serviceContext = AccessController.doPrivileged(new PrivilegedExceptionAction() {

public Object run() throws WcmException {

return ResourceFactory.getInstance().getServiceContext("cmadmin_service");

}

});

} catch (PrivilegedActionException e) {

logger.severe(e, "ResourceContext for the technical " + serviceUser +

" user could not be retrieved.");

}

IResourceContext resCtx = (IResourceContext) serviceContext;

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

I m getting PrivilegedActionException acception

Former Member
0 Kudos

Hi Praveen,

I tried that code to get the ResourceContext, but i m getting PrivilegedActionException.

How to resolve this Exception?

Why this Exception is being thrown?

Waiting for ur reply.

0 Kudos

Hi,

It seems you have not rights to access cmadmin_service user.

Check in the UserManagement if the user cmadmin_service has EveryOne group and Authenticated Users group assigned to it.

If not assign them.

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

How and where can i check rights/permissions for camadmin_service?

Former Member
0 Kudos

Hi,

Login to portal. Check under 'User Administration' -> 'Identity Managment'. Enter the user. Click Go. Select the user from the table. At the bottom, user details will be displayed. Click on Modify button, go to 'Assigned groups' tab. On the right, under 'assigned groups' table, check the above 2 groups. If not present, then search for them in 'available groups' and add to the user. Save it.

Regards,

Harini S

Former Member
0 Kudos

Hi Praveen,

The user through which i logged in have both the above grps checked.

But tthe code which u gave for Getting resourceContxt for cmadmin_service is independent of any IUser.

So i m not getting for which user the code is throwing the exception of PrevilegeActionException????