001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  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.jetty6;
018    
019    import java.security.Principal;
020    
021    import org.mortbay.jetty.Request;
022    import org.mortbay.jetty.security.UserRealm;
023    
024    
025    /**
026     * @version $Rev: 482336 $ $Date: 2006-12-04 15:12:19 -0500 (Mon, 04 Dec 2006) $
027     */
028    public class JAASJettyRealm implements UserRealm {
029    
030        private final String webRealmName;
031        private final InternalJAASJettyRealm internalJAASJettyRealm;
032    
033        public JAASJettyRealm(String realmName, InternalJAASJettyRealm internalJAASJettyRealm) {
034            this.webRealmName = realmName;
035            this.internalJAASJettyRealm = internalJAASJettyRealm;
036        }
037    
038        public String getName() {
039            return webRealmName;
040        }
041    
042        public Principal getPrincipal(String username) {
043            return internalJAASJettyRealm.getPrincipal(username);
044        }
045    
046        public Principal authenticate(String username, Object credentials, Request request) {
047            return internalJAASJettyRealm.authenticate(username, credentials, request);
048        }
049    
050        public boolean reauthenticate(Principal user) {
051            return internalJAASJettyRealm.reauthenticate(user);
052        }
053    
054        public boolean isUserInRole(Principal user, String role) {
055            return internalJAASJettyRealm.isUserInRole(user, role);
056        }
057    
058        public void disassociate(Principal user) {
059            internalJAASJettyRealm.disassociate(user);
060        }
061    
062        public Principal pushRole(Principal user, String role) {
063            return internalJAASJettyRealm.pushRole(user, role);
064        }
065    
066        public Principal popRole(Principal user) {
067            return internalJAASJettyRealm.popRole(user);
068        }
069    
070        public void logout(Principal user) {
071            internalJAASJettyRealm.logout(user);
072        }
073    
074        public String getSecurityRealmName() {
075            return internalJAASJettyRealm.getSecurityRealmName();
076        }
077    
078    }