+++ /dev/null
-/*****************************************************************************
-* Copyright Igor Barma, Eric Brun, Alexandre Desoubeaux, Christian Martel,
-* (2 décembre 2008)
-*
-* Ce logiciel est un programme informatique servant à l'évaluation des
-* compétences.
-*
-* Ce logiciel est régi par la licence CeCILL soumise au droit français et
-* respectant les principes de diffusion des logiciels libres. Vous pouvez
-* utiliser, modifier et/ou redistribuer ce programme sous les conditions
-* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
-* sur le site "http://www.cecill.info".
-*
-* En contrepartie de l'accessibilité au code source et des droits de copie,
-* de modification et de redistribution accordés par cette licence, il n'est
-* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
-* seule une responsabilité restreinte pèse sur l'auteur du programme, le
-* titulaire des droits patrimoniaux et les concédants successifs.
-*
-* A cet égard l'attention de l'utilisateur est attirée sur les risques
-* associés au chargement, à l'utilisation, à la modification et/ou au
-* développement et à la reproduction du logiciel par l'utilisateur étant
-* donné sa spécificité de logiciel libre, qui peut le rendre complexe à
-* manipuler et qui le réserve donc à des développeurs et des professionnels
-* avertis possédant des connaissances informatiques approfondies. Les
-* utilisateurs sont donc invités à charger et tester l'adéquation du
-* logiciel à leurs besoins dans des conditions permettant d'assurer la
-* sécurité de leurs systèmes et ou de leurs données et, plus généralement,
-* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
-*
-* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
-* pris connaissance de la licence CeCILL, et que vous en avez accepté les
-* termes.
-*******************************************************************************/
-package com.pentila.jackrabbit.auth;
-
-/*
-
- /*
- * Copyright (c) 2000-2003 Yale University. All rights reserved.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE EXPRESSLY
- * DISCLAIMED. IN NO EVENT SHALL YALE UNIVERSITY OR ITS EMPLOYEES BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED, THE COSTS OF
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Redistribution and use of this software in source or binary forms,
- * with or without modification, are permitted, provided that the
- * following conditions are met:
- *
- * 1. Any redistribution must include the above copyright notice and
- * disclaimer and this list of conditions in any related documentation
- * and, if feasible, in the redistributed software.
- *
- * 2. Any redistribution must include the acknowledgment, "This product
- * includes software developed by Yale University," in any related
- * documentation and, if feasible, in the redistributed software.
- *
- * 3. The names "Yale" and "Yale University" must not be used to endorse
- * or promote products derived from this software.
- */
-
-import java.security.Principal;
-import java.util.Map;
-
-import javax.jcr.Credentials;
-import javax.jcr.SimpleCredentials;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-
-import org.apache.jackrabbit.core.security.CredentialsCallback;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class CASLoginModule.
- */
-public class CASLoginModule implements LoginModule {
-
- /** The subject. */
- protected Subject subject;
-
- /** The callback handler. */
- protected CallbackHandler callbackHandler;
-
- /** The cas validate url. */
- protected String casValidateUrl;
-
- /** The service. */
- protected String service;
-
- /** The principal. */
- protected Principal principal;
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)
- */
- public void initialize(Subject subject, CallbackHandler callbackHandler,
- Map sharedState, Map options) {
- this.subject = subject;
- this.callbackHandler = callbackHandler;
- this.casValidateUrl = (String) options.get("cas_validate_url");
- this.service = (String) options.get("service");
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#login()
- */
- public boolean login() throws LoginException {
- final String name;
- String n = "";
- try {
- n = new CasAuth().getUserName();
- } catch (Exception e) {
- try {
- CredentialsCallback ccb = new CredentialsCallback();
- callbackHandler.handle(new Callback[] { ccb });
- Credentials creds = ccb.getCredentials();
- if (creds != null) {
- if (creds instanceof SimpleCredentials) {
- SimpleCredentials sc = (SimpleCredentials) creds;
- n = sc.getUserID();
- }
- } else {
- n = "anonymous";
- }
- } catch (Exception e1) {
- }
- }
- if (!n.equals("")) {
- name = n;
- principal = new Principal() {
- public String getName() {
- return name;
- }
- };
- return true;
- } else {
- return false;
- }
- // return true;
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#commit()
- */
- public boolean commit() throws LoginException {
- if (principal != null) {
- subject.getPrincipals().add(principal);
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#abort()
- */
- public boolean abort() throws LoginException {
- if (principal != null) {
- principal = null;
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#logout()
- */
- public boolean logout() throws LoginException {
- if (principal != null) {
- subject.getPrincipals().remove(principal);
- return true;
- }
- return false;
- }
-
-}