Skip to Content
author's profile photo Former Member
Former Member

Obtanin an IPortalComponentRequest In a LoginModule

Hello ,

I'm trying to develop a class to be used in an authentication scheme so it needs to implement LoginModule interfaz and I want to get an IPortalComponentRequest in this class but I don't know how ( if it's possible ).

Do you know any method to do this ?

Thanks a lot and best regards

Fernando

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2004 at 05:35 PM

    Not sure about the IPortalComponentRequest,but you can geet a HttpServletRequest

    public boolean login() throws LoginException {
    
    		if (callbackHandler == null) {
    
    			throw new LoginException("Error: no CallbackHandler available to garner authentication information from the user");
    		}
    
    		//TODO declare a Callback array (1 element) and 
    		//     assign a WebCallback object to the array
    		Callback[] callbacks = new Callback[1];
    		callbacks[0] = new WebCallback();
    
    		try {
    			callbackHandler.handle(callbacks);
    			//TODO get the user ID in the cookie from the request object (contained in the callbacks[0])
    			Cookie[] cookies = 
    				((WebCallback) callbacks[0]).getRequest().getCookies();
    			for (int i=0; i<cookies.length; i++) {
    				Cookie c = cookies<i>;
    				if(debug)
    					System.out.println("cookie: " + c.getName() + " = "+c.getValue());
    				if (c.getName().equals(cookieName)) {
    					//TODO get the cookie value and decrypt it
    					userID = decrypt(c.getValue());
    					break;
    				}
    			}
    
    		}
    

    (what you are looking for is ((WebCallback) callbacks[0]).getRequest()

    (code taken for JAAS login example,https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/PRTL351.htm

    Add comment
    10|10000 characters needed characters exceeded