cancel
Showing results for 
Search instead for 
Did you mean: 

Obtanin an IPortalComponentRequest In a LoginModule

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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