01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: */
21:
22: package org.josso.tc55.agent.jaas;
23:
24: import org.apache.catalina.realm.JAASRealm;
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27:
28: import javax.security.auth.Subject;
29: import java.security.Principal;
30:
31: /**
32: * Catalina JAASRealm replacement that instantiates CatalinaSSOUser Principal instead of
33: * GenericPrincipal.
34: *
35: * @author <a href="mailto:gbrigand@josso.org">Gianluca Brigandi</a>
36: * @version CVS $Id: CatalinaJAASRealm.java 508 2008-02-18 13:32:29Z sgonzalez $
37: */
38:
39: public class CatalinaJAASRealm extends JAASRealm {
40: private static Log log = LogFactory.getLog(CatalinaJAASRealm.class);
41:
42: /**
43: * Construct and return a java.security.Principal instance
44: * representing the authenticated user for the specified Subject. If no
45: * such Principal can be constructed, return null.
46: *
47: * The Principal constructed is *not* GenericPrincipal as in Catalina JAASRealm class,
48: * but CatalinaSSOUser which is a SSOUser.
49: * The Partner Application can access SSOUser-specific properties that are not available
50: * in GenericPrincipal.
51: * The JAASRealm superclass invokes this factory method to build the Catalina-specific
52: * Principal from the Subject filled by the configured JAASLoginModule.
53: *
54: * @param subject The Subject representing the logged in user
55: */
56: protected Principal createPrincipal(String username, Subject subject) {
57: return CatalinaSSOUser.newInstance(this, subject);
58: }
59:
60: }
|