Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2EF656BFE for ; Wed, 22 Jun 2011 03:17:18 +0000 (UTC) Received: (qmail 94512 invoked by uid 500); 22 Jun 2011 03:17:17 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 94366 invoked by uid 500); 22 Jun 2011 03:17:12 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 94355 invoked by uid 99); 22 Jun 2011 03:17:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2011 03:17:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2011 03:17:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 45E0F23888CB; Wed, 22 Jun 2011 03:16:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1138290 - /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java Date: Wed, 22 Jun 2011 03:16:46 -0000 To: scm@geronimo.apache.org From: xiaming@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110622031646.45E0F23888CB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: xiaming Date: Wed Jun 22 03:16:45 2011 New Revision: 1138290 URL: http://svn.apache.org/viewvc?rev=1138290&view=rev Log: GERONIMO-5652 add a missing file of generic header enablement Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java (with props) Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java?rev=1138290&view=auto ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java (added) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java Wed Jun 22 03:16:45 2011 @@ -0,0 +1,213 @@ +package org.apache.geronimo.tomcat.security.authentication; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.geronimo.security.realm.providers.RequestCallbackHandler; +import org.apache.geronimo.tomcat.security.AuthResult; +import org.apache.geronimo.tomcat.security.Authenticator; +import org.apache.geronimo.tomcat.security.LoginService; +import org.apache.geronimo.tomcat.security.ServerAuthException; +import org.apache.geronimo.tomcat.security.TomcatAuthStatus; +import org.apache.geronimo.tomcat.security.UserIdentity; + +public class GenericHeaderAuthenticator implements Authenticator { + + private static final String GENERIC_AUTH = "GENERIC"; + + private final LoginService loginService; + private final UserIdentity unauthenticatedIdentity; + + public GenericHeaderAuthenticator(LoginService loginService, UserIdentity unauthenticatedIdentity) { + this.loginService = loginService; + this.unauthenticatedIdentity = unauthenticatedIdentity; + } + + @Override + public AuthResult validateRequest(Request request, HttpServletResponse response, boolean isAuthMandatory, + UserIdentity cachedIdentity) throws ServerAuthException { + try { + HttpServletRequest httpRequest = request.getRequest(); + UserIdentity userIdentity = loginService.login(new RequestCallbackHandler(httpRequest)); + if (userIdentity != null) { + return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, false); + } else { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return new AuthResult(TomcatAuthStatus.FAILURE, unauthenticatedIdentity, false); + } + } catch (IOException e) { + throw new ServerAuthException(e); + } + } + + @Override + public boolean secureResponse(Request request, Response response, AuthResult authResult) throws ServerAuthException { + return false; + } + + @Override + public String getAuthType() { + return GENERIC_AUTH; + } + + @Override + public AuthResult login(String username, String password, Request request) throws ServletException { + UserIdentity userIdentity = loginService.login(username, password); + if (userIdentity != null) { + return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, true); + } + return new AuthResult(TomcatAuthStatus.FAILURE, null, false); + } + + @Override + public void logout(Request request) throws ServletException { + } + +} +package org.apache.geronimo.tomcat.security.authentication; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.geronimo.security.realm.providers.RequestCallbackHandler; +import org.apache.geronimo.tomcat.security.AuthResult; +import org.apache.geronimo.tomcat.security.Authenticator; +import org.apache.geronimo.tomcat.security.LoginService; +import org.apache.geronimo.tomcat.security.ServerAuthException; +import org.apache.geronimo.tomcat.security.TomcatAuthStatus; +import org.apache.geronimo.tomcat.security.UserIdentity; + +public class GenericHeaderAuthenticator implements Authenticator { + + private static final String GENERIC_AUTH = "GENERIC"; + + private final LoginService loginService; + private final UserIdentity unauthenticatedIdentity; + + public GenericHeaderAuthenticator(LoginService loginService, UserIdentity unauthenticatedIdentity) { + this.loginService = loginService; + this.unauthenticatedIdentity = unauthenticatedIdentity; + } + + @Override + public AuthResult validateRequest(Request request, HttpServletResponse response, boolean isAuthMandatory, + UserIdentity cachedIdentity) throws ServerAuthException { + try { + HttpServletRequest httpRequest = request.getRequest(); + UserIdentity userIdentity = loginService.login(new RequestCallbackHandler(httpRequest)); + if (userIdentity != null) { + return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, false); + } else { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return new AuthResult(TomcatAuthStatus.FAILURE, unauthenticatedIdentity, false); + } + } catch (IOException e) { + throw new ServerAuthException(e); + } + } + + @Override + public boolean secureResponse(Request request, Response response, AuthResult authResult) throws ServerAuthException { + return false; + } + + @Override + public String getAuthType() { + return GENERIC_AUTH; + } + + @Override + public AuthResult login(String username, String password, Request request) throws ServletException { + UserIdentity userIdentity = loginService.login(username, password); + if (userIdentity != null) { + return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, true); + } + return new AuthResult(TomcatAuthStatus.FAILURE, null, false); + } + + @Override + public void logout(Request request) throws ServletException { + } + +} +package org.apache.geronimo.tomcat.security.authentication; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.geronimo.security.realm.providers.RequestCallbackHandler; +import org.apache.geronimo.tomcat.security.AuthResult; +import org.apache.geronimo.tomcat.security.Authenticator; +import org.apache.geronimo.tomcat.security.LoginService; +import org.apache.geronimo.tomcat.security.ServerAuthException; +import org.apache.geronimo.tomcat.security.TomcatAuthStatus; +import org.apache.geronimo.tomcat.security.UserIdentity; + +public class GenericHeaderAuthenticator implements Authenticator { + + private static final String GENERIC_AUTH = "GENERIC"; + + private final LoginService loginService; + private final UserIdentity unauthenticatedIdentity; + + public GenericHeaderAuthenticator(LoginService loginService, UserIdentity unauthenticatedIdentity) { + this.loginService = loginService; + this.unauthenticatedIdentity = unauthenticatedIdentity; + } + + @Override + public AuthResult validateRequest(Request request, HttpServletResponse response, boolean isAuthMandatory, + UserIdentity cachedIdentity) throws ServerAuthException { + try { + HttpServletRequest httpRequest = request.getRequest(); + UserIdentity userIdentity = loginService.login(new RequestCallbackHandler(httpRequest)); + if (userIdentity != null) { + return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, false); + } else { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return new AuthResult(TomcatAuthStatus.FAILURE, unauthenticatedIdentity, false); + } + } catch (IOException e) { + throw new ServerAuthException(e); + } + } + + @Override + public boolean secureResponse(Request request, Response response, AuthResult authResult) throws ServerAuthException { + return false; + } + + @Override + public String getAuthType() { + return GENERIC_AUTH; + } + + @Override + public AuthResult login(String username, String password, Request request) throws ServletException { + UserIdentity userIdentity = loginService.login(username, password); + if (userIdentity != null) { + return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, true); + } + return new AuthResult(TomcatAuthStatus.FAILURE, null, false); + } + + @Override + public void logout(Request request) throws ServletException { + } + +} Propchange: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/security/authentication/GenericHeaderAuthenticator.java ------------------------------------------------------------------------------ svn:mime-type = text/plain