AmASJ2EEAuthHandler.java revision 80c77071c6700660c39046da32a0d7953620f608
2N/A/**
2N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2N/A *
2N/A * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
2N/A *
2N/A * The contents of this file are subject to the terms
2N/A * of the Common Development and Distribution License
2N/A * (the License). You may not use this file except in
2N/A * compliance with the License.
2N/A *
2N/A * You can obtain a copy of the License at
2N/A * https://opensso.dev.java.net/public/CDDLv1.0.html or
2N/A * opensso/legal/CDDLv1.0.txt
2N/A * See the License for the specific language governing
2N/A * permission and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL
2N/A * Header Notice in each file and include the License file
2N/A * at opensso/legal/CDDLv1.0.txt.
2N/A * If applicable, add the following below the CDDL Header,
2N/A * with the fields enclosed by brackets [] replaced by
2N/A * your own identifying information:
2N/A * "Portions Copyrighted [year] [name of copyright owner]"
2N/A *
2N/A * $Id: AmASJ2EEAuthHandler.java,v 1.2 2008/06/25 05:52:11 qcheng Exp $
2N/A *
2N/A */
2N/A
2N/Apackage com.sun.identity.agents.appserver.v81;
2N/A
2N/A
2N/A
2N/Aimport javax.servlet.http.HttpServletRequest;
2N/Aimport javax.servlet.http.HttpServletResponse;
2N/Aimport javax.servlet.http.HttpSession;
2N/A
2N/Aimport com.sun.appserv.security.ProgrammaticLogin;
2N/Aimport com.sun.identity.agents.arch.IModuleAccess;
2N/Aimport com.sun.identity.agents.filter.AmFilterManager;
2N/Aimport com.sun.identity.agents.filter.IJ2EEAuthenticationHandler;
2N/A
2N/A
/**
* The J2EE Authentication handler class for Sun Appserver 8.1 Agent
*/
public class AmASJ2EEAuthHandler implements IJ2EEAuthenticationHandler {
/**
* Authenticate a user based on username and password
*
* @param userName The user name
* @param password The user's password
* @param request The HttpServeltRequest object
* @param response The HttpServletResponse object
* @param extraData Some extra data for the authentication
*
* @return true if authentication is successful
*
*/
public boolean authenticate(String userName, String password,
HttpServletRequest request,
HttpServletResponse response,
Object extraData) {
boolean result = false;
HttpSession session = request.getSession(true);
ProgrammaticLogin pLogin = new ProgrammaticLogin();
if((userName != null) && (password != null)) {
IModuleAccess modAccess = AmFilterManager.getModuleAccess();
result = pLogin.login(userName, password, request,
response).booleanValue();
if( !result) {
if (modAccess.isLogWarningEnabled()) {
modAccess.logMessage("AmAS81J2EEAuthHandler: "
+ "Programmatic Login Failed, Invalidating Session");
}
session.invalidate();
} else {
// Show some success message
if (modAccess.isLogMessageEnabled()) {
modAccess.logMessage("AmAS81J2EEAuthHandler: "
+ "Programmatic Login was successful");
}
}
}
return result;
}
}