001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.shared.kerberos.codec; 021 022 023import org.apache.directory.api.asn1.ber.AbstractContainer; 024import org.apache.directory.shared.kerberos.components.PrincipalName; 025import org.apache.directory.shared.kerberos.messages.KerberosMessage; 026import org.apache.directory.shared.kerberos.messages.Ticket; 027 028 029/** 030 * The KerberosMessage container stores all the messages decoded by the Asn1Decoder. 031 * When dealing with an incoding PDU, we will obtain a KerberosMessage in the 032 * container. 033 * 034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 035 */ 036public class KerberosMessageContainer extends AbstractContainer 037{ 038 /** The internal kerberos message */ 039 private KerberosMessage message; 040 041 /** A PrincipalName container */ 042 private PrincipalName principalName; 043 044 /** A flag used when the protocol used to transfer the PDU is TCP */ 045 private boolean isTCP; 046 047 /** When the connection is using a TCP protocol, the PDU length */ 048 private int tcpLength = -1; 049 050 051 /** 052 * Creates a new KerberosMessageContainer object. We will store ten grammars, 053 * it's enough ... 054 */ 055 public KerberosMessageContainer() 056 { 057 super(); 058 setGrammar( KerberosMessageGrammar.getInstance() ); 059 setTransition( KerberosMessageStatesEnum.START_STATE ); 060 } 061 062 063 /** 064 * @return Returns the KerberosMessage. 065 */ 066 public KerberosMessage getMessage() 067 { 068 return message; 069 } 070 071 072 /** 073 * Set a Message Object into the container. It will be completed by the 074 * KerberosDecoder. 075 * 076 * @param message The message to set. 077 */ 078 public void setMessage( KerberosMessage message ) 079 { 080 this.message = message; 081 } 082 083 084 /** 085 * @return Returns the Ticket if the interned message is a Ticket. 086 */ 087 public Ticket getTicket() 088 { 089 return ( Ticket ) message; 090 } 091 092 093 /** 094 * @return Returns the PrincipalName. 095 */ 096 public PrincipalName getPrincipalName() 097 { 098 return principalName; 099 } 100 101 102 /** 103 * Set a PrincipalName Object into the container. It will be completed by the 104 * KerberosDecoder. 105 * 106 * @param principalName The principalName to set. 107 */ 108 public void setPrincipalName( PrincipalName principalName ) 109 { 110 this.principalName = principalName; 111 } 112 113 114 /** 115 * @return the isTCP 116 */ 117 public boolean isTCP() 118 { 119 return isTCP; 120 } 121 122 123 /** 124 * @param isTCP the isTCP to set 125 */ 126 public void setTCP( boolean isTCP ) 127 { 128 this.isTCP = isTCP; 129 } 130 131 132 /** 133 * @return the tcpLength 134 */ 135 public int getTcpLength() 136 { 137 return tcpLength; 138 } 139 140 141 /** 142 * @param tcpLength the tcpLength to set 143 */ 144 public void setTcpLength( int tcpLength ) 145 { 146 this.tcpLength = tcpLength; 147 } 148}