on 2013 Jul 25 3:00 PM
Hi All,
I'm working with web channel 2.0 and I would like to make the user login as soon as the application is launched.
Can you explain how I can achieve that ? (With details)
Thanks,
Benoît
Request clarification before answering.
Hello Benoît,
we call this Feature "Early Logon". However in WCEM 2.0 it is not yet supported. We have shipped the "Early Logon" with Release 3.0.
Please see also this Blog: Web Channel Experience Management 3.0: Early Logon
The Early Logon also has been enabled on Project Basis. I will try to get a good Explanation for this.
Best regards,
Arno
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Benoît,
You can build your own "Early Logon" functionality in WCEM 2.0. The following is a possible strategy how to get the feature.
First you need to create your own user module, extending the original one. This is described in the dev. and extension guide.
Then you need to create a class that extends the PhaseListenerSSOHandlerApp. The PhaseListenerSSOHandlerApp is called at the beginning of the JSF lifecycle (Restore View phase) in every roundtrip. It's registered in the faces-config.xml file of the SAP user module. Your PhaseListener extension also needs be called each roundtrip and should call the super class at the beginning of its afterPhase method. Therefore you create a faces-config.xml with the <lifecycle>-tag referring to your new implementation in your user module similar to the mentioned one in the SAP user module.
After the super class call you need to implement a logic that checks if the user is already logged in. If not you need to redirect to the login page and you need to remember the original request path to be able to navigate to the original requested page after a successful logon. Saving the request path can be done e.g. with the UserUISessionState interface. You can get an object instance using an instance from the UserUIUtils. This instance can be retrieved by using the GenericFactory
UserUIUtils userUIUtils = (UserUIUtils) GenericFactory.getInstance(UserUIUtils.class.getName(), UserUIUtilsImpl.class.getName());
Now having an UserUIUtils instance call
UserUISessionState sessionState = (UserUISessionState) userUIUtils.getSessionObject(UserUISessionState.USER_UI_SESSION_STATE_SESSION_ATT_NAME);
to get the UserUISessionState instance. If there is no instance available you need to create one. The object instances of the necessary parameters can be retrieved as shown in the PhaseListenerSSOHandlerApp.
sessionState = new UserUISessionStateImpl(User, UserConfiguration);
and set the new instance in the UserUIUtils object
userUIUtils.setSessionObject(UserUISessionState.USER_UI_SESSION_STATE_SESSION_ATT_NAME, sessionState);
The UserUISessionState object provides the method setUrlToRedirectToAfterLoginOK to set the redirect URL used after the logon. The redirect URL is a relative path which parts that can be read from the HttpServletRequest
request.getContextPath() + request.getServletPath() + "?" + request.getQueryString();
The redirect call using this URL will be done automatically after a successful logon.
The standard Login page uses the standard header that always contains e.g. the live search input field and the simple search link in WCEM 2.0. If you don't like those links to be visible you need create your own header view hiding those components when the user is not logged in e.g. by calling a new FaceletFunction in a <c:if>-tag returning the user login status.
I hope this helps you to implement your own "Early Logon" functionality.
Best regards
Oliver
Hi Benoît,
I think the missing part for the redirect to the login page should be the following:
String redirectUrl = request.getContextPath() + "/user/loginRegisterOptions.jsf?" +
request.getQueryString();
// URLChecker throws MalformedURLException
new URLChecker().isValid(redirectUrl);
context.getExternalContext().redirect(redirectUrl);
Regards
René
Hi Rene,
Well I've tried to get the context from the PhaseEvent but now I'm keep getting java linkage error :
java.lang.RuntimeException: java.lang.LinkageError: loader constraint violation: 'customer/home~comm~mc~user~cust~dpu (urls: [''file:/usr/sap/DW1/J00/j2ee/cluster/apps/customer/home%7Ecomm%7Emc%7Euser%7Ecust%7Edpu/app_libraries_container/customer%7Ehome%7Ecomm%7Emc%7Euser%7Ecust%7Emd%7Eassembly.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/apps/customer/home%7Ecomm%7Emc%7Euser%7Ecust%7Edpu/app_libraries_container/customer%7Ehome%7Ecomm%7Emc%7Euser%7Ecust%7Eui%7Eassembly.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/apps/customer/home%7Ecomm%7Emc%7Euser%7Ecust%7Edpu/app_libraries_container/customer%7Ehome%7Ecomm%7Emc%7Euser%7Ecust%7Ebo%7Eassembly.jar'], parents: [)'system:Frame', 'system:Frame', 'interface:webservices', 'interface:cross', 'interface:security', 'interface:transactionext', 'library:webservices_lib', 'library:opensql', 'library:jms', 'library:ejb20', 'service:p4', 'service:ejb', 'service:servlet_jsp', 'sap.com/wec~frw~tc~core~app', 'sap.com/wec~comm~mc~user~dpu']) previously initiated loading of javax.faces.event.PhaseEvent (loader 'library:wec~frw~tc~jsf~lib', urls: ['file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/commons-beanutils-1.8.3.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/commons-codec-1.3.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/commons-collections-3.2.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/commons-digester-2.1.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/commons-logging-1.1.1.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/myfaces-api-2.1.7.jar', 'file:/usr/sap/DW1/J00/j2ee/cluster/bin/ext/wec%7Efrw%7Etc%7Ejsf%7Elib/myfaces-impl-2.1.7.jar'], parents: ['system:Frame', 'system:Frame', 'library:servlet', 'library:ejb_api', 'library:javax~persistence~api', 'library:tc~je~portlet~plb'])
And I don't see what's wrong in the dependancies...
Regards,
Benoît
Hello Benoît,
In the past similar problems like the one reported by you was related to the prepend
mechanism.
Please check if the file application-j2ee-engine.xml of your dpu which contains the phaselistener has the following reference:
<!-- JSF 2 Implementation -->
<reference reference-type="hard" prepend="true">
<reference-target provider-name="sap.com"
target-type="library">wec~frw~tc~jsf~lib</reference-target>
</reference>
If you want, you can send me the ear file of your dpu project for further investigation.
My email is sascha.scherer@sap.com
Best regards,
Sascha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.