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