cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

WCEM 2.0 How to force user to login before navigate

Former Member
0 Kudos
740

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

View Entire Topic
Arno-Meyer
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

Helle Arno,

Unfortunately we are using version 2.0, is there a way to do it anyway ?

Thanks for you reply,

Regards,

Benoît

oliver_kohl
Associate
Associate
0 Kudos

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

Former Member
0 Kudos

Hi Oliver,

Thanks for your answer it's helpful.

But you didn't tell me how to redirect to the login page in the method ?

Regards,

Benoît

rene_schwarz2
Associate
Associate
0 Kudos

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é

Former Member
0 Kudos

Hi Rene,

The problem is I can't get the context :

FacesContext context = FacesContext.getCurrentInstance();   does not seem to work cause context is always null in my method...

Any ideas ?

Thanks,

Benoît

rene_schwarz2
Associate
Associate
0 Kudos

Hi Benoît,

I talked with a framework colleague and he said you can check two things:

1) In your application-j2ee-engine.xml should the attribute "prepend" equal true

and

2) you can try to get the context from the PhaseEvent

Best regards

René

Former Member
0 Kudos

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

rene_schwarz2
Associate
Associate
0 Kudos

Hi Benoît,

this problem could be the consequence of the missing "prepend"-configuration inside your application-j2ee-engine.xml.

You can find the correpsonding documentation in the Dev & Extension Guide - Generic Information 2.0, chapter 7.1 JSF 2 Implementation.

Best regards

René

Former Member
0 Kudos

Rene,

I do have the "prepend" attribute (but it's marked as en error in NWDS...).

Regards,

Benoît

rene_schwarz2
Associate
Associate
0 Kudos

Hi Benoît,

it is no problem that the "prepend" attribute is marked as an error inside the NWDS. This is only a validation issue.

After you have set the "prepend" attribute is the problem with the faces-context solved?

 

Best regards

René

Former Member
0 Kudos

Rene,

Well I'va always had the prepend attribute.. so nothing is resolved.

I still getting these linkage error... because of the PhaseEvent class it seems.

Regards,

Benoît

sascha_scherer
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

Hello Oliver,

Is it normal that my Z class is called within each application, even when they don't use the customer module for component "User" ?

It's even called within the web channel builder...

All I did was declare it in the faces-config of my customer user module.

Regards,

Benoît

rene_schwarz2
Associate
Associate
0 Kudos

Hi Benoît,

yes, this is normal. JSF evaluates each faces-config independently of the module concept.

Best regards

René