The following assumes you are using JDK 1.3 and the files were extracted to the d:/JaasExample Directory. You will save some work by extracting the files to this directory otherwise you will have to modify the policy and the ResourceSecurity.xml policy files with the correct path names.
1) Copy the jaas.jar and the jaasmod.jar to your JDK jre/lib/ext directory (i.e. D:/JDK1.3/jre/lib/ext).
2) Add the following to the end of the java.security file located in JDK's jre/lib/security directory (i.e. D:/JDK1.3/jre/lib/security): auth.policy.PRovider=com.ibm.resource.security.auth.XMLPolicyFile
<%@ taglib uri="/tags/struts-logic" prefix="logic" %> <logic:redirect forward="index"/> <%-- welcome.jspRedirect default requests to Welcome global ActionForward.By using a redirect, the user-agent will change address to match the path of our Welcome ActionForward. --%>
/* * Created on 2005/07/01 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */package com.nova.colimas.security.auth;import java.util.*; import javax.security.auth.*;import javax.security.auth.callback.*; import javax.security.auth.login.*; import javax.security.auth.spi.LoginModule;//import java.security.*; //import org.w3c.dom.traversal.*; import org.w3c.dom.*;//import org.apache.XPath.*; /** * @author tyrone * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */public class ColimasLoginModule implements LoginModule { private Subject subject; private CallbackHandler callbackHandler; private boolean debug = false; private boolean succeeded = false; private boolean commitSucceeded = false; private String username; private char[] passWord; /** * Initializes the <code>LoginModule</code>. * * @param subject the <code>Subject</code> to be authenticated. * * @param callbackHandler a <code>CallbackHandler</code> for * prompting and retrieving the userid and password from the user. * * @param sharedState shared <code>LoginModule</code> state. * * @param options options specified in the login configuration * file for this <code>LoginModule</code>. */ public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.callbackHandler = callbackHandler; // initialize configuration options debug = "true".equalsIgnoreCase((String) options.get("debug")); } /** * Prompts the user for a userid and password. * * @return true if the authentication succeeded, * or false if this LoginModule should be ignored * * @exception FailedLoginException if the authentication fails. * * @exception LoginException if the <code>LoginModule< /code> * is unable to authenticate. */ public boolean login() throws LoginException { if (callbackHandler == null) throw new LoginException("Error: CallbackHandler cannot be null"); Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("userid: "); callbacks[1] = new PasswordCallback("password: ", false); try { callbackHandler.handle(callbacks); username = ((NameCallback) callbacks[0]).getName(); char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword(); if (tmpPassword == null) { // treat a NULL password as an empty