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    import java.util.ArrayList;
021    import java.util.List;
022    import javax.net.ssl.SSLSession;
023    import javax.security.auth.Subject;
024    
025    import org.omg.CORBA.ORB;
026    import org.omg.CSIIOP.TAG_NULL_TAG;
027    import org.omg.CSIIOP.TAG_SECIOP_SEC_TRANS;
028    import org.omg.CSIIOP.TAG_TLS_SEC_TRANS;
029    import org.omg.IOP.Codec;
030    import org.omg.IOP.TaggedComponent;
031    
032    import org.apache.geronimo.corba.security.SASException;
033    
034    
035    /**
036     * @version $Rev: 503274 $ $Date: 2007-02-03 10:19:18 -0800 (Sat, 03 Feb 2007) $
037     */
038    public abstract class TSSTransportMechConfig implements Serializable {
039    
040        private boolean trustEveryone;
041        private boolean trustNoone = true;
042        private final List entities = new ArrayList();
043    
044        public boolean isTrustEveryone() {
045            return trustEveryone;
046        }
047    
048        public void setTrustEveryone(boolean trustEveryone) {
049            this.trustEveryone = trustEveryone;
050        }
051    
052        public boolean isTrustNoone() {
053            return trustNoone;
054        }
055    
056        public void setTrustNoone(boolean trustNoone) {
057            this.trustNoone = trustNoone;
058        }
059    
060        public List getEntities() {
061            return entities;
062        }
063    
064        public abstract short getSupports();
065    
066        public abstract short getRequires();
067    
068        public abstract TaggedComponent encodeIOR(ORB orb, Codec codec) throws Exception;
069    
070        public static TSSTransportMechConfig decodeIOR(Codec codec, TaggedComponent tc) throws Exception {
071            TSSTransportMechConfig result = null;
072    
073            if (tc.tag == TAG_NULL_TAG.value) {
074                result = new TSSNULLTransportConfig();
075            } else if (tc.tag == TAG_TLS_SEC_TRANS.value) {
076                result = new TSSSSLTransportConfig(tc, codec);
077            } else if (tc.tag == TAG_SECIOP_SEC_TRANS.value) {
078                result = new TSSSECIOPTransportConfig(tc, codec);
079            }
080    
081            return result;
082        }
083    
084        public abstract Subject check(SSLSession session) throws SASException;
085    
086        public String toString() {
087            StringBuffer buf = new StringBuffer();
088            toString("", buf);
089            return buf.toString();
090        }
091    
092        abstract void toString(String spaces, StringBuffer buf);
093    
094    }