/* (non-Javadoc)
* @see org.apache.portals.bridges.common.GenericServletPortlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
*/
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException
{
PortletMode curMode = actionRequest.getPortletMode();
if (curMode == PortletMode.VIEW)
{
String action = actionRequest.getParameter(OpenIDConstants.OPEN_ID_REQUEST);
if (action != null)
{
// redirect action to OpenIDRelayingPartyServlet
RequestContext requestContext = (RequestContext)actionRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
String servletRedirect = requestContext.getRequest().getContextPath()+OPEN_ID_RELAYING_PARTY_SERVLET_MAPPING+"/"+action+"?"+OpenIDConstants.OPEN_ID_RETURN+"="+requestContext.getPortalURL().getBasePath();
// perform action
if (action.equals(OpenIDConstants.OPEN_ID_LOGIN_REQUEST))
{
// access new user registration init parameters and preferences
// and save in session for consumption by the OpenIDRelayingPartyServlet
String logConfiguration = "none";
PortletPreferences prefs = actionRequest.getPreferences();
if (Boolean.parseBoolean(prefs.getValue(ENABLE_REGISTRATION_CONFIG_PREF_NAME, null)))
{
OpenIDRegistrationConfiguration registrationConfiguration = new OpenIDRegistrationConfiguration();
registrationConfiguration.setEnableRegistration(prefs.getValue(ENABLE_REGISTRATION_PREF_NAME, null));
registrationConfiguration.setUserTemplateDirectory(prefs.getValue(REGISTRATION_USER_TEMPLATE_PREF_NAME, null));
registrationConfiguration.setSubsiteRootFolder(prefs.getValue(REGISTRATION_SUBSITE_ROOT_PREF_NAME, null));
registrationConfiguration.setRoles(prefs.getValue(REGISTRATION_ROLES_PREF_NAME, null));
registrationConfiguration.setGroups(prefs.getValue(REGISTRATION_GROUPS_PREF_NAME, null));
registrationConfiguration.setProfilerRules(prefs.getValue(REGISTRATION_PROFILER_RULE_NAMES_PREF_NAME, null), prefs.getValue(REGISTRATION_PROFILER_RULE_VALUES_PREF_NAME, null));
registrationConfiguration.merge(initRegistrationConfiguration);
requestContext.setSessionAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION, registrationConfiguration);
logConfiguration = "preferences";
}
else if (initRegistrationConfiguration != null)
{
requestContext.setSessionAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION, initRegistrationConfiguration);
logConfiguration = "init params";
}
// login redirect to OpenIDRelayingPartyServlet
String discoveryParam = actionRequest.getParameter(OpenIDConstants.OPEN_ID_DISCOVERY);
servletRedirect += (((discoveryParam != null) && (discoveryParam.length() > 0)) ? "&"+OpenIDConstants.OPEN_ID_DISCOVERY+"="+discoveryParam : "");
String providerParam = actionRequest.getParameter(OpenIDConstants.OPEN_ID_PROVIDER);
servletRedirect += (((providerParam != null) && (providerParam.length() > 0)) ? "&"+OpenIDConstants.OPEN_ID_PROVIDER+"="+providerParam : "");
actionResponse.sendRedirect(servletRedirect);
// log user login
if (log.isDebugEnabled())
{
log.debug("OpenID login: discovery: "+discoveryParam+", provider: "+providerParam+", configuration: "+logConfiguration);
}
}
else if (action.equals(OpenIDConstants.OPEN_ID_LOGOUT_REQUEST))
{
// logout redirect to OpenIDRelayingPartyServlet
actionResponse.sendRedirect(servletRedirect);
// log user logout
if (log.isDebugEnabled())
{
log.debug("OpenID logout");
}
}
}
}
else if (curMode.equals(JetspeedActions.EDIT_DEFAULTS_MODE))
{
// default preferences edit mode
if (actionRequest.getParameter(SAVE_ACTION_PARAM_NAME) != null)
{
// save provider and registration preferences