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.css; 018 019 import java.io.Serializable; 020 import java.util.ArrayList; 021 import java.util.Iterator; 022 import java.util.List; 023 024 import org.apache.geronimo.corba.security.config.tss.TSSCompoundSecMechConfig; 025 import org.apache.geronimo.corba.security.config.tss.TSSCompoundSecMechListConfig; 026 027 028 /** 029 * @version $Rev: 503274 $ $Date: 2007-02-03 10:19:18 -0800 (Sat, 03 Feb 2007) $ 030 */ 031 public class CSSCompoundSecMechListConfig implements Serializable { 032 033 private boolean stateful; 034 private final ArrayList mechs = new ArrayList(); 035 036 public boolean isStateful() { 037 return stateful; 038 } 039 040 public void setStateful(boolean stateful) { 041 this.stateful = stateful; 042 } 043 044 public void add(CSSCompoundSecMechConfig mech) { 045 mechs.add(mech); 046 } 047 048 public CSSCompoundSecMechConfig mechAt(int i) { 049 return (CSSCompoundSecMechConfig) mechs.get(i); 050 } 051 052 public int size() { 053 return mechs.size(); 054 } 055 056 public List findCompatibleSet(TSSCompoundSecMechListConfig mechList) { 057 List result = new ArrayList(); 058 059 for (Iterator availMechs = mechs.iterator(); availMechs.hasNext();) { 060 CSSCompoundSecMechConfig aConfig = (CSSCompoundSecMechConfig) availMechs.next(); 061 062 int size = mechList.size(); 063 for (int i = 0; i < size; i++) { 064 TSSCompoundSecMechConfig requirement = mechList.mechAt(i); 065 066 if (aConfig.canHandle(requirement)) { 067 result.add(aConfig); 068 } 069 } 070 071 } 072 073 return result; 074 } 075 076 public String toString() { 077 StringBuffer buf = new StringBuffer(); 078 toString("", buf); 079 return buf.toString(); 080 } 081 082 void toString(String spaces, StringBuffer buf) { 083 buf.append(spaces).append("CSSCompoundSecMechListConfig: [\n"); 084 for (Iterator availMechs = mechs.iterator(); availMechs.hasNext();) { 085 CSSCompoundSecMechConfig aConfig = (CSSCompoundSecMechConfig) availMechs.next(); 086 aConfig.toString(spaces + " ", buf); 087 buf.append("\n"); 088 } 089 buf.append(spaces).append("]\n"); 090 } 091 092 }