Integration Server 10.3 | Integration Server Administrator's Guide | Customizing Authentication Using JAAS | JAAS Custom Login Module Example | JAAS Login Module for Integration Server: Sample Code
 
JAAS Login Module for Integration Server: Sample Code
Following is the Java code for a simplified Integration Server JAAS login module. The numbers refer to code portions that are described in the summary table following the module.
package samples.login;
1.
import javax.security.auth.login.LoginException;
import com.softwareag.security.jaas.login.SagAbstractLoginModule;
import com.softwareag.security.jaas.login.SagCredentials;
import com.softwareag.security.jaas.principals.SagUserPrincipal;
import com.wm.app.b2b.server.UserManager;
2.
public class TestLoginModule extends SagAbstractLoginModule {
3.
private String userId;
4.
public boolean abort() throws LoginException {
userId = null;
return true;
}
5.
public boolean commit() throws LoginException {
if(userId != null)
{
createUserPrincipal = "true";
super.commit();
return true;
} else {
return false;
}
}
6.
protected void initConfiguration(){
this.userId = null;
}
7.
public boolean authenticate(SagCredentials userCreds) throws
LoginException
{
String username = userCreds.getUserName();
if(username == null || username.length()==0) {
return false;
}
if(userCreds.getPassword() == null) {
return false;
}
String password = new String(userCreds.getPassword());
if(password == null || password.length()==0) {
return false;
}
if(username.equals("bob") && password.equals("123") &&
UserManager.getUser(username) != null)
{
userId = username;
return true;
} else {
return false;
}
}
public boolean logout() throws LoginException {
userId = null;
return true;
}
}