Netweaver 7.3 Portal – Getting Started Part 3 – Logon Language and Login Module

Configure the Login Module

IMPORTANTPlease make sure that you have two sessions of Netweaver Administrator open either on two machines or in two different browsers.

With Visual administrator it was possible to revert the changes incase there is an error in Login Module. As there is no Visual Administrator in NW 7.3 and the changes need to be made through NWA, you won’t be able to login incase there is some error with your login module!!!!

1. login to http://<host>:<port>/nwa with a user which has got administrative rights.

2. Navigate to Configuration Management->Security->Authentication and Single Sign-On

3. On the Login Modules Tab Select the Login Module which you want to Edit (If you haven’t modified the standard settings, it will be ticket)

4. Click on Edit and add your logon module (The name which you see here is the one configured in LoginModuleConfiguration.xml).

5. Adjust the flag and position of the Login module to suit your requirement. Refer to the logon module blog for details

 

6. Open a new session (Don’t close all the NWA sessions, keep at least one alive, you might need it). Aaccess the URL

http://<host>:<port>/irj/portal?ume.logon.locale=de

7. You will get the login page (You won’t get the Language drop down as of now), Login to the portal and if your Login module is working you will see the content in German. Incase you get an error page on the logon screen itself read on

8. In my case I got an error screen saying that the class com.sap.engine.services.security.exceptions.BaseSecurityException is not found. This is one of the exceptions which are being used in our JAAS Implementation. I tried searching for this class in Netweaver 7.3, but couldn’t found it. In NW 7.0 this is located in sapj2eeclient.jar. I couldn’t find this jar file also in NW7.3. I was left with no other option but to include this jar in the ear project, which I don’t think, is the right way, and I hope someone reading this might suggest a better way. But this approach can be used incase you don’t have the JAAS project available with you and you need to include the jar file directly.

My Project structure now looks like

 

9. After regenerating and redeploying the ear, I was able to successfully test the Login Module.

 

Enhance the Portal Logon Page

I am assuming that you have followed the blog related to the Logon Page modification, and have all the projects already available in NWDS.

If you have worked on Logon screen modification in NW7.0, you will notice that there are major changes in NW7.3. As discussed in my blog on providing Language option in NW7.0, There used to be a property ume.logon.locale , which when set to TRUE through configtool will provide the Language Drop Down on the Logon Page. There is no such property in Netweaver 7.3.  On analysing the Logon Page in NW7.0, I found out that the Languages appearing in the dropdown are store as properties files in umelogonbase.jar. The properties files are accessed through LanguagesBean. After doing a JAD (Java Decompilation), I found the code in Languages Bean to be pretty much independent of other logon functions. This gave me the idea to create my own Logon helper class which will provide the same functionality in NW 7.3. As a bonus I had the properties file which I extracted from theumelogonbase.jar and a template code for the helper class which got after doing the JAD on LanguagesBean class.

1. Create a Java project (In my case it’s LogonHelper), Create a class (In my case it’s LanguagesBean) which implements the interface Serializable.

2. Copy the properties files languages_xx.properties (which were extracted from the umelogonbase.jar) and place them inside the src folder of the Java project. Your project structure will look like below:

 

3. Copy and Paste the below code in  LanguagesBean.java

package com.cts.logon;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class LanguagesBean implements Serializable {
//private final static Location myLoc = Location.getLocation(AuthenticationTraces.LOGON_APPLICATION_LOCATION);
public static final String beanId = “languages”;
private static final String baseName = “languages”;
private ArrayList sortedList = null;
private transient ResourceBundle resourceBundle;
private Locale locale;
// private String[ ][ ] entries;

public LanguagesBean() {
this(Locale.getDefault());
}

public LanguagesBean(Locale locale) {
this.resourceBundle = ResourceBundle.getBundle(baseName, locale);
this.locale = locale;
}

private ResourceBundle getResourceBundle()
{
if (resourceBundle == null)
{
resourceBundle = ResourceBundle.getBundle(baseName, locale);
}
return resourceBundle;
}

protected void appendHtmlOption(StringBuffer result, String id,
String name, boolean select) {
result.append(“<option value=\””);
result.append(id);

if (select) {
result.append(“\” selected >”);
} else {
result.append(“\” >”);
}

result.append(name);
}
// appendHtmlOption

public Enumeration getIds() {
return this.getResourceBundle().getKeys();
}

public String getKeyByValue(String value) {
String key = null;
Enumeration keys = getIds();

while (keys.hasMoreElements()) {
String id = (String) keys.nextElement();
String name = (String) getName(id);

if (name.equals(value)) {
key = id;
break;
}
}

return key;
}

public String getName(String id) {
try {
return this.resourceBundle.getString(id);
} catch (MissingResourceException ex) {

return “”;
}
}

public boolean exists(String id) {
try {
this.getResourceBundle().getString(id);
return true;
} catch (MissingResourceException ex) {

return false;
}
}

public String getHtmlOptions(String selectedId) {
if (this.sortedList == null) {
synchronized (this) {
// create list which is sorted for name
sortedList = new ArrayList();

Enumeration ids = getIds();

while (ids.hasMoreElements()) {
String id = (String)ids.nextElement();
sortedList.add(new Pair(getName(id), id));
}

Collections.sort(sortedList);
}
}

// build sorted html options
Iterator iter = sortedList.iterator();
StringBuffer result = new StringBuffer(“”);

//appendHtmlOption(result, “”, “”, selectedId != null && !exists(selectedId));
while (iter.hasNext()) {
Pair pair = (Pair)iter.next();
appendHtmlOption(result, pair.getId(), pair.getName(), pair.getId().equals(selectedId));
}

return result.toString();
}
// getHtmlOptions

// helper class to sort for name
class Pair implements Comparable, java.io.Serializable {
private String name;
private String id;

Pair(String name, String id) {
this.name = name;
this.id = id;
}

public int compareTo(Object o) {
return name.compareTo(((Pair) o).name);
}

public String getName() {
return name;
}

public String getId() {
return id;
}
}
}

4. Build the project and export the jar file. In my case it’s logonhelper.jar

 

5. Place the logonhelper.jar file inside the lib folder of tc~sec~ume~logon~ui project. Refer to the blog related with the logon page modification for details.

 

6. Open logonPage.jsp and include the LanguagesBean.

 

7. Include the below code in logonPage.jsp as shown

 

 

Author: