cancel
Showing results for 
Search instead for 
Did you mean: 

Having problem in type Casting of IUser

Former Member
0 Kudos

Hi Everyone

I have made the login() method but i am facing the problem while making the resource context...Because in Resource Context it takes IUser of package

com.sapportals.portal.security.usermanagement.IUser but I have got IUser of package com.sap.security.api.IUser ...while type Casting it with below code it is giving ClassCAstException.......

public class NewSimpleServlet extends HttpServlet {

protected void doGet(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

StringBuffer s = new StringBuffer();

try {String j_user="epuser";

String j_password="Abcd1234";

request.setAttribute("j_user", j_user);

request.setAttribute("j_password", j_password);

javax.security.auth.Subject subject;

Set principals = UMFactory.getLogonAuthenticator().logon(request, response, "uidpwdlogon").getPrincipals();

i have problem with getting IUser object from set of principals. In javadoc is written: "In order to get an IUser object from this subject, call Subject.getPrincipals() and iterate through the returned Set of principals." so i tried to iterate but i was not able to get that IUser with any casting. Do u know how it should be?

IUser serviceUser = (IUser)subject.getPrincipals().iterator().next();

Now in resource Context

ResourceContext c = new ResourceContext(User);

Here resource context need IUser type object as parameter...

I also tried st like this

loggedUser = UMFactory.getAuthenticator().getLoggedInUser(request, response);

but loggedUser is not authenticated.

Can Anyone Help me Out...

Thanks

Rupesh Khemka

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you can use the following to create a com.sapportals.portal.security.usermanagement.IUser from your com.sap.security.api.IUser


com.sap.security.api.IUser iUser= ...;
com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(iUser); 

WPUMFactory is in the bc.util.public_api.jar

Best regards,

Stefan Brauneis

Answers (0)