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
021 import org.omg.CSI.AuthorizationElement;
022 import org.omg.CSI.IdentityToken;
023
024 import org.apache.geronimo.corba.security.config.tss.TSSSASMechConfig;
025 import org.apache.geronimo.corba.security.config.ConfigUtil;
026
027
028 /**
029 * @version $Rev: 503274 $ $Date: 2007-02-03 10:19:18 -0800 (Sat, 03 Feb 2007) $
030 */
031 public class CSSSASMechConfig implements Serializable {
032
033 private short supports;
034 private short requires;
035 private boolean required;
036 private CSSSASIdentityToken identityToken;
037
038
039 public short getSupports() {
040 return supports;
041 }
042
043 public short getRequires() {
044 return requires;
045 }
046
047 public boolean isRequired() {
048 return required;
049 }
050
051 public void setRequired(boolean required) {
052 this.required = required;
053 }
054
055 public CSSSASIdentityToken getIdentityToken() {
056 return identityToken;
057 }
058
059 public void setIdentityToken(CSSSASIdentityToken identityToken) {
060 this.identityToken = identityToken;
061 }
062
063 public boolean canHandle(TSSSASMechConfig sasMech) {
064 if ((supports & sasMech.getRequires()) != sasMech.getRequires()) return false;
065 if ((requires & sasMech.getSupports()) != requires) return false;
066
067 // TODO: FILL THIS IN
068
069 return true;
070 }
071
072 public AuthorizationElement[] encodeAuthorizationElement() {
073 return new AuthorizationElement[0];
074 }
075
076 public IdentityToken encodeIdentityToken() {
077 return identityToken.encodeIdentityToken();
078 }
079
080 public String toString() {
081 StringBuffer buf = new StringBuffer();
082 toString("", buf);
083 return buf.toString();
084 }
085
086 void toString(String spaces, StringBuffer buf) {
087 String moreSpaces = spaces + " ";
088 buf.append(spaces).append("CSSSASMechConfig: [\n");
089 buf.append(moreSpaces).append("SUPPORTS: ").append(ConfigUtil.flags(supports)).append("\n");
090 buf.append(moreSpaces).append("REQUIRES: ").append(ConfigUtil.flags(requires)).append("\n");
091 if (identityToken != null) {
092 identityToken.toString(moreSpaces, buf);
093 }
094 buf.append(spaces).append("]\n");
095 }
096
097 }