/* * Copyright 2000-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jetspeed.security.impl.ext; import javax.security.auth.Subject; import javax.servlet.http.HttpSession; import org.apache.jetspeed.pipeline.valve.SecurityValve; import org.apache.jetspeed.security.impl.AbstractSecurityValve; import org.apache.jetspeed.security.impl.UserPrincipalImpl; import org.apache.jetspeed.security.UserManager; import org.apache.jetspeed.security.UserPrincipal; import org.apache.jetspeed.request.RequestContext; import org.apache.geronimo.security.ContextManager; import java.security.Principal; /** * GeronimoSecurityValve retrieves the Subject from the geronimo ContextManager whence it was put upon login. * * @version $Id: /local/jetspeed/trunk/components/portal/src/java/org/apache/jetspeed/security/impl/SecurityValveImpl.java 4344 2005-11-07T23:35:53.918893Z taylor $ */ public class GeronimoSecurityValveImpl extends AbstractSecurityValve { private final Subject defaultSubject = new Subject(); public GeronimoSecurityValveImpl(String anonymousUser) { UserPrincipal userPrincipal = new UserPrincipalImpl(anonymousUser); defaultSubject.getPrincipals().add(userPrincipal); } public String toString() { return "GeronimoSecurityValve"; } protected final Subject getSubject(RequestContext request) throws Exception { request.setSessionAttribute(SecurityValve.IP_ADDRESS, request.getRequest().getRemoteAddr()); Subject subject = ContextManager.getCurrentCaller(); if (subject == null) { subject = defaultSubject; } return subject; } protected final Principal getUserPrincipal(RequestContext request) { throw new RuntimeException("Why is this in the interface?"); } }