001    /**
002     *
003     * Copyright 2004 The Apache Software Foundation
004     *
005     *  Licensed under the Apache License, Version 2.0 (the "License");
006     *  you may not use this file except in compliance with the License.
007     *  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.jetty;
018    
019    import java.security.Principal;
020    
021    import org.apache.commons.logging.Log;
022    import org.apache.commons.logging.LogFactory;
023    import org.mortbay.http.HttpRequest;
024    import org.mortbay.http.UserRealm;
025    
026    
027    /**
028     * @version $Rev: 397916 $ $Date: 2006-04-28 08:12:20 -0700 (Fri, 28 Apr 2006) $
029     */
030    public class JAASJettyRealm implements UserRealm {
031        private static Log log = LogFactory.getLog(JAASJettyRealm.class);
032    
033        private final String webRealmName;
034        private final InternalJAASJettyRealm internalJAASJettyRealm;
035    
036        public JAASJettyRealm(String realmName, InternalJAASJettyRealm internalJAASJettyRealm) {
037            this.webRealmName = realmName;
038            this.internalJAASJettyRealm = internalJAASJettyRealm;
039        }
040    
041        public String getName() {
042            return webRealmName;
043        }
044    
045        public Principal getPrincipal(String username) {
046            return internalJAASJettyRealm.getPrincipal(username);
047        }
048    
049        public Principal authenticate(String username, Object credentials, HttpRequest request) {
050            return internalJAASJettyRealm.authenticate(username, credentials, request);
051        }
052    
053        public boolean reauthenticate(Principal user) {
054            return internalJAASJettyRealm.reauthenticate(user);
055        }
056    
057        public boolean isUserInRole(Principal user, String role) {
058            return internalJAASJettyRealm.isUserInRole(user, role);
059        }
060    
061        public void disassociate(Principal user) {
062            internalJAASJettyRealm.disassociate(user);
063        }
064    
065        public Principal pushRole(Principal user, String role) {
066            return internalJAASJettyRealm.pushRole(user, role);
067        }
068    
069        public Principal popRole(Principal user) {
070            return internalJAASJettyRealm.popRole(user);
071        }
072    
073        public void logout(Principal user) {
074            internalJAASJettyRealm.logout(user);
075        }
076    
077        public String getSecurityRealmName() {
078            return internalJAASJettyRealm.getSecurityRealmName();
079        }
080    
081    }