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.corba.security.config.tss; 018 019 import java.io.Serializable; 020 021 import javax.net.ssl.SSLSession; 022 import javax.security.auth.Subject; 023 024 import org.apache.geronimo.corba.security.SASException; 025 import org.omg.CORBA.ORB; 026 import org.omg.CSI.EstablishContext; 027 import org.omg.IOP.Codec; 028 import org.omg.IOP.TaggedComponent; 029 030 031 /** 032 * @version $Rev: 503274 $ $Date: 2007-02-03 10:19:18 -0800 (Sat, 03 Feb 2007) $ 033 */ 034 public class TSSConfig implements Serializable { 035 036 private boolean inherit; 037 private TSSTransportMechConfig transport_mech; 038 private final TSSCompoundSecMechListConfig mechListConfig = new TSSCompoundSecMechListConfig(); 039 040 public boolean isInherit() { 041 return inherit; 042 } 043 044 public void setInherit(boolean inherit) { 045 this.inherit = inherit; 046 } 047 048 public TSSTransportMechConfig getTransport_mech() { 049 return transport_mech; 050 } 051 052 public void setTransport_mech(TSSTransportMechConfig transport_mech) { 053 this.transport_mech = transport_mech; 054 } 055 056 public TSSCompoundSecMechListConfig getMechListConfig() { 057 return mechListConfig; 058 } 059 060 public TaggedComponent generateIOR(ORB orb, Codec codec) throws Exception { 061 return mechListConfig.encodeIOR(orb, codec); 062 } 063 064 public Subject check(SSLSession session, EstablishContext msg) throws SASException { 065 066 Subject transportSubject = transport_mech.check(session); 067 068 Subject mechSubject = mechListConfig.check(msg); 069 if (mechSubject != null) return mechSubject; 070 071 return transportSubject; 072 } 073 074 public String toString() { 075 StringBuffer buf = new StringBuffer(); 076 toString("", buf); 077 return buf.toString(); 078 } 079 080 void toString(String spaces, StringBuffer buf) { 081 String moreSpaces = spaces + " "; 082 buf.append(spaces).append("TSSConfig: [\n"); 083 if (transport_mech != null) { 084 transport_mech.toString(moreSpaces, buf); 085 } else { 086 buf.append(moreSpaces).append("null transport_mech\n"); 087 } 088 mechListConfig.toString(moreSpaces, buf); 089 buf.append(spaces).append("]\n"); 090 } 091 }