Skip to Content
Former Member
Dec 18, 2006 at 09:03 AM

Having problem in type Casting of IUser


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 but I have got IUser of package ...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); 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...


Rupesh Khemka