1 package org.mortbay.jetty.plus.jaas; 2 3 // ======================================================================== 4 // $Id: SSOJAASUserRealm.java 1001 2008-02-01 09:31:51Z fred nizery $ 5 // 6 // ------------------------------------------------------------------------ 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // http://www.apache.org/licenses/LICENSE-2.0 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 // ======================================================================== 17 18 19 import java.security.Principal; 20 21 import org.mortbay.jetty.Request; 22 import org.mortbay.jetty.Response; 23 import org.mortbay.jetty.security.Credential; 24 import org.mortbay.jetty.security.SSORealm; 25 26 27 28 29 /* ---------------------------------------------------- */ 30 /** SSOJAASUserRealm 31 * <p> 32 * 33 * <p><h4>Notes</h4> 34 * <p> 35 * 36 * <p><h4>Usage</h4> 37 * For SSO realm that uses JAAS 38 * The configuration must be the same as for JAASUserRealm plus 39 * injection of an instance of class HashSSORealm using setSSORealm() 40 * methode. This is intended to be used with the correct LoginModule 41 * and its fitting .conf configuration file as described in JAAS documentation. 42 * 43 * @author Frederic Nizery <frederic.nizery@alcatel-lucent.fr> 44 * 45 * @org.apache.xbean.XBean element="ssoJaasUserRealm" description="Creates a UserRealm suitable for use with JAAS w/ support of SSO" 46 */ 47 public class SSOJAASUserRealm extends JAASUserRealm implements SSORealm 48 { 49 private SSORealm _ssoRealm; 50 51 /** Set the SSORealm. 52 * A SSORealm implementation may be set to enable support for SSO. 53 * @param ssoRealm The SSORealm to delegate single sign on requests to. 54 */ 55 public void setSSORealm(SSORealm ssoRealm) 56 { 57 _ssoRealm = ssoRealm; 58 } 59 60 /* ------------------------------------------------------------ */ 61 public Credential getSingleSignOn(Request request,Response response) 62 { 63 if (_ssoRealm!=null) 64 return _ssoRealm.getSingleSignOn(request,response); 65 return null; 66 } 67 68 /* ------------------------------------------------------------ */ 69 public void setSingleSignOn(Request request,Response response,Principal principal,Credential credential) 70 { 71 if (_ssoRealm!=null) 72 _ssoRealm.setSingleSignOn(request,response,principal,credential); 73 } 74 75 /* ------------------------------------------------------------ */ 76 public void clearSingleSignOn(String username) 77 { 78 if (_ssoRealm!=null) 79 _ssoRealm.clearSingleSignOn(username); 80 } 81 82 }