You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2022/09/14 07:52:18 UTC
[directory-server] branch master updated: Some more Kerberos code removal
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new 35ae545e45 Some more Kerberos code removal
35ae545e45 is described below
commit 35ae545e45074c4ab890334d840811404abefdb2
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Wed Sep 14 09:52:05 2022 +0200
Some more Kerberos code removal
---
.../shared/kerberos/codec/KerberosDecoder.java | 229 -------
.../shared/kerberos/codec/KerberosEncoder.java | 68 ---
.../shared/kerberos/codec/types/LastReqType.java | 127 ----
.../shared/kerberos/codec/types/PaDataType.java | 267 --------
.../shared/kerberos/components/AdAndOr.java | 217 -------
.../shared/kerberos/components/AdIfRelevant.java | 68 ---
.../shared/kerberos/components/AdKdcIssued.java | 313 ----------
.../kerberos/components/AdMandatoryForKdc.java | 68 ---
.../shared/kerberos/components/ETypeInfo.java | 295 ---------
.../shared/kerberos/components/ETypeInfo2.java | 295 ---------
.../kerberos/components/ETypeInfo2Entry.java | 302 ---------
.../shared/kerberos/components/ETypeInfoEntry.java | 249 --------
.../shared/kerberos/components/EncKdcRepPart.java | 674 ---------------------
.../shared/kerberos/components/EncKrbCredPart.java | 444 --------------
.../shared/kerberos/components/EncKrbPrivPart.java | 406 -------------
.../shared/kerberos/components/KdcRep.java | 476 ---------------
.../shared/kerberos/components/KrbCredInfo.java | 647 --------------------
.../shared/kerberos/components/KrbSafeBody.java | 403 ------------
.../shared/kerberos/components/LastReq.java | 297 ---------
.../shared/kerberos/components/LastReqEntry.java | 119 ----
.../shared/kerberos/components/MethodData.java | 278 ---------
.../shared/kerberos/components/PaData.java | 274 ---------
.../shared/kerberos/components/PaEncTimestamp.java | 68 ---
.../shared/kerberos/components/PaEncTsEnc.java | 261 --------
.../shared/kerberos/components/TypedData.java | 296 ---------
.../directory/shared/kerberos/messages/ApRep.java | 226 -------
.../directory/shared/kerberos/messages/AsRep.java | 169 ------
.../shared/kerberos/messages/ChangePasswdData.java | 202 ------
.../shared/kerberos/messages/EncApRepPart.java | 338 -----------
.../shared/kerberos/messages/EncAsRepPart.java | 116 ----
.../shared/kerberos/messages/EncTgsRepPart.java | 116 ----
.../crypto/encryption/CipherTextHandlerTest.java | 241 --------
.../kerberos/shared/messages/value/PaDataTest.java | 84 ---
33 files changed, 8633 deletions(-)
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosDecoder.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosDecoder.java
index 5b5c111dc6..be11572b52 100644
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosDecoder.java
+++ b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosDecoder.java
@@ -29,21 +29,10 @@ import org.apache.directory.api.asn1.ber.tlv.TLVStateEnum;
import org.apache.directory.shared.kerberos.codec.encryptionKey.EncryptionKeyContainer;
import org.apache.directory.shared.kerberos.codec.principalName.PrincipalNameContainer;
import org.apache.directory.shared.kerberos.codec.ticket.TicketContainer;
-import org.apache.directory.shared.kerberos.components.AuthorizationData;
-import org.apache.directory.shared.kerberos.components.EncKdcRepPart;
-import org.apache.directory.shared.kerberos.components.EncKrbPrivPart;
-import org.apache.directory.shared.kerberos.components.EncTicketPart;
-import org.apache.directory.shared.kerberos.components.EncryptedData;
import org.apache.directory.shared.kerberos.components.EncryptionKey;
-import org.apache.directory.shared.kerberos.components.PaEncTsEnc;
import org.apache.directory.shared.kerberos.components.PrincipalName;
import org.apache.directory.shared.kerberos.exceptions.ErrorType;
import org.apache.directory.shared.kerberos.exceptions.KerberosException;
-import org.apache.directory.shared.kerberos.messages.ApRep;
-import org.apache.directory.shared.kerberos.messages.Authenticator;
-import org.apache.directory.shared.kerberos.messages.EncApRepPart;
-import org.apache.directory.shared.kerberos.messages.EncAsRepPart;
-import org.apache.directory.shared.kerberos.messages.EncTgsRepPart;
import org.apache.directory.shared.kerberos.messages.Ticket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -111,139 +100,7 @@ public class KerberosDecoder
return null;
}
-
-
- /**
- * Decode an EncrytedData structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncryptedData
- * @throws KerberosException If the decoding fails
- */
- public static EncryptedData decodeEncryptedData( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode an PaEncTsEnc structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of PaEncTsEnc
- * @throws KerberosException If the decoding fails
- */
- public static PaEncTsEnc decodePaEncTsEnc( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- // Allocate a PaEncTsEnc Container
- //Asn1Container paEncTsEncContainer = new PaEncTsEncContainer();
- // Decode the PaEncTsEnc PDU
- /*
- try
- {
- //Asn1Decoder.decode( stream, paEncTsEncContainer );
- }
- catch ( DecoderException de )
- {
- throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
- }
- */
-
- // get the decoded PaEncTsEnc
- return null;//( ( PaEncTsEncContainer ) paEncTsEncContainer ).getPaEncTsEnc();
- }
-
-
- /**
- * Decode an EncApRepPart structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncApRepPart
- * @throws KerberosException If the decoding fails
- */
- public static EncApRepPart decodeEncApRepPart( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode an EncKdcRepPart structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncKdcRepPart
- * @throws KerberosException If the decoding fails
- */
- public static EncKdcRepPart decodeEncKdcRepPart( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode an EncKrbPrivPart structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncKrbPrivPart
- * @throws KerberosException If the decoding fails
- */
- public static EncKrbPrivPart decodeEncKrbPrivPart( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode an EncTicketPart structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncTicketPart
- * @throws KerberosException If the decoding fails
- */
- public static EncTicketPart decodeEncTicketPart( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- // Allocate a EncTicketPart Container
- /*Asn1Container encTicketPartContainer = new EncTicketPartContainer( stream );
-
- // Decode the EncTicketPart PDU
- try
- {
- Asn1Decoder.decode( stream, encTicketPartContainer );
- }
- catch ( DecoderException de )
- {
- throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
- }
-
- // get the decoded EncTicketPart
- */
- return null; //( ( EncTicketPartContainer ) encTicketPartContainer ).getEncTicketPart();
- }
/**
@@ -337,90 +194,4 @@ public class KerberosDecoder
// get the decoded Ticket
return ( ( TicketContainer ) ticketContainer ).getTicket();
}
-
-
- /**
- * Decode a Authenticator structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of Authenticator
- * @throws KerberosException If the decoding fails
- */
- public static Authenticator decodeAuthenticator( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
-
- return null;
- }
-
-
- /**
- * Decode a AuthorizationData structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of AuthorizationData
- * @throws KerberosException If the decoding fails
- */
- public static AuthorizationData decodeAuthorizationData( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode a AP-REP structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of ApRep
- * @throws KerberosException If the decoding fails
- */
- public static ApRep decodeApRep( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode an EncAsRepPart structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncAsRepPart
- * @throws KerberosException If the decoding fails
- */
- public static EncAsRepPart decodeEncAsRepPart( byte[] data ) throws KerberosException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
-
-
- /**
- * Decode an EncTgsRepPart structure
- *
- * @param data The byte array containing the data structure to decode
- * @return An instance of EncTgsRepPart
- * @throws DecodeException If the decoding fails
- */
- public static EncTgsRepPart decodeEncTgsRepPart( byte[] data ) throws DecoderException
- {
- ByteBuffer stream = ByteBuffer.allocate( data.length );
- stream.put( data );
- stream.flip();
-
- return null;
- }
}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosEncoder.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosEncoder.java
deleted file mode 100644
index b3c6bf8c9a..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosEncoder.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.codec;
-
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-
-
-/**
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class KerberosEncoder
-{
- public static ByteBuffer encode( Asn1Object asn1Obj, boolean isTcp ) throws IOException
- {
- ByteBuffer kerberosMessage = null;
-
- int responseLength = asn1Obj.computeLength();
-
- int bufferLen = responseLength;
-
- if ( isTcp )
- {
- bufferLen += 4;
- }
-
- kerberosMessage = ByteBuffer.allocate( bufferLen );
-
- if ( isTcp )
- {
- kerberosMessage.putInt( responseLength );
- }
-
- try
- {
- asn1Obj.encode( kerberosMessage );
-
- kerberosMessage.flip();
-
- return kerberosMessage;
- }
- catch ( EncoderException e )
- {
- throw new IOException( e.getMessage() );
- }
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/LastReqType.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/LastReqType.java
deleted file mode 100644
index bd200e3fc4..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/LastReqType.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.codec.types;
-
-
-import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
-
-
-/**
- * The LastRequest types
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public enum LastReqType
-{
- /**
- * Constant for the "none" last request type.
- */
- NONE(0, AuthenticationLevel.NONE.toString()),
-
- /**
- * Constant for the "time of initial ticket" last request type.
- */
- TIME_OF_INITIAL_TGT(1, "time of initial ticket"),
-
- /**
- * Constant for the "time of initial request" last request type.
- */
- TIME_OF_INITIAL_REQ(2, "time of initial request"),
-
- /**
- * Constant for the "time of newest ticket" last request type.
- */
- TIME_OF_NEWEST_TGT(3, "time of newest ticket"),
-
- /**
- * Constant for the "time of last renewal" last request type.
- */
- TIME_OF_LAST_RENEWAL(4, "time of last renewal"),
-
- /**
- * Constant for the "time of last request" last request type.
- */
- TIME_OF_LAST_REQ(5, "time of last request"),
-
- /**
- * Constant for the "time of password expiration" last request type.
- */
- TIME_OF_PASSWORD_EXP(6, "time of password expiration");
-
- /**
- * The name of the checksum type.
- */
- private String name;
-
- /**
- * The value/code for the checksum type.
- */
- private int value;
-
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private LastReqType( int value, String name )
- {
- this.value = value;
- this.name = name;
- }
-
-
- /**
- * Returns the last request type when specified by its ordinal.
- *
- * @param type The numeric type
- * @return The last request type.
- */
- public static LastReqType getTypeByValue( int type )
- {
- for ( LastReqType lrt : LastReqType.values() )
- {
- if ( type == lrt.getValue() )
- {
- return lrt;
- }
- }
-
- return NONE;
- }
-
-
- /**
- * Returns the number associated with this last request type.
- *
- * @return The last request type ordinal.
- */
- public int getValue()
- {
- return value;
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString()
- {
- return name + " (" + value + ")";
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java
deleted file mode 100644
index c22ac4540d..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.codec.types;
-
-
-/**
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public enum PaDataType
-{
- /**
- * Constant for the "null" pre-authentication data type.
- */
- NULL(0),
-
- /**
- * Constant for the "TGS request" pre-authentication data type.
- */
- PA_TGS_REQ(1),
-
- /**
- * Constant for the "encrypted timestamp" pre-authentication data type.
- */
- PA_ENC_TIMESTAMP(2),
-
- /**
- * Constant for the "password salt" pre-authentication data type.
- */
- PA_PW_SALT(3),
-
- /**
- * Constant for the "enc unix time" pre-authentication data type.
- */
- PA_ENC_UNIX_TIME(5),
-
- /**
- * Constant for the "sandia secureid" pre-authentication data type.
- */
- PA_SANDIA_SECUREID(6),
-
- /**
- * Constant for the "sesame" pre-authentication data type.
- */
- PA_SESAME(7),
-
- /**
- * Constant for the "OSF DCE" pre-authentication data type.
- */
- PA_OSF_DCE(8),
-
- /**
- * Constant for the "cybersafe secureid" pre-authentication data type.
- */
- PA_CYBERSAFE_SECUREID(9),
-
- /**
- * Constant for the "ASF3 salt" pre-authentication data type.
- */
- PA_ASF3_SALT(10),
-
- /**
- * Constant for the "encryption info" pre-authentication data type.
- */
- PA_ENCTYPE_INFO(11),
-
- /**
- * Constant for the "SAM challenge" pre-authentication data type.
- */
- SAM_CHALLENGE(12),
-
- /**
- * Constant for the "SAM response" pre-authentication data type.
- */
- SAM_RESPONSE(13),
-
- /**
- * Constant for the "PK as request" pre-authentication data type.
- */
- PA_PK_AS_REQ(14),
-
- /**
- * Constant for the "PK as response" pre-authentication data type.
- */
- PA_PK_AS_REP(15),
-
- /**
- * Constant for the "encryption info2" pre-authentication data type.
- */
- PA_ENCTYPE_INFO2( 19 ),
-
- /**
- * Constant for the "use specified key version" pre-authentication data type.
- */
- PA_USE_SPECIFIED_KVNO(20),
-
- /**
- * Constant for the "SAM redirect" pre-authentication data type.
- */
- SAM_REDIRECT(21),
-
- /**
- * Constant for the "get from typed data" pre-authentication data type.
- */
- PA_GET_FROM_TYPED_DATA(22);
-
- /**
- * The value/code for the pre-authentication type.
- */
- private final int value;
-
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private PaDataType( int value )
- {
- this.value = value;
- }
-
-
- /**
- * Returns the number associated with this pre-authentication type.
- *
- * @return The pre-authentication type value.
- */
- public int getValue()
- {
- return value;
- }
-
-
- /**
- * Returns the pre authentication data type when specified by its ordinal.
- *
- * @param type The value
- * @return The pre authentication type.
- */
- public static PaDataType getTypeByValue( int type )
- {
- switch ( type )
- {
- case 1:
- return PA_TGS_REQ;
- case 2:
- return PA_ENC_TIMESTAMP;
- case 3:
- return PA_PW_SALT;
- case 5:
- return PA_ENC_UNIX_TIME;
- case 6:
- return PA_SANDIA_SECUREID;
- case 7:
- return PA_SESAME;
- case 8:
- return PA_OSF_DCE;
- case 9:
- return PA_CYBERSAFE_SECUREID;
- case 10:
- return PA_ASF3_SALT;
- case 11:
- return PA_ENCTYPE_INFO;
- case 12:
- return SAM_CHALLENGE;
- case 13:
- return SAM_RESPONSE;
- case 14:
- return PA_PK_AS_REQ;
- case 15:
- return PA_PK_AS_REQ;
- case 19 :
- return PA_ENCTYPE_INFO2;
- case 20:
- return PA_USE_SPECIFIED_KVNO;
- case 21:
- return SAM_REDIRECT;
- case 22:
- return PA_GET_FROM_TYPED_DATA;
- default:
- return NULL;
- }
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString()
- {
- switch ( this )
- {
- case PA_TGS_REQ:
- return "TGS request." + "(" + value + ")";
-
- case PA_ENC_TIMESTAMP:
- return "Encrypted timestamp." + "(" + value + ")";
-
- case PA_PW_SALT:
- return "password salt" + "(" + value + ")";
-
- case PA_ENC_UNIX_TIME:
- return "enc unix time" + "(" + value + ")";
-
- case PA_SANDIA_SECUREID:
- return "sandia secureid" + "(" + value + ")";
-
- case PA_SESAME:
- return "sesame" + "(" + value + ")";
-
- case PA_OSF_DCE:
- return "OSF DCE" + "(" + value + ")";
-
- case PA_CYBERSAFE_SECUREID:
- return "cybersafe secureid" + "(" + value + ")";
-
- case PA_ASF3_SALT:
- return "ASF3 salt" + "(" + value + ")";
-
- case PA_ENCTYPE_INFO:
- return "Encryption info." + "(" + value + ")";
-
- case SAM_CHALLENGE:
- return "SAM challenge." + "(" + value + ")";
-
- case SAM_RESPONSE:
- return "SAM response." + "(" + value + ")";
-
- case PA_PK_AS_REQ:
- return "PK as request" + "(" + value + ")";
-
- case PA_ENCTYPE_INFO2 :
- return "Encryption info." + "(" + value + ")";
-
- case PA_PK_AS_REP:
- return "PK as response" + "(" + value + ")";
-
- case PA_USE_SPECIFIED_KVNO:
- return "use specified key version" + "(" + value + ")";
-
- case SAM_REDIRECT:
- return "SAM redirect." + "(" + value + ")";
-
- case PA_GET_FROM_TYPED_DATA:
- return "Get from typed data" + "(" + value + ")";
-
- default:
- return "null" + "(" + value + ")";
- }
- }
-}
\ No newline at end of file
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdAndOr.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdAndOr.java
deleted file mode 100644
index 81dc085652..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdAndOr.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The AdAndOr structure is used to store a AD-AND-OR associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * AD-AND-OR ::= SEQUENCE {
- * condition-count [0] Int32,
- * elements [1] <AuthorizationData>
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdAndOr implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( AdAndOr.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The condition-count */
- private int conditionCount;
-
- /** The elements */
- private AuthorizationData elements;
-
- // Storage for computed lengths
- private int conditionCountTagLength;
- private int elementsTagLength;
- private int adAndOrSeqLength;
-
-
- /**
- * Creates a new instance of AdAndOr
- */
- public AdAndOr()
- {
- }
-
-
- /**
- * @return the conditionCount
- */
- public int getConditionCount()
- {
- return conditionCount;
- }
-
-
- /**
- * @param conditionCount the conditionCount to set
- */
- public void setConditionCount( int conditionCount )
- {
- this.conditionCount = conditionCount;
- }
-
-
- /**
- * @return the elements
- */
- public AuthorizationData getElements()
- {
- return elements;
- }
-
-
- /**
- * @param elements the elements to set
- */
- public void setElements( AuthorizationData elements )
- {
- this.elements = elements;
- }
-
-
- /**
- * Compute the AD-AND-OR length
- * <pre>
- * 0x30 L1 AD-AND-OR sequence
- * |
- * +--> 0xA1 L2 condition count tag
- * | |
- * | +--> 0x02 L2-1 condition count (int)
- * |
- * +--> 0xA2 L3 elements tag
- * |
- * +--> 0x30 L3-1 elements (AuthorizationData)
- * </pre>
- */
- @Override
- public int computeLength()
- {
- // Compute the condition count length
- int conditionCountLength = BerValue.getNbBytes( conditionCount );
- conditionCountTagLength = 1 + TLV.getNbBytes( conditionCountLength ) + conditionCountLength;
- adAndOrSeqLength = 1 + TLV.getNbBytes( conditionCountTagLength ) + conditionCountTagLength;
-
- // Compute the elements length
- elementsTagLength = elements.computeLength();
- adAndOrSeqLength += 1 + TLV.getNbBytes( elementsTagLength ) + elementsTagLength;
-
- // Compute the whole sequence length
- return 1 + TLV.getNbBytes( adAndOrSeqLength ) + adAndOrSeqLength;
- }
-
-
- /**
- * Encode the AD-AND-OR message to a PDU.
- *
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The AD-AND-OR SEQ OF Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( adAndOrSeqLength ) );
-
- // the condition-count
- buffer.put( ( byte ) KerberosConstants.AD_AND_OR_CONDITION_COUNT_TAG );
- buffer.put( ( byte ) conditionCountTagLength );
- BerValue.encode( buffer, conditionCount );
-
- // the elements
- buffer.put( ( byte ) KerberosConstants.AD_AND_OR_ELEMENTS_TAG );
- buffer.put( ( byte ) elementsTagLength );
-
- elements.encode( buffer );
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( adAndOrSeqLength )
- + adAndOrSeqLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "AD-AND-OR encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "AD-AND-OR initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "AD-AND-OR : {\n" );
- sb.append( tabs ).append( " condition-count: " ).append( conditionCount ).append( '\n' );
- sb.append( tabs + " elements:" ).append( elements ).append( '\n' );
- sb.append( tabs + "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdIfRelevant.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdIfRelevant.java
deleted file mode 100644
index 76b2b4b0e9..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdIfRelevant.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-/**
- * The AdIfRelevant structure is used to store a AD-IF-RELEVANT associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * AD-IF-RELEVANT ::= AuthorizationData
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdIfRelevant extends AuthorizationData
-{
- /**
- * Creates a new instance of AD-IF-RELEVANT.
- */
- public AdIfRelevant()
- {
- super();
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "AD-IF-RELEVANT : {\n" );
- sb.append( tabs ).append( super.toString( " " + tabs ) ).append( '\n' );
-
- sb.append( tabs + "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java
deleted file mode 100644
index b222408de1..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The AdKdcIssued structure is used to store a AD-KDCIssued associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * AD-KDCIssued ::= SEQUENCE {
- * ad-checksum [0] Checksum,
- * i-realm [1] Realm OPTIONAL,
- * i-sname [2] PrincipalName OPTIONAL,
- * elements [3] AuthorizationData
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdKdcIssued implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( AdKdcIssued.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The checksum */
- private Checksum adChecksum;
-
- /** The realm */
- private String irealm;
-
- /** The PrincipalName */
- private PrincipalName isname;
-
- /** The AuthorizationData */
- private AuthorizationData elements;
-
- // Storage for computed lengths
- private int adCheksumTagLength;
- private int irealmTagLength;
- private byte[] irealmBytes;
- private int isnameTagLength;
- private int elementsTagLength;
- private int adKdcIssuedSeqLength;
-
-
- /**
- * Creates a new instance of AdKdcIssued
- */
- public AdKdcIssued()
- {
- }
-
-
- /**
- * @return the elements
- */
- public AuthorizationData getElements()
- {
- return elements;
- }
-
-
- /**
- * @param elements the elements to set
- */
- public void setElements( AuthorizationData elements )
- {
- this.elements = elements;
- }
-
-
- /**
- * @return the adChecksum
- */
- public Checksum getAdChecksum()
- {
- return adChecksum;
- }
-
-
- /**
- * @param adChecksum the adChecksum to set
- */
- public void setAdChecksum( Checksum adChecksum )
- {
- this.adChecksum = adChecksum;
- }
-
-
- /**
- * @return the irealm
- */
- public String getIRealm()
- {
- return irealm;
- }
-
-
- /**
- * @param irealm the irealm to set
- */
- public void setIRealm( String irealm )
- {
- this.irealm = irealm;
- }
-
-
- /**
- * @return the isname
- */
- public PrincipalName getISName()
- {
- return isname;
- }
-
-
- /**
- * @param isname the isname to set
- */
- public void setISName( PrincipalName isname )
- {
- this.isname = isname;
- }
-
-
- /**
- * Compute the AD-KDCIssued length
- * <pre>
- * 0x30 L1 AD-KDCIssued sequence
- * |
- * +--> 0xA1 L2 ad-checksum tag
- * | |
- * | +--> 0x30 L2-1 ad-checksum value ( Checksum )
- * |
- * +--> 0xA2 L3 i-realm tag
- * | |
- * | +--> 0x1B L3-1 i-realm value ( KerberosString )
- * |
- * +--> 0xA3 L4 i-sname tag
- * | |
- * | +--> 0x30 L4-1 i-sname value ( PrincipalName )
- * |
- * +--> 0xA4 L5 elements tag
- * |
- * +--> 0x30 L5-1 elements (AuthorizationData)
- * </pre>
- */
- @Override
- public int computeLength()
- {
- // Compute the ad-cheksum count length
- adCheksumTagLength = adChecksum.computeLength();
- adKdcIssuedSeqLength = 1 + TLV.getNbBytes( adCheksumTagLength ) + adCheksumTagLength;
-
- // Compute the i-realm length, if any
- if ( irealm != null )
- {
- irealmBytes = Strings.getBytesUtf8( irealm );
- irealmTagLength = 1 + TLV.getNbBytes( irealmBytes.length ) + irealmBytes.length;
- adKdcIssuedSeqLength += 1 + TLV.getNbBytes( irealmTagLength ) + irealmTagLength;
- }
-
- // Compute the i-sname length, if any
- if ( isname != null )
- {
- isnameTagLength = isname.computeLength();
- adKdcIssuedSeqLength += 1 + TLV.getNbBytes( isnameTagLength ) + isnameTagLength;
- }
-
- // Compute the elements count length
- elementsTagLength = elements.computeLength();
- adKdcIssuedSeqLength += 1 + TLV.getNbBytes( elementsTagLength ) + elementsTagLength;
-
- // Compute the whole sequence length
- return 1 + TLV.getNbBytes( adKdcIssuedSeqLength ) + adKdcIssuedSeqLength;
- }
-
-
- /**
- * Encode the AD-KDCIssued message to a PDU.
- *
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The AD-KDCIssued SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( adKdcIssuedSeqLength ) );
-
- // the ad-checksum
- buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_AD_CHECKSUM_TAG );
- buffer.put( ( byte ) adCheksumTagLength );
- adChecksum.encode( buffer );
-
- // the i-realm, if any
- if ( irealm != null )
- {
- buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_I_REALM_TAG );
- buffer.put( ( byte ) irealmTagLength );
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( ( byte ) irealmBytes.length );
- buffer.put( irealmBytes );
- }
-
- // the i-sname, if any
- if ( isname != null )
- {
- buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_I_SNAME_TAG );
- buffer.put( ( byte ) isnameTagLength );
- isname.encode( buffer );
- }
-
- // the elements
- buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_ELEMENTS_TAG );
- buffer.put( ( byte ) elementsTagLength );
- elements.encode( buffer );
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( adKdcIssuedSeqLength )
- + adKdcIssuedSeqLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "AD-KDCIssued encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "AD-KDCIssued initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "AD-KDCIssued : {\n" );
- sb.append( tabs ).append( " ad-cheksum: " ).append( adChecksum.toString( tabs + " " ) ).append( '\n' );
-
- if ( irealm != null )
- {
- sb.append( tabs ).append( " i-realm: " ).append( irealm ).append( '\n' );
- }
-
- if ( isname != null )
- {
- sb.append( tabs ).append( " i-sname: " ).append( isname.toString() ).append( '\n' );
- }
-
- sb.append( tabs + " elements:" ).append( elements.toString( tabs + " " ) ).append( '\n' );
- sb.append( tabs + "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdMandatoryForKdc.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdMandatoryForKdc.java
deleted file mode 100644
index 002db9c1de..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdMandatoryForKdc.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-/**
- * The AdIfRelevant structure is used to store a AD-MANDATORY-FOR-KDC associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * AD-MANDATORY-FOR-KDC ::= AuthorizationData
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdMandatoryForKdc extends AuthorizationData
-{
- /**
- * Creates a new instance of AD-MANDATORY-FOR-KDC.
- */
- public AdMandatoryForKdc()
- {
- super();
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "AD-MANDATORY-FOR-KDC : {\n" );
- sb.append( tabs ).append( super.toString( " " + tabs ) ).append( '\n' );
-
- sb.append( tabs + "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo.java
deleted file mode 100644
index 8c957120eb..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Store a list of ETYPE-INFO
- *
- * The ASN.1 grammar is :
- * <pre>
- * ETYPE-INFO ::= SEQUENCE OF <ETYPE-INFO-ENTRY>
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class ETypeInfo implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( ETypeInfo.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** List of all ETYPE-INFO-ENTRY stored */
- private List<ETypeInfoEntry> etypeInfoEntries;
-
- // Storage for computed lengths
- private int etypeInfoLength;
-
-
- /**
- * Creates a new instance of ETypeInfo.
- */
- public ETypeInfo()
- {
- this.etypeInfoEntries = new ArrayList<>();
- }
-
-
- /**
- * Creates a new instance of ETypeInfo.
- *
- * @param etypeInfoEntries The associated etypeInfoEntries
- */
- public ETypeInfo( ETypeInfoEntry[] etypeInfoEntries )
- {
- if ( etypeInfoEntries == null )
- {
- this.etypeInfoEntries = new ArrayList<>();
- }
- else
- {
- this.etypeInfoEntries = Arrays.asList( etypeInfoEntries );
- }
- }
-
-
- /**
- * Adds an {@link ETypeInfoEntry} to the list
- * @param etypeInfoEntry The ETypeInfoEntry to add
- */
- public void addETypeInfoEntry( ETypeInfoEntry etypeInfoEntry )
- {
- etypeInfoEntries.add( etypeInfoEntry );
- }
-
-
- /**
- * Returns true if this {@link ETypeInfoEntry} contains a specified {@link ETypeInfoEntry}.
- *
- * @param etypeInfoEntry The etypeInfoEntry we are looking for in the existing list
- * @return true if this {@link ETypeInfoEntry} contains a specified {@link ETypeInfoEntry}.
- */
- public boolean contains( ETypeInfoEntry etypeInfoEntry )
- {
- if ( etypeInfoEntries != null )
- {
- return etypeInfoEntries.contains( etypeInfoEntry );
- }
-
- return false;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- int hash = 37;
-
- if ( etypeInfoEntries != null )
- {
- hash = hash * 17 + etypeInfoEntries.size();
-
- for ( ETypeInfoEntry etypeInfoEntry : etypeInfoEntries )
- {
- hash = hash * 17 + etypeInfoEntry.hashCode();
- }
- }
-
- return hash;
- }
-
-
- /**
- * Returns true if two {@link ETypeInfo} are equal.
- *
- * @param that The {@link ETypeInfo} we want to compare with the current one
- * @return true if two {@link ETypeInfo} are equal.
- */
- public boolean equals( ETypeInfo that )
- {
- if ( that == null )
- {
- return false;
- }
-
- // infoEntries can't be null after creation
- if ( etypeInfoEntries.size() != that.etypeInfoEntries.size() )
- {
- return false;
- }
-
- for ( int i = 0; i < etypeInfoEntries.size(); i++ )
- {
- if ( !etypeInfoEntries.get( i ).equals( that.etypeInfoEntries.get( i ) ) )
- {
- return false;
- }
- }
-
- return true;
- }
-
-
- /**
- * Returns the contained {@link ETypeInfoEntry}s as an array.
- *
- * @return An array of {@link ETypeInfoEntry}s.
- */
- public ETypeInfoEntry[] getETypeInfoEntries()
- {
- return etypeInfoEntries.toArray( new ETypeInfoEntry[0] );
- }
-
-
- /**
- * Compute the ETypeInfo length
- * <pre>
- * ETypeInfo :
- *
- * 0x30 L1 ETypeInfo sequence of ETypeInfoEntry
- * |
- * +--> 0x30 L2[1] ETypeInfoEntry[1]
- * |
- * +--> 0x30 L2[2] ETypeInfoEntry[2]
- * |
- * ...
- * |
- * +--> 0x30 L2[n] ETypeInfoEntry[n]
- *
- * where L1 = sum( L2[1], l2[2], ..., L2[n] )
- * </pre>
- */
- public int computeLength()
- {
- // Compute the ETypeInfo length.
- etypeInfoLength = 0;
-
- if ( ( etypeInfoEntries != null ) && !etypeInfoEntries.isEmpty() )
- {
- for ( ETypeInfoEntry infoEntry : etypeInfoEntries )
- {
- int length = infoEntry.computeLength();
- etypeInfoLength += length;
- }
- }
-
- return 1 + TLV.getNbBytes( etypeInfoLength ) + etypeInfoLength;
- }
-
-
- /**
- * Encode the ETypeInfo message to a PDU.
- * <pre>
- * ETypeInfo :
- *
- * 0x30 LL
- * 0x30 LL ETypeInfoEntry[1]
- * 0x30 LL ETypeInfoEntry[1]
- * ...
- * 0x30 LL ETypeInfoEntry[1]
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The ETypeInfoEntry SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( etypeInfoLength ) );
-
- // The ETypeInfoEntry list, if it's not empty
- if ( ( etypeInfoEntries != null ) && !etypeInfoEntries.isEmpty() )
- {
- for ( ETypeInfoEntry infoEntry : etypeInfoEntries )
- {
- infoEntry.encode( buffer );
- }
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_144, 1 + TLV.getNbBytes( etypeInfoLength )
- + etypeInfoLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "ETYPE-INFO encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "ETYPE-INFO initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- boolean isFirst = true;
-
- for ( ETypeInfoEntry infoEntry : etypeInfoEntries )
- {
- if ( isFirst )
- {
- isFirst = false;
- }
- else
- {
- sb.append( ", " );
- }
-
- sb.append( infoEntry.toString() );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo2.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo2.java
deleted file mode 100644
index d44e510715..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo2.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Store a list of ETYPE-INFO2.
- *
- * The ASN.1 grammar is :
- * <pre>
- * ETYPE-INFO2 ::= SEQUENCE SIZE (1..MAX) OF ETYPE-INFO2-ENTRY
- *</pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class ETypeInfo2 implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( ETypeInfo2.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** List of all ETYPE-INFO2-ENTRY stored */
- private List<ETypeInfo2Entry> etypeInfo2Entries;
-
- // Storage for computed lengths
- private int etypeInfo2Length;
-
-
- /**
- * Creates a new instance of ETypeInfo2.
- */
- public ETypeInfo2()
- {
- this.etypeInfo2Entries = new ArrayList<>();
- }
-
-
- /**
- * Creates a new instance of ETypeInfo2.
- *
- * @param etypeInfo2Entries The associated etypeInfo2Entries
- */
- public ETypeInfo2( ETypeInfo2Entry[] etypeInfo2Entries )
- {
- if ( etypeInfo2Entries == null )
- {
- this.etypeInfo2Entries = new ArrayList<>();
- }
- else
- {
- this.etypeInfo2Entries = Arrays.asList( etypeInfo2Entries );
- }
- }
-
-
- /**
- * Adds an {@link ETypeInfo2Entry} to the list
- * @param etypeInfo2Entry The ETypeInfo2Entry to add
- */
- public void addETypeInfo2Entry( ETypeInfo2Entry etypeInfo2Entry )
- {
- etypeInfo2Entries.add( etypeInfo2Entry );
- }
-
-
- /**
- * Returns true if this {@link ETypeInfo2Entry} contains a specified {@link ETypeInfo2Entry}.
- *
- * @param etypeInfo2Entry The etypeInfo2Entry we are looking for in the existing list
- * @return true if this {@link ETypeInfo2Entry} contains a specified {@link ETypeInfo2Entry}.
- */
- public boolean contains( ETypeInfo2Entry etypeInfo2Entry )
- {
- if ( etypeInfo2Entries != null )
- {
- return etypeInfo2Entries.contains( etypeInfo2Entry );
- }
-
- return false;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- int hash = 37;
-
- if ( etypeInfo2Entries != null )
- {
- hash = hash * 17 + etypeInfo2Entries.size();
-
- for ( ETypeInfo2Entry etypeInfo2Entry : etypeInfo2Entries )
- {
- hash = hash * 17 + etypeInfo2Entry.hashCode();
- }
- }
-
- return hash;
- }
-
-
- /**
- * Returns true if two {@link ETypeInfo2} are equal.
- *
- * @param that The {@link ETypeInfo2} we want to compare with the current one
- * @return true if two {@link ETypeInfo2} are equal.
- */
- public boolean equals( ETypeInfo2 that )
- {
- if ( that == null )
- {
- return false;
- }
-
- // infoEntries can't be null after creation
- if ( etypeInfo2Entries.size() != that.etypeInfo2Entries.size() )
- {
- return false;
- }
-
- for ( int i = 0; i < etypeInfo2Entries.size(); i++ )
- {
- if ( !etypeInfo2Entries.get( i ).equals( that.etypeInfo2Entries.get( i ) ) )
- {
- return false;
- }
- }
-
- return true;
- }
-
-
- /**
- * Returns the contained {@link ETypeInfo2Entry}s as an array.
- *
- * @return An array of {@link ETypeInfo2Entry}s.
- */
- public ETypeInfo2Entry[] getETypeInfo2Entries()
- {
- return etypeInfo2Entries.toArray( new ETypeInfo2Entry[0] );
- }
-
-
- /**
- * Compute the ETypeInfo2 length
- * <pre>
- * ETypeInfo2 :
- *
- * 0x30 L1 ETypeInfo2 sequence of ETypeInfo2Entry
- * |
- * +--> 0x30 L2[1] ETypeInfo2Entry[1]
- * |
- * +--> 0x30 L2[2] ETypeInfo2Entry[2]
- * |
- * ...
- * |
- * +--> 0x30 L2[n] ETypeInfo2Entry[n]
- *
- * where L1 = sum( L2[1], l2[2], ..., L2[n] )
- * </pre>
- */
- public int computeLength()
- {
- // Compute the ETypeInfo2 length.
- etypeInfo2Length = 0;
-
- if ( ( etypeInfo2Entries != null ) && !etypeInfo2Entries.isEmpty() )
- {
- for ( ETypeInfo2Entry info2Entry : etypeInfo2Entries )
- {
- int length = info2Entry.computeLength();
- etypeInfo2Length += length;
- }
- }
-
- return 1 + TLV.getNbBytes( etypeInfo2Length ) + etypeInfo2Length;
- }
-
-
- /**
- * Encode the ETypeInfo2 message to a PDU.
- * <pre>
- * ETypeInfo2 :
- *
- * 0x30 LL
- * 0x30 LL ETypeInfo2Entry[1]
- * 0x30 LL ETypeInfo2Entry[1]
- * ...
- * 0x30 LL ETypeInfo2Entry[1]
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The ETypeInfo2Entry SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( etypeInfo2Length ) );
-
- // The ETypeInfo2Entry list, if it's not empty
- if ( ( etypeInfo2Entries != null ) && !etypeInfo2Entries.isEmpty() )
- {
- for ( ETypeInfo2Entry info2Entry : etypeInfo2Entries )
- {
- info2Entry.encode( buffer );
- }
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_144, 1 + TLV.getNbBytes( etypeInfo2Length )
- + etypeInfo2Length, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "ETYPE-INFO encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "ETYPE-INFO initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- boolean isFirst = true;
-
- for ( ETypeInfo2Entry info2Entry : etypeInfo2Entries )
- {
- if ( isFirst )
- {
- isFirst = false;
- }
- else
- {
- sb.append( ", " );
- }
-
- sb.append( info2Entry.toString() );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo2Entry.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo2Entry.java
deleted file mode 100644
index fffe5ed033..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfo2Entry.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Provides encryption info information sent to the client.
- *
- * The ASN.1 grammar for this structure is :
- * <pre>
- * ETYPE-INFO2-ENTRY ::= SEQUENCE {
- * etype [0] Int32,
- * salt [1] KerberosString OPTIONAL,
- * s2kparams [2] OCTET STRING OPTIONAL
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class ETypeInfo2Entry implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( ETypeInfo2Entry.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The encryption type */
- private EncryptionType etype;
-
- /** The salt */
- private String salt;
- private byte[] saltBytes;
-
- /** The s2k params */
- private byte[] s2kparams;
-
- // Storage for computed lengths
- private int etypeTagLength;
- private int saltTagLength;
- private int s2kparamsTagLength;
- private int etypeInfo2EntrySeqLength;
-
-
- /**
- * Creates a new instance of ETypeInfo2Entry.
- */
- public ETypeInfo2Entry()
- {
- }
-
-
- public ETypeInfo2Entry( EncryptionType etype )
- {
- this.etype = etype;
- }
-
-
- /**
- * Returns the salt.
- *
- * @return The salt.
- */
- public String getSalt()
- {
- return salt;
- }
-
-
- /**
- * @param salt the salt to set
- */
- public void setSalt( String salt )
- {
- this.salt = salt;
- }
-
-
- /**
- * Returns the s2kparams.
- *
- * @return The s2kparams.
- */
- public byte[] getS2kparams()
- {
- return s2kparams;
- }
-
-
- /**
- * @param s2kparams the s2kparams to set
- */
- public void setS2kparams( byte[] s2kparams )
- {
- this.s2kparams = s2kparams;
- }
-
-
- /**
- * Returns the {@link EncryptionType}.
- *
- * @return The {@link EncryptionType}.
- */
- public EncryptionType getEType()
- {
- return etype;
- }
-
-
- /**
- * @param etype the encryptionType to set
- */
- public void setEType( EncryptionType etype )
- {
- this.etype = etype;
- }
-
-
- /**
- * Compute the ETYPE-INFO2-ENTRY length
- * <pre>
- * ETYPE-INFO-ENTRY :
- *
- * 0x30 L1 ETYPE-INFO2-ENTRY sequence
- * |
- * +--> 0xA0 L2 etype tag
- * | |
- * | +--> 0x02 L2-1etype (int)
- * |
- * +--> 0xA1 L3 salt tag
- * | |
- * | +--> 0x1B L3-1 salt (KerberosString)
- * |
- * +--> 0xA2 L4 s2kparams tag
- * |
- * +--> 0x04 L4-1 salt (OCTET STRING)
- *
- * where L1 = L2 + length(0xA0) + length(L2) +
- * L3 + length(0xA1) + length(L3) +
- * L4 + length(0xA2) + length( L4)
- * and
- * L2 = L2-1 + length(0x02) + length( L2-1)
- * L3 = L3-1 + length(0x1B) + length( L3-1)
- * L4 = L4-1 + length(0x04) + length( L4-1)
- * </pre>
- */
- public int computeLength()
- {
- // Compute the etype. The Length will always be contained in 1 byte
- int etypeLength = BerValue.getNbBytes( etype.getValue() );
- etypeTagLength = 1 + TLV.getNbBytes( etypeLength ) + etypeLength;
- etypeInfo2EntrySeqLength = 1 + TLV.getNbBytes( etypeTagLength ) + etypeTagLength;
-
- // Compute the salt
- if ( salt != null )
- {
- saltBytes = Strings.getBytesUtf8( salt );
- saltTagLength = 1 + TLV.getNbBytes( saltBytes.length ) + saltBytes.length;
- etypeInfo2EntrySeqLength += 1 + TLV.getNbBytes( saltTagLength ) + saltTagLength;
- }
-
- // Compute the s2kparams
- if ( s2kparams != null )
- {
- s2kparamsTagLength = 1 + TLV.getNbBytes( s2kparams.length ) + s2kparams.length;
- etypeInfo2EntrySeqLength += 1 + TLV.getNbBytes( s2kparamsTagLength ) + s2kparamsTagLength;
- }
-
- return 1 + TLV.getNbBytes( etypeInfo2EntrySeqLength ) + etypeInfo2EntrySeqLength;
- }
-
-
- /**
- * Encode the ETYPE-INFO2-ENTRY message to a PDU.
- * <pre>
- * ETYPE-INFO2-ENTRY :
- *
- * 0x30 LL
- * 0xA0 LL
- * 0x02 0x01 etype
- * 0xA1 LL
- * 0x1B LL salt
- * 0xA2 LL
- * 0x04 LL s2kparams
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The ETYPE-INFO2-ENTRY SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( etypeInfo2EntrySeqLength ) );
-
- // The etype, first the tag, then the value
- buffer.put( ( byte ) KerberosConstants.ETYPE_INFO2_ENTRY_ETYPE_TAG );
- buffer.put( TLV.getBytes( etypeTagLength ) );
- BerValue.encode( buffer, etype.getValue() );
-
- // The salt, first the tag, then the value, if salt is not null
- if ( salt != null )
- {
- // The tag
- buffer.put( ( byte ) KerberosConstants.ETYPE_INFO2_ENTRY_SALT_TAG );
- buffer.put( TLV.getBytes( saltTagLength ) );
-
- // The value
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( TLV.getBytes( saltBytes.length ) );
- buffer.put( saltBytes );
- }
-
- // The s2kparams, first the tag, then the value, if s2kparams is not null
- if ( s2kparams != null )
- {
- buffer.put( ( byte ) KerberosConstants.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG );
- buffer.put( TLV.getBytes( saltTagLength ) );
- BerValue.encode( buffer, s2kparams );
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_145, 1 + TLV.getNbBytes( etypeInfo2EntrySeqLength )
- + etypeInfo2EntrySeqLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "ETYPE-INFO2-ENTRY encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "ETYPE-INFO2-ENTRY initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "ETYPE-INFO2-ENTRY : {\n" );
- sb.append( " etype: " ).append( etype ).append( '\n' );
-
- if ( salt != null )
- {
- sb.append( " salt: " ).append( salt ).append( '\n' );
- }
-
- if ( salt != null )
- {
- sb.append( " s2kparams: " ).append( Strings.dumpBytes( s2kparams ) ).append( '\n' );
- }
-
- sb.append( "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java
deleted file mode 100644
index 0ef3fa39f0..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Provides encryption info information sent to the client.
- *
- * The ASN.1 grammar for this structure is :
- * <pre>
- * ETYPE-INFO-ENTRY ::= SEQUENCE {
- * etype [0] Int32,
- * salt [1] OCTET STRING OPTIONAL
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class ETypeInfoEntry implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( ETypeInfoEntry.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The encryption type */
- private EncryptionType etype;
-
- /** The salt */
- private byte[] salt;
-
- // Storage for computed lengths
- private int etypeTagLength;
- private int saltTagLength;
- private int etypeInfoEntrySeqLength;
-
-
- /**
- * Creates a new instance of ETypeInfoEntry.
- *
- * @param etype the Encryption type
- * @param salt the salt
- */
- public ETypeInfoEntry( EncryptionType etype, byte[] salt )
- {
- this.etype = etype;
- this.salt = salt;
- }
-
-
- /**
- * Creates a new instance of ETypeInfoEntry.
- */
- public ETypeInfoEntry()
- {
- }
-
-
- /**
- * Returns the salt.
- *
- * @return The salt.
- */
- public byte[] getSalt()
- {
- return salt;
- }
-
-
- /**
- * @param salt the salt to set
- */
- public void setSalt( byte[] salt )
- {
- this.salt = salt;
- }
-
-
- /**
- * Returns the {@link EncryptionType}.
- *
- * @return The {@link EncryptionType}.
- */
- public EncryptionType getEType()
- {
- return etype;
- }
-
-
- /**
- * @param etype the encryptionType to set
- */
- public void setEType( EncryptionType etype )
- {
- this.etype = etype;
- }
-
-
- /**
- * Compute the ETYPE-INFO-ENTRY length
- * <pre>
- * ETYPE-INFO-ENTRY :
- *
- * 0x30 L1 ETYPE-INFO-ENTRY sequence
- * |
- * +--> 0xA0 L2 etype tag
- * | |
- * | +--> 0x02 L2-1etype (int)
- * |
- * +--> 0xA1 L3 salt tag
- * |
- * +--> 0x04 L3-1 salt (OCTET STRING)
- *
- * where L1 = L2 + lenght(0xA0) + length(L2) +
- * L3 + lenght(0xA1) + length(L3)
- * and
- * L2 = L2-1 + length(0x02) + length( L2-1)
- * L3 = L3-1 + length(0x04) + length( L3-1)
- * </pre>
- */
- public int computeLength()
- {
- // Compute the etype. The Length will always be contained in 1 byte
- int etypeLength = BerValue.getNbBytes( etype.getValue() );
- etypeTagLength = 1 + TLV.getNbBytes( etypeLength ) + etypeLength;
- etypeInfoEntrySeqLength = 1 + TLV.getNbBytes( etypeTagLength ) + etypeTagLength;
-
- // Compute the salt
- if ( salt != null )
- {
- saltTagLength = 1 + TLV.getNbBytes( salt.length ) + salt.length;
- etypeInfoEntrySeqLength += 1 + TLV.getNbBytes( saltTagLength ) + saltTagLength;
- }
-
- return 1 + TLV.getNbBytes( etypeInfoEntrySeqLength ) + etypeInfoEntrySeqLength;
- }
-
-
- /**
- * Encode the ETYPE-INFO-ENTRY message to a PDU.
- * <pre>
- * ETYPE-INFO-ENTRY :
- *
- * 0x30 LL
- * 0xA1 LL
- * 0x02 0x01 etype
- * 0xA2 LL
- * 0x04 LL salt
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The ETYPE-INFO-ENTRY SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( etypeInfoEntrySeqLength ) );
-
- // The etype, first the tag, then the value
- buffer.put( ( byte ) KerberosConstants.ETYPE_INFO_ENTRY_ETYPE_TAG );
- buffer.put( TLV.getBytes( etypeTagLength ) );
- BerValue.encode( buffer, etype.getValue() );
-
- // The salt, first the tag, then the value, if salt is not null
- if ( salt != null )
- {
- buffer.put( ( byte ) KerberosConstants.ETYPE_INFO_ENTRY_SALT_TAG );
- buffer.put( TLV.getBytes( saltTagLength ) );
- BerValue.encode( buffer, salt );
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_145, 1 + TLV.getNbBytes( etypeInfoEntrySeqLength )
- + etypeInfoEntrySeqLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "ETYPE-INFO-ENTRY encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "ETYPE-INFO-ENTRY initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "ETYPE-INFO-ENTRY : {\n" );
- sb.append( " etype: " ).append( etype ).append( '\n' );
-
- if ( salt != null )
- {
- sb.append( " salt: " ).append( Strings.dumpBytes( salt ) ).append( '\n' );
- }
-
- sb.append( "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
deleted file mode 100644
index 1d37f8a7f8..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.flags.TicketFlags;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Base class for encrypted parts of KDC responses.
- *
- * The ASN.1 grammar for this structure is :
- * <pre>
- * EncKDCRepPart ::= SEQUENCE {
- * key [0] EncryptionKey,
- * last-req [1] LastReq,
- * nonce [2] UInt32,
- * key-expiration [3] KerberosTime OPTIONAL,
- * flags [4] TicketFlags,
- * authtime [5] KerberosTime,
- * starttime [6] KerberosTime OPTIONAL,
- * endtime [7] KerberosTime,
- * renew-till [8] KerberosTime OPTIONAL,
- * srealm [9] Realm,
- * sname [10] PrincipalName,
- * caddr [11] HostAddresses OPTIONAL
- * }
- * </pre>
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class EncKdcRepPart implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( EncKdcRepPart.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** The encryption key */
- private EncryptionKey key;
-
- /** The time of the last request */
- private LastReq lastReq;
-
- /** The nonce */
- private int nonce;
-
- /** The KeyExpiration */
- private KerberosTime keyExpiration; //optional
-
- /** The Ticket flags */
- private TicketFlags flags = new TicketFlags();
-
- /** The initial Authentication time */
- private KerberosTime authTime;
-
- /** The ticket's start time */
- private KerberosTime startTime; //optional
-
- /** The Ticket expiration time */
- private KerberosTime endTime;
-
- /** Maximum endtime in a renewal */
- private KerberosTime renewTill; //optional
-
- /** The server's realm */
- private String srealm;
-
- /** The server's principal */
- private PrincipalName sname;
-
- /** The client addresses */
- private HostAddresses caddr; //optional
-
- // Storage for computed lengths
- private int keyLength;
- private int lastReqLength;
- private int nonceLength;
- private int flagsLength;
- private byte[] srealmBytes;
- private int srealmLength;
- private int snameLength;
- private int caddrLength;
- private int encKdcRepPartSeqLength;
-
-
- /**
- * Creates a new instance of EncKdcRepPart.
- */
- public EncKdcRepPart()
- {
- }
-
-
- /**
- * Returns the auth {@link KerberosTime}.
- *
- * @return The auth {@link KerberosTime}.
- */
- public KerberosTime getAuthTime()
- {
- return authTime;
- }
-
-
- /**
- * Sets the auth {@link KerberosTime}.
- *
- * @param time
- */
- public void setAuthTime( KerberosTime time )
- {
- authTime = time;
- }
-
-
- /**
- * Returns the client {@link HostAddresses}.
- *
- * @return The client {@link HostAddresses}.
- */
- public HostAddresses getClientAddresses()
- {
- return caddr;
- }
-
-
- /**
- * Sets the client {@link HostAddresses}.
- *
- * @param caddr The client addresses
- */
- public void setClientAddresses( HostAddresses caddr )
- {
- this.caddr = caddr;
- }
-
-
- /**
- * Returns the end {@link KerberosTime}.
- *
- * @return The end {@link KerberosTime}.
- */
- public KerberosTime getEndTime()
- {
- return endTime;
- }
-
-
- /**
- * Sets the end {@link KerberosTime}.
- *
- * @param time
- */
- public void setEndTime( KerberosTime time )
- {
- endTime = time;
- }
-
-
- /**
- * Returns the {@link TicketFlags}.
- *
- * @return The {@link TicketFlags}.
- */
- public TicketFlags getFlags()
- {
- return flags;
- }
-
-
- /**
- * Sets the {@link TicketFlags}.
- *
- * @param flags
- */
- public void setFlags( TicketFlags flags )
- {
- this.flags = flags;
- }
-
-
- /**
- * Returns the {@link EncryptionKey}.
- *
- * @return The {@link EncryptionKey}.
- */
- public EncryptionKey getKey()
- {
- return key;
- }
-
-
- /**
- * Sets the {@link EncryptionKey}.
- *
- * @param key
- */
- public void setKey( EncryptionKey key )
- {
- this.key = key;
- }
-
-
- /**
- * Returns the key expiration {@link KerberosTime}.
- *
- * @return The key expiration {@link KerberosTime}.
- */
- public KerberosTime getKeyExpiration()
- {
- return keyExpiration;
- }
-
-
- /**
- * Sets the key expiration {@link KerberosTime}.
- *
- * @param expiration
- */
- public void setKeyExpiration( KerberosTime expiration )
- {
- keyExpiration = expiration;
- }
-
-
- /**
- * Returns the {@link LastReq}.
- *
- * @return The {@link LastReq}.
- */
- public LastReq getLastReq()
- {
- return lastReq;
- }
-
-
- /**
- * Sets the {@link LastReq}.
- *
- * @param lastReq The LastReq to set
- */
- public void setLastReq( LastReq lastReq )
- {
- this.lastReq = lastReq;
- }
-
-
- /**
- * Returns the nonce.
- *
- * @return The nonce.
- */
- public int getNonce()
- {
- return nonce;
- }
-
-
- /**
- * Sets the nonce.
- *
- * @param nonce
- */
- public void setNonce( int nonce )
- {
- this.nonce = nonce;
- }
-
-
- /**
- * Returns the renew till {@link KerberosTime}.
- *
- * @return The renew till {@link KerberosTime}.
- */
- public KerberosTime getRenewTill()
- {
- return renewTill;
- }
-
-
- /**
- * Sets the renew till {@link KerberosTime}.
- *
- * @param till
- */
- public void setRenewTill( KerberosTime till )
- {
- renewTill = till;
- }
-
-
- /**
- * Returns the server {@link PrincipalName}.
- *
- * @return The server {@link PrincipalName}.
- */
- public PrincipalName getSName()
- {
- return sname;
- }
-
-
- /**
- * Sets the server {@link PrincipalName}.
- *
- * @param sname The server PrincipalName
- */
- public void setSName( PrincipalName sname )
- {
- this.sname = sname;
- }
-
-
- /**
- * Returns the server realm.
- *
- * @return The server realm.
- */
- public String getSRealm()
- {
- return srealm;
- }
-
-
- /**
- * Sets the server realm.
- *
- * @param srealm The server realm
- */
- public void setSRealm( String srealm )
- {
- this.srealm = srealm;
- }
-
-
- /**
- * Returns the start {@link KerberosTime}.
- *
- * @return The start {@link KerberosTime}.
- */
- public KerberosTime getStartTime()
- {
- return startTime;
- }
-
-
- /**
- * Sets the start {@link KerberosTime}.
- *
- * @param time he start time to set
- */
- public void setStartTime( KerberosTime time )
- {
- startTime = time;
- }
-
-
- /**
- * Compute the EncKdcRepPart length
- * <pre>
- * EncKdcRepPart :
- *
- * 0x30 L1 EncKdcRepPart sequence
- * |
- * +--> 0xA0 L2 key tag
- * | |
- * | +--> 0x30 L2-1 key ( EncryptionKey)
- * |
- * +--> 0xA1 L3 last-req tag
- * | |
- * | +--> 0x30 L3-1 last-req ( LastReq )
- * |
- * +--> 0xA2 L4 nonce tag
- * | |
- * | +--> 0x02 L4-1 nonce (Int)
- * |
- * [+--> 0xA3 0x11 key-expiration tag]
- * | |
- * | +--> 0x18 0x0F key-expiration ( KerberosTime )
- * |
- * +--> 0xA4 0x07 flags tag
- * | |
- * | +--> 0x03 0x05 flags ( TicketFlags )
- * |
- * +--> 0xA5 0x11 authtime tag
- * | |
- * | +--> 0x18 0x0F authtime ( KerberosTime )
- * |
- * [+--> 0xA6 0x11 starttime tag]
- * | |
- * | +--> 0x18 0x0F starttime ( KerberosTime )
- * |
- * +--> 0xA7 0x11 endtime tag
- * | |
- * | +--> 0x18 0x0F endtime ( KerberosTime )
- * |
- * [+--> 0xA8 0x11 renew-till tag]
- * | |
- * | +--> 0x18 0x0F renew-till ( KerberosTime )
- * |
- * +--> 0xA9 L5 srealm tag
- * | |
- * | +--> 0x1B L5-1 srealm ( KerberosString )
- * |
- * +--> 0xAA L6 sname tag
- * | |
- * | +--> 0x30 L6-1 sname ( PrincipalName )
- * |
- * [+--> 0xAB L7 caddr tag]
- * |
- * +--> 0x30 L7-1 caddr ( HostAddresses )
- * </pre>
- */
- public int computeLength()
- {
- // The key
- keyLength = key.computeLength();
- encKdcRepPartSeqLength = 1 + TLV.getNbBytes( keyLength ) + keyLength;
-
- // The last-req
- lastReqLength = lastReq.computeLength();
- encKdcRepPartSeqLength += 1 + TLV.getNbBytes( lastReqLength ) + lastReqLength;
-
- // The nonce
- nonceLength = BerValue.getNbBytes( nonce );
- nonceLength = 1 + TLV.getNbBytes( nonceLength ) + nonceLength;
- encKdcRepPartSeqLength += 1 + TLV.getNbBytes( nonceLength ) + nonceLength;
-
- // The keyExpiration
- if ( keyExpiration != null )
- {
- encKdcRepPartSeqLength += 1 + 1 + 0x11;
- }
-
- // The flags
- flagsLength = 1 + 1 + 5;
- encKdcRepPartSeqLength += 1 + TLV.getNbBytes( flagsLength ) + flagsLength;
-
- // The authtime
- encKdcRepPartSeqLength += 1 + 1 + 0x11;
-
- // The starttime, if any
- if ( startTime != null )
- {
- encKdcRepPartSeqLength += 1 + 1 + 0x11;
- }
-
- // The endtime
- encKdcRepPartSeqLength += 1 + 1 + 0x11;
-
- // The renew-till, if any
- if ( renewTill != null )
- {
- encKdcRepPartSeqLength += 1 + 1 + 0x11;
- }
-
- // The srealm
- srealmBytes = Strings.getBytesUtf8( srealm );
- srealmLength = 1 + TLV.getNbBytes( srealmBytes.length ) + srealmBytes.length;
- encKdcRepPartSeqLength += 1 + TLV.getNbBytes( srealmLength ) + srealmLength;
-
- // The sname
- snameLength = sname.computeLength();
- encKdcRepPartSeqLength += 1 + TLV.getNbBytes( snameLength ) + snameLength;
-
- // The caddr if any
- if ( caddr != null )
- {
- caddrLength = caddr.computeLength();
- encKdcRepPartSeqLength += 1 + TLV.getNbBytes( caddrLength ) + caddrLength;
- }
-
- return 1 + TLV.getNbBytes( encKdcRepPartSeqLength ) + encKdcRepPartSeqLength;
- }
-
-
- /**
- * Encode the EncKdcRepPart message to a PDU.
- *
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The EncKdcRepPart sequence
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( encKdcRepPartSeqLength ) );
-
- // The Key
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_KEY_TAG );
- buffer.put( TLV.getBytes( keyLength ) );
- key.encode( buffer );
-
- // The LastReq
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_LAST_REQ_TAG );
- buffer.put( TLV.getBytes( lastReqLength ) );
- lastReq.encode( buffer );
-
- // The nonce
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_NONCE_TAG );
- buffer.put( TLV.getBytes( nonceLength ) );
- BerValue.encode( buffer, nonce );
-
- // The key-expiration, if any
- if ( keyExpiration != null )
- {
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_KEY_EXPIRATION_TAG );
- buffer.put( TLV.getBytes( 0x11 ) );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( keyExpiration.getBytes() );
- }
-
- // The flags
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_FLAGS_TAG );
- buffer.put( TLV.getBytes( 0x07 ) );
- BerValue.encode( buffer, flags );
-
- // The authtime
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_AUTH_TIME_TAG );
- buffer.put( TLV.getBytes( 0x11 ) );
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( authTime.getBytes() );
-
- // The starttime if any
- if ( startTime != null )
- {
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_START_TIME_TAG );
- buffer.put( TLV.getBytes( 0x11 ) );
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( startTime.getBytes() );
- }
-
- // The endtime
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_END_TIME_TAG );
- buffer.put( TLV.getBytes( 0x11 ) );
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( endTime.getBytes() );
-
- // The renew-till if any
- if ( renewTill != null )
- {
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_RENEW_TILL_TAG );
- buffer.put( TLV.getBytes( 0x11 ) );
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( renewTill.getBytes() );
- }
-
- // The srealm
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_SREALM_TAG );
- buffer.put( TLV.getBytes( srealmLength ) );
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( TLV.getBytes( srealmBytes.length ) );
- buffer.put( srealmBytes );
-
- // The sname
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_SNAME_TAG );
- buffer.put( TLV.getBytes( snameLength ) );
- sname.encode( buffer );
-
- // The caddr if any
- if ( caddr != null )
- {
- buffer.put( ( byte ) KerberosConstants.ENC_KDC_REP_PART_CADDR_TAG );
- buffer.put( TLV.getBytes( caddrLength ) );
- caddr.encode( buffer );
- }
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_140, 1 + TLV.getNbBytes( 0 ) + 0,
- buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "EncKdcRepPart encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "EncKdcRepPart initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "EncKdcRepPart : \n" );
- sb.append( " key : " ).append( key ).append( "\n" );
- sb.append( " last-req : " ).append( lastReq ).append( "\n" );
- sb.append( " nonce : " ).append( nonce ).append( "\n" );
-
- if ( keyExpiration != null )
- {
- sb.append( " key-expiration : " ).append( keyExpiration ).append( "\n" );
- }
-
- sb.append( " flags : " ).append( flags ).append( "\n" );
- sb.append( " authtime : " ).append( authTime ).append( "\n" );
-
- if ( startTime != null )
- {
- sb.append( " starttime : " ).append( startTime ).append( "\n" );
- }
-
- sb.append( " endtime : " ).append( endTime ).append( "\n" );
-
- if ( renewTill != null )
- {
- sb.append( " renew-till : " ).append( renewTill ).append( "\n" );
- }
-
- sb.append( " srealm : " ).append( srealm ).append( "\n" );
- sb.append( " sname : " ).append( sname ).append( "\n" );
-
- if ( caddr != null )
- {
- sb.append( " caddr : " ).append( caddr ).append( "\n" );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKrbCredPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKrbCredPart.java
deleted file mode 100644
index b028d368b7..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKrbCredPart.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * EncKrbCredPart ::= [APPLICATION 29] SEQUENCE {
- * ticket-info [0] SEQUENCE OF KrbCredInfo,
- * nonce [1] UInt32 OPTIONAL,
- * timestamp [2] KerberosTime OPTIONAL,
- * usec [3] Microseconds OPTIONAL,
- * s-address [4] HostAddress OPTIONAL,
- * r-address [5] HostAddress OPTIONAL
- * }
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class EncKrbCredPart implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( EncKrbCredPart.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** list of KrbCredInfo */
- private List<KrbCredInfo> ticketInfo;
-
- /** the nonce */
- private Integer nonce;
-
- /** the timestamp */
- private KerberosTime timestamp;
-
- /** the microseconds part of the timestamp */
- private Integer usec;
-
- /** the sender's address */
- private HostAddress senderAddress;
-
- /** the recipient's address */
- private HostAddress recipientAddress;
-
- private int ticketInfoSeqLen;
- private int ticketInfoLen;
- private int nonceLen;
- private int timestampLen;
- private byte[] timestampBytes;
- private int usecLen;
- private int senderAddressLen;
- private int recipientAddressLen;
- private int encKrbCredPartSeqLen;
- private int encKrbCredPartLen;
-
-
- /**
- * computing length of EncKrbCredPart:
- *
- * <pre>
- * 0x7D L1
- * |
- * +--> 0x30 L1-2 EncKrbCredPart seq tag
- * |
- * +--> 0xA0 L2 seq of KrbCredInfo tag
- * | |
- * | +--> 0x30 L2-2 seq tag
- * | |
- * | +--> 0x30 LL1 KrbCredInfo
- * | . ....
- * | +--> 0x30 LLn KrbCredInfo
- * |
- * +--> 0xA1 L3 nonce tag
- * | |
- * | +--> 0x02 L3-2 nonce (UInt32)
- * |
- * +--> 0xA2 11 timestamp tag
- * | |
- * | +--> 0x18 0x0F timestamp (KerberosTime)
- * |
- * +--> 0xA3 L4 usec tag
- * | |
- * | +--> 0x02 L4-2 usec (Microseconds)
- * |
- * +--> 0xA4 L5 s-address tag
- * | |
- * | +--> 0x30 L5-2 s-address (HostAddress)
- * |
- * +--> 0xA5 L6 r-address tag
- * |
- * +--> 0x30 L6-2 s-address (HostAddress)
- *
- * </pre>
- */
- @Override
- public int computeLength()
- {
- for ( KrbCredInfo kci : ticketInfo )
- {
- ticketInfoSeqLen += kci.computeLength();
- }
-
- ticketInfoLen = 1 + TLV.getNbBytes( ticketInfoSeqLen ) + ticketInfoSeqLen;
-
- encKrbCredPartSeqLen = 1 + TLV.getNbBytes( ticketInfoLen ) + ticketInfoLen;
-
- if ( nonce != null )
- {
- nonceLen = BerValue.getNbBytes( nonce );
- nonceLen = 1 + TLV.getNbBytes( nonceLen ) + nonceLen;
- encKrbCredPartSeqLen += 1 + TLV.getNbBytes( nonceLen ) + nonceLen;
- }
-
- if ( timestamp != null )
- {
- timestampBytes = timestamp.getBytes();
- timestampLen = 1 + TLV.getNbBytes( timestampBytes.length ) + timestampBytes.length;
- encKrbCredPartSeqLen += 1 + TLV.getNbBytes( timestampLen ) + timestampLen;
- }
-
- if ( usec != null )
- {
- usecLen = BerValue.getNbBytes( usec );
- usecLen = 1 + TLV.getNbBytes( usecLen ) + usecLen;
- encKrbCredPartSeqLen += 1 + TLV.getNbBytes( usecLen ) + usecLen;
- }
-
- if ( senderAddress != null )
- {
- senderAddressLen = senderAddress.computeLength();
- encKrbCredPartSeqLen += 1 + TLV.getNbBytes( senderAddressLen ) + senderAddressLen;
- }
-
- if ( recipientAddress != null )
- {
- recipientAddressLen = recipientAddress.computeLength();
- encKrbCredPartSeqLen += 1 + TLV.getNbBytes( recipientAddressLen ) + recipientAddressLen;
- }
-
- encKrbCredPartLen = 1 + TLV.getNbBytes( encKrbCredPartSeqLen ) + encKrbCredPartSeqLen;
-
- return 1 + TLV.getNbBytes( encKrbCredPartLen ) + encKrbCredPartLen;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- //EncKrbCredPart application tag
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_PART_TAG );
- buffer.put( TLV.getBytes( encKrbCredPartLen ) );
-
- //EncKrbCredPart sequence tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( encKrbCredPartSeqLen ) );
-
- // ticket-info tag
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_TICKET_INFO_TAG );
- buffer.put( TLV.getBytes( ticketInfoLen ) );
-
- // sequence of ticket-info seq tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( ticketInfoSeqLen ) );
-
- for ( KrbCredInfo ki : ticketInfo )
- {
- ki.encode( buffer );
- }
-
- if ( nonce != null )
- {
- // nonce tag and value
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_PART_NONCE_TAG );
- buffer.put( TLV.getBytes( nonceLen ) );
- BerValue.encode( buffer, nonce );
- }
-
- if ( timestamp != null )
- {
- // timestamp tag and value
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_PART_TIMESTAMP_TAG );
- buffer.put( TLV.getBytes( timestampLen ) );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( timestampBytes );
- }
-
- if ( usec != null )
- {
- // usec tag and value
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_PART_USEC_TAG );
- buffer.put( TLV.getBytes( usecLen ) );
- BerValue.encode( buffer, usec );
- }
-
- if ( senderAddress != null )
- {
- // s-address tag and value
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_PART_SENDER_ADDRESS_TAG );
- buffer.put( TLV.getBytes( senderAddressLen ) );
- senderAddress.encode( buffer );
- }
-
- if ( recipientAddress != null )
- {
- // r-address tag and value
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_CRED_PART_RECIPIENT_ADDRESS_TAG );
- buffer.put( TLV.getBytes( recipientAddressLen ) );
- recipientAddress.encode( buffer );
- }
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_740_CANNOT_ENCODE_ENC_KRB_CRED_PART, 1 + TLV.getNbBytes( encKrbCredPartLen )
- + encKrbCredPartLen, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "EncKrbCredPart encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "EncKrbCredPart initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @return the ticketInfo
- */
- public List<KrbCredInfo> getTicketInfo()
- {
- return ticketInfo;
- }
-
-
- /**
- * @param ticketInfo the ticketInfo to set
- */
- public void setTicketInfo( List<KrbCredInfo> ticketInfo )
- {
- this.ticketInfo = ticketInfo;
- }
-
-
- /**
- * @return the nonce
- */
- public Integer getNonce()
- {
- return nonce;
- }
-
-
- /**
- * @param nonce the nonce to set
- */
- public void setNonce( Integer nonce )
- {
- this.nonce = nonce;
- }
-
-
- /**
- * @return the timestamp
- */
- public KerberosTime getTimestamp()
- {
- return timestamp;
- }
-
-
- /**
- * @param timestamp the timestamp to set
- */
- public void setTimestamp( KerberosTime timestamp )
- {
- this.timestamp = timestamp;
- }
-
-
- /**
- * @return the usec
- */
- public Integer getUsec()
- {
- return usec;
- }
-
-
- /**
- * @param usec the usec to set
- */
- public void setUsec( Integer usec )
- {
- this.usec = usec;
- }
-
-
- /**
- * @return the senderAddress
- */
- public HostAddress getSenderAddress()
- {
- return senderAddress;
- }
-
-
- /**
- * @param senderAddress the senderAddress to set
- */
- public void setSenderAddress( HostAddress senderAddress )
- {
- this.senderAddress = senderAddress;
- }
-
-
- /**
- * @return the recipientAddress
- */
- public HostAddress getRecipientAddress()
- {
- return recipientAddress;
- }
-
-
- /**
- * @param recipientAddress the recipientAddress to set
- */
- public void setRecipientAddress( HostAddress recipientAddress )
- {
- this.recipientAddress = recipientAddress;
- }
-
-
- /**
- * add KrbCredInfo object to the existing list of ticket-info
- *
- * @param info the KrbCredInfo
- */
- public void addTicketInfo( KrbCredInfo info )
- {
- if ( info == null )
- {
- throw new IllegalArgumentException();
- }
-
- if ( ticketInfo == null )
- {
- ticketInfo = new ArrayList<>();
- }
-
- ticketInfo.add( info );
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "EncKrbCredPart : {\n" );
-
- sb.append( " ticketInfo: " ).append( ticketInfo ).append( '\n' );
-
- if ( nonce != null )
- {
- sb.append( " nonce: " ).append( nonce ).append( '\n' );
- }
-
- if ( timestamp != null )
- {
- sb.append( " timestamp: " ).append( timestamp ).append( '\n' );
- }
-
- if ( usec != null )
- {
- sb.append( " usec: " ).append( usec ).append( '\n' );
- }
-
- if ( senderAddress != null )
- {
- sb.append( " senderAddress: " ).append( senderAddress ).append( '\n' );
- }
-
- if ( recipientAddress != null )
- {
- sb.append( " recipientAddress: " ).append( recipientAddress ).append( '\n' );
- }
-
- sb.append( "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKrbPrivPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKrbPrivPart.java
deleted file mode 100644
index 54cccd9966..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKrbPrivPart.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The EncKrbPrivPart structure is used to store a EncKrbPrivPart associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * EncKrbPrivPart ::= [APPLICATION 28] SEQUENCE {
- * user-data [0] OCTET STRING,
- * timestamp [1] KerberosTime OPTIONAL,
- * usec [2] Microseconds OPTIONAL,
- * seq-number [3] UInt32 OPTIONAL,
- * s-address [4] HostAddress -- sender's addr --,
- * r-address [5] HostAddress OPTIONAL -- recip's addr
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-//NOTE: this ASN.1 structure is quite identical to KrbSafeBody
-public class EncKrbPrivPart implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( EncKrbPrivPart.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** the user data */
- private byte[] userData;
-
- /** the current time of the sender */
- private KerberosTime timestamp;
-
- /** the microsecond part of the timestamp */
- private Integer usec;
-
- /** the sequence number */
- private Integer seqNumber;
-
- /** the sender's address */
- private HostAddress senderAddress;
-
- /** the recipient's address */
- private HostAddress recipientAddress;
-
- // Storage for computed lengths
- private int userDataLen;
- private int timestampLen;
- private int usecLen;
- private int seqNumberLen;
- private int senderAddressLen;
- private int recipientAddressLen;
- private int encKrbPrivPartSeqLen;
- private int encKrbPrivPartLen;
-
-
- /**
- * @return the userData
- */
- public byte[] getUserData()
- {
- return userData;
- }
-
-
- /**
- * @param userData the userData to set
- */
- public void setUserData( byte[] userData )
- {
- this.userData = userData;
- }
-
-
- /**
- * @return the timestamp
- */
- public KerberosTime getTimestamp()
- {
- return timestamp;
- }
-
-
- /**
- * @param timestamp the timestamp to set
- */
- public void setTimestamp( KerberosTime timestamp )
- {
- this.timestamp = timestamp;
- }
-
-
- /**
- * @return the usec
- */
- public int getUsec()
- {
- if ( usec == null )
- {
- return 0;
- }
-
- return usec;
- }
-
-
- /**
- * @param usec the usec to set
- */
- public void setUsec( int usec )
- {
- this.usec = usec;
- }
-
-
- /**
- * @return the seqNumber
- */
- public int getSeqNumber()
- {
- if ( seqNumber == null )
- {
- return 0;
- }
-
- return seqNumber;
- }
-
-
- /**
- * @param seqNumber the seqNumber to set
- */
- public void setSeqNumber( int seqNumber )
- {
- this.seqNumber = seqNumber;
- }
-
-
- /**
- * @return the senderAddress
- */
- public HostAddress getSenderAddress()
- {
- return senderAddress;
- }
-
-
- /**
- * @param senderAddress the senderAddress to set
- */
- public void setSenderAddress( HostAddress senderAddress )
- {
- this.senderAddress = senderAddress;
- }
-
-
- /**
- * @return the recipientAddress
- */
- public HostAddress getRecipientAddress()
- {
- return recipientAddress;
- }
-
-
- /**
- * @param recipientAddress the recipientAddress to set
- */
- public void setRecipientAddress( HostAddress recipientAddress )
- {
- this.recipientAddress = recipientAddress;
- }
-
-
- /**
- * Compute the EncKrbPrivPart length:
- *
- * <pre>
- * 0x7C L0 EncKrbPrivPart
- * |
- * |
- * 0x30 L1 EncKrbPrivPart SEQ
- * |
- * +--> 0xA0 L2 user-data tag
- * | |
- * | +--> 0x04 L2-1 user-data (Octet String)
- * |
- * +--> 0xA1 0x11 timestamp tag
- * | |
- * | +--> 0x18 0x0F timestamp (KerberosTime)
- * |
- * +--> 0xA2 L3 usec tag
- * | |
- * | +--> 0x02 L3-1 usec (Microseconds)
- * |
- * +--> 0xA3 L4 seq-number tag
- * | |
- * | +--> 0x02 L4-1 seqnumber (UInt32)
- * |
- * +--> 0xA4 L5 s-address tag
- * | |
- * | +--> 0x30 L5-1 s-address (HostAddress)
- * |
- * +--> 0xA5 L6 r-address tag
- * |
- * +--> 0x30 L6-1 r-address (HostAddress)
- * </pre>
- */
- @Override
- public int computeLength()
- {
- userDataLen = 1 + TLV.getNbBytes( userData.length ) + userData.length;
- encKrbPrivPartSeqLen = 1 + TLV.getNbBytes( userDataLen ) + userDataLen;
-
- senderAddressLen = senderAddress.computeLength();
- encKrbPrivPartSeqLen += 1 + TLV.getNbBytes( senderAddressLen ) + senderAddressLen;
-
- if ( timestamp != null )
- {
- timestampLen = timestamp.getBytes().length;
- timestampLen = 1 + TLV.getNbBytes( timestampLen ) + timestampLen;
- encKrbPrivPartSeqLen += 1 + TLV.getNbBytes( timestampLen ) + timestampLen;
- }
-
- if ( usec != null )
- {
- usecLen = BerValue.getNbBytes( usec );
- usecLen = 1 + TLV.getNbBytes( usecLen ) + usecLen;
- encKrbPrivPartSeqLen += 1 + TLV.getNbBytes( usecLen ) + usecLen;
- }
-
- if ( seqNumber != null )
- {
- seqNumberLen = BerValue.getNbBytes( seqNumber );
- seqNumberLen = 1 + TLV.getNbBytes( seqNumberLen ) + seqNumberLen;
- encKrbPrivPartSeqLen += 1 + TLV.getNbBytes( seqNumberLen ) + seqNumberLen;
- }
-
- if ( recipientAddress != null )
- {
- recipientAddressLen = recipientAddress.computeLength();
- encKrbPrivPartSeqLen += 1 + TLV.getNbBytes( recipientAddressLen ) + recipientAddressLen;
- }
-
- encKrbPrivPartLen = 1 + TLV.getNbBytes( encKrbPrivPartSeqLen ) + encKrbPrivPartSeqLen;
-
- return 1 + TLV.getNbBytes( encKrbPrivPartLen ) + encKrbPrivPartLen;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- buffer.put( ( byte ) KerberosConstants.ENC_KRB_PRIV_PART_TAG );
- buffer.put( TLV.getBytes( encKrbPrivPartLen ) );
-
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( encKrbPrivPartSeqLen ) );
-
- // user-data
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_USER_DATA_TAG );
- buffer.put( TLV.getBytes( userDataLen ) );
- BerValue.encode( buffer, userData );
-
- if ( timestamp != null )
- {
- // timestamp tag
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_TIMESTAMP_TAG );
- buffer.put( TLV.getBytes( timestampLen ) );
-
- // timestamp value
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( timestamp.getBytes() );
- }
-
- if ( usec != null )
- {
- // usec
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_USEC_TAG );
- buffer.put( TLV.getBytes( usecLen ) );
- BerValue.encode( buffer, usec );
- }
-
- if ( seqNumber != null )
- {
- // seq-number
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_SEQ_NUMBER_TAG );
- buffer.put( TLV.getBytes( seqNumberLen ) );
- BerValue.encode( buffer, seqNumber );
- }
-
- // s-address
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_SENDER_ADDRESS_TAG );
- buffer.put( TLV.getBytes( senderAddressLen ) );
- senderAddress.encode( buffer );
-
- if ( recipientAddress != null )
- {
- // s-address
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_RECIPIENT_ADDRESS_TAG );
- buffer.put( TLV.getBytes( recipientAddressLen ) );
- recipientAddress.encode( buffer );
- }
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_735_CANNOT_ENCODE_KRBSAFEBODY, 1 + TLV.getNbBytes( encKrbPrivPartLen )
- + encKrbPrivPartLen, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "EncKrbPrivPart encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "EncKrbPrivPart initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "EncKrbPrivPart : {\n" );
- sb.append( " user-data: " ).append( Strings.dumpBytes( userData ) ).append( '\n' );
-
- if ( timestamp != null )
- {
- sb.append( " timestamp: " ).append( timestamp.getDate() ).append( '\n' );
- }
-
- if ( usec != null )
- {
- sb.append( " usec: " ).append( usec ).append( '\n' );
- }
-
- if ( seqNumber != null )
- {
- sb.append( " seq-number: " ).append( seqNumber ).append( '\n' );
- }
-
- sb.append( " s-address: " ).append( senderAddress ).append( '\n' );
-
- if ( recipientAddress != null )
- {
- sb.append( " r-address: " ).append( recipientAddress ).append( '\n' );
- }
-
- sb.append( "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcRep.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcRep.java
deleted file mode 100644
index f164eaa70d..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcRep.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.messages.KerberosMessage;
-import org.apache.directory.shared.kerberos.messages.Ticket;
-
-
-/**
- * The KDC-REP data structure. It will store the object described by the ASN.1 grammar :
- * <pre>
- * KDC-REP ::= SEQUENCE {
- * pvno [0] INTEGER (5),
- * msg-type [1] INTEGER (11 -- AS -- | 13 -- TGS --),
- * padata [2] SEQUENCE OF PA-DATA OPTIONAL
- * -- NOTE: not empty --,
- * crealm [3] Realm,
- * cname [4] <PrincipalName>,
- * ticket [5] <Ticket@gt;,
- * enc-part [6] <EncryptedData>
- * -- EncASRepPart or EncTGSRepPart,
- * -- as appropriate
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class KdcRep extends KerberosMessage
-{
- /** The PA-DATAs */
- private List<PaData> paData;
-
- /** The client realm */
- private String crealm;
-
- /** A storage for a byte array representation of the realm */
- private byte[] crealmBytes;
-
- /** The client principal name */
- private PrincipalName cname;
-
- /** The ticket tickets */
- private Ticket ticket;
-
- /** Encoded part */
- private EncryptedData encPart;
-
- /** The decoded KDC-REP part */
- protected EncKdcRepPart encKdcRepPart;
-
- // Storage for computed lengths
- private int pvnoLength;
- private int msgTypeLength;
- private int paDataLength;
- private int paDataSeqLength;
- private int[] paDataLengths;
- private int cnameLength;
- private int crealmLength;
- private int ticketLength;
- private int encPartLength;
- private int kdcRepSeqLength;
- private int kdcRepLength;
-
-
- /**
- * Creates a new instance of KDC-REP.
- */
- public KdcRep( KerberosMessageType msgType )
- {
- super( msgType );
- paData = new ArrayList<>();
- }
-
-
- /**
- * @return the pvno
- */
- public int getPvno()
- {
- return getProtocolVersionNumber();
- }
-
-
- /**
- * @param pvno the pvno to set
- */
- public void setPvno( int pvno )
- {
- setProtocolVersionNumber( pvno );
- }
-
-
- /**
- * @return the paData
- */
- public List<PaData> getPaData()
- {
- return paData;
- }
-
-
- /**
- * @param paData the paData to set
- */
- public void addPaData( PaData paData )
- {
- this.paData.add( paData );
- }
-
-
- /**
- * Returns the client realm.
- *
- * @return The client realm.
- */
- public String getCRealm()
- {
- return crealm;
- }
-
-
- /**
- * Set the client realm
- * @param crealm the client realm
- */
- public void setCRealm( String crealm )
- {
- this.crealm = crealm;
- }
-
-
- /**
- * Returns the client {@link PrincipalName}.
- *
- * @return The client {@link PrincipalName}.
- */
- public PrincipalName getCName()
- {
- return cname;
- }
-
-
- /**
- * Set the client principalName
- * @param cname the client principalName
- */
- public void setCName( PrincipalName cname )
- {
- this.cname = cname;
- }
-
-
- /**
- * Returns the {@link Ticket}
- *
- * @return The {@link Ticket}
- */
- public Ticket getTicket()
- {
- return ticket;
- }
-
-
- /**
- * Set the Ticket
- * @param ticket the ticket to set
- */
- public void setTicket( Ticket ticket )
- {
- this.ticket = ticket;
- }
-
-
- /**
- * Returns the encrypted part as {@link EncryptedData}.
- *
- * @return The encrypted part as {@link EncryptedData}.
- */
- public EncryptedData getEncPart()
- {
- return encPart;
- }
-
-
- /**
- * @param encPart the encPart to set
- */
- public void setEncPart( EncryptedData encPart )
- {
- this.encPart = encPart;
- }
-
-
- /**
- * @return the encKdcRepPart
- */
- public EncKdcRepPart getEncKdcRepPart()
- {
- return encKdcRepPart;
- }
-
-
- /**
- * @param encKdcRepPart the encKdcRepPart to set
- */
- public void setEncKdcRepPart( EncKdcRepPart encKdcRepPart )
- {
- this.encKdcRepPart = encKdcRepPart;
- }
-
-
- /**
- * Compute the KDC-REP length
- * <pre>
- * KDC-REP :
- *
- * 0x30 L1 KDC-REP sequence
- * |
- * +--> 0xA0 0x03 pvno tag
- * | |
- * | +--> 0x02 0x01 0x05 pvno (5)
- * |
- * +--> 0xA1 0x03 msg-type tag
- * | |
- * | +--> 0x02 0x01 0x0B/0x0D msg-type : either AS-REP (0x0B) or TGS-REP (0x0D)
- * |
- * +--> 0xA2 L2 pa-data tag
- * | |
- * | +--> 0x30 L2-1 pa-data SEQ
- * | |
- * | +--> 0x30 L2-1-1 pa-data
- * | |
- * | +--> 0x30 L2-1-2 pa-data
- * | :
- * |
- * +--> 0xA3 L3 crealm tag
- * | |
- * | +--> 0x1B L3-1 crealm
- * |
- * +--> 0xA4 L4 cname tag
- * | |
- * | +--> 0x30 L4-1 cname
- * |
- * +--> 0xA5 L5 ticket tag
- * | |
- * | +--> 0x61 L5-1 ticket
- * |
- * +--> 0xA6 L6 enc-part tag
- * |
- * +--> 0x30 L6-1 enc-part
- *
- * </pre>
- */
- public int computeLength()
- {
- // The pvno length
- pvnoLength = 1 + 1 + 1;
- kdcRepSeqLength = 1 + TLV.getNbBytes( pvnoLength ) + pvnoLength;
-
- // The msg-type length
- msgTypeLength = 1 + 1 + 1;
- kdcRepSeqLength += 1 + TLV.getNbBytes( msgTypeLength ) + msgTypeLength;
-
- // Compute the pa-data length.
- if ( !paData.isEmpty() )
- {
- paDataLengths = new int[paData.size()];
- int pos = 0;
- paDataSeqLength = 0;
-
- for ( PaData paDataElem : paData )
- {
- paDataLengths[pos] = paDataElem.computeLength();
- paDataSeqLength += paDataLengths[pos];
- pos++;
- }
-
- paDataLength = 1 + TLV.getNbBytes( paDataSeqLength ) + paDataSeqLength;
- kdcRepSeqLength += 1 + TLV.getNbBytes( paDataLength ) + paDataLength;
- }
-
- // The crealm length
- crealmBytes = Strings.getBytesUtf8( crealm );
- crealmLength = 1 + TLV.getNbBytes( crealmBytes.length ) + crealmBytes.length;
- kdcRepSeqLength += 1 + TLV.getNbBytes( crealmLength ) + crealmLength;
-
- // Compute the client principalName length
- cnameLength = cname.computeLength();
- kdcRepSeqLength += 1 + TLV.getNbBytes( cnameLength ) + cnameLength;
-
- // Compute the ticket length
- ticketLength = ticket.computeLength();
- kdcRepSeqLength += 1 + TLV.getNbBytes( ticketLength ) + ticketLength;
-
- // Compute the encrypted part
- encPartLength = encPart.computeLength();
- kdcRepSeqLength += 1 + TLV.getNbBytes( encPartLength ) + encPartLength;
-
- // compute the global size
- kdcRepLength = 1 + TLV.getNbBytes( kdcRepSeqLength ) + kdcRepSeqLength;
-
- return kdcRepLength;
- }
-
-
- /**
- * Encode the KDC-REP component
- *
- * @param buffer The buffer containing the encoded result
- * @return The encoded component
- * @throws EncoderException If the encoding failed
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- // The KDC-REP SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( kdcRepSeqLength ) );
-
- // The PVNO -----------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_PVNO_TAG );
- buffer.put( TLV.getBytes( pvnoLength ) );
-
- // The value
- BerValue.encode( buffer, getProtocolVersionNumber() );
-
- // The MSG-TYPE if any ------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_MSG_TYPE_TAG );
- buffer.put( TLV.getBytes( msgTypeLength ) );
-
- // The value
- BerValue.encode( buffer, getMessageType().getValue() );
-
- // The PD-DATA if any -------------------------------------------------
- if ( !paData.isEmpty() )
- {
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_PA_DATA_TAG );
- buffer.put( TLV.getBytes( paDataLength ) );
-
- // The sequence
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( paDataSeqLength ) );
-
- // The values
- for ( PaData paDataElem : paData )
- {
- paDataElem.encode( buffer );
- }
- }
-
- // The CREALM ---------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_CREALM_TAG );
- buffer.put( TLV.getBytes( crealmLength ) );
-
- // The value
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( TLV.getBytes( crealmBytes.length ) );
- buffer.put( crealmBytes );
-
- // The CNAME ----------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_CNAME_TAG );
- buffer.put( TLV.getBytes( cnameLength ) );
-
- // The value
- cname.encode( buffer );
-
- // The TICKET ---------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_TICKET_TAG );
- buffer.put( TLV.getBytes( ticketLength ) );
-
- // The value
- ticket.encode( buffer );
-
- // The ENC-PART -------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.KDC_REP_ENC_PART_TAG );
- buffer.put( TLV.getBytes( encPartLength ) );
-
- // The value
- encPart.encode( buffer );
-
- return buffer;
- }
-
-
- /**
- * Pretty print the instance
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append(
- "\n>-------------------------------------------------------------------------------\n" );
- sb.append( tabs ).append( "KdcRep : " );
-
- if ( getMessageType() == KerberosMessageType.AS_REP )
- {
- sb.append( "AS-REP" ).append( '\n' );
- }
- else if ( getMessageType() == KerberosMessageType.TGS_REP )
- {
- sb.append( "TGS-REP" ).append( '\n' );
- }
- else
- {
- sb.append( "Unknown" ).append( '\n' );
- }
-
- sb.append( tabs ).append( "pvno : " ).append( getProtocolVersionNumber() ).append( '\n' );
-
- sb.append( tabs ).append( "msg-type : " ).append( getMessageType() ).append( '\n' );
-
- for ( PaData paDataElem : paData )
- {
- sb.append( tabs ).append( "padata : " ).append( paDataElem.toString( tabs + " " ) ).append( '\n' );
- }
-
- sb.append( tabs ).append( "crealm : " ).append( crealm ).append( '\n' );
- sb.append( tabs ).append( "cname : " ).append( cname ).append( '\n' );
- sb.append( ticket.toString( tabs ) );
- sb.append( encPart.toString( tabs ) );
- sb.append( tabs ).append(
- "\n-------------------------------------------------------------------------------<\n" );
-
- return sb.toString();
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbCredInfo.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbCredInfo.java
deleted file mode 100644
index 39891986bc..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbCredInfo.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.flags.TicketFlags;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * KrbCredInfo ::= SEQUENCE {
- * key [0] EncryptionKey,
- * prealm [1] Realm OPTIONAL,
- * pname [2] PrincipalName OPTIONAL,
- * flags [3] TicketFlags OPTIONAL,
- * authtime [4] KerberosTime OPTIONAL,
- * starttime [5] KerberosTime OPTIONAL,
- * endtime [6] KerberosTime OPTIONAL,
- * renew-till [7] KerberosTime OPTIONAL,
- * srealm [8] Realm OPTIONAL,
- * sname [9] PrincipalName OPTIONAL,
- * caddr [10] HostAddresses OPTIONAL
- * }
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class KrbCredInfo implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( KrbCredInfo.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** the encryption key */
- private EncryptionKey key;
-
- /** principal identity's realm */
- private String pRealm;
-
- /** principal identity's name */
- private PrincipalName pName;
-
- /** the ticket flags */
- private TicketFlags ticketFlags;
-
- /** the time of initial authentication */
- private KerberosTime authTime;
-
- /** the time after which the ticket is valid */
- private KerberosTime startTime;
-
- /** the expiration time of ticket */
- private KerberosTime endTime;
-
- /** the maximum endtime that may be included in a renewal */
- private KerberosTime renewtill;
-
- /** searver's realm */
- private String sRealm;
-
- /** server's principal name */
- private PrincipalName sName;
-
- /** the addresses for which the ticket can be used */
- private HostAddresses clientAddresses;
-
- private int keyLen;
- private int pRealmLen;
- private byte[] pRealmBytes;
- private int pNameLen;
- private int ticketFlagsLen;
- private int authTimeLen;
- private byte[] authTimeBytes;
- private int startTimeLen;
- private byte[] startTimeBytes;
- private int endTimeLen;
- private byte[] endTimeBytes;
- private int renewtillLen;
- private byte[] renewtillBytes;
- private int sRealmLen;
- private byte[] sRealmBytes;
- private int sNameLen;
- private int clientAddressesLen;
- private int krbKredInfoSeqLen;
-
-
- /**
- * Calculate the length od KrbCredInfo:
- *
- * <pre>
- * 0x30 L1 KrbCredInfo SEQ tag
- * |
- * |
- * +--> 0xA0 L2 key tag
- * | |
- * | +--> 0x30 L2-2 key
- * |
- * +--> [0xA1 L3 prealm tag
- * | |
- * | +--> 0x1B L3-2 prealm]
- * |
- * +--> [0xA2 L4 pname tag
- * | |
- * | +--> 0x30 L4-2 pname]
- * |
- * +--> [0xA3 L5 flags tag
- * | |
- * | +--> 0x02 L5-2 flags]
- * |
- * +--> [0xA4 0x11 authtime tag
- * | |
- * | +--> 0x18 0x1F authtime]
- * |
- * +--> [0xA5 0x11 starttime tag
- * | |
- * | +--> 0x18 0x1F starttime]
- * |
- * +--> [0xA6 0x11 endtime tag
- * | |
- * | +--> 0x18 0x1F endtime]
- * |
- * +--> [0xA7 0x11 renew-till tag
- * | |
- * | +--> 0x18 0x1F renew-till]
- * |
- * +--> [0xA8 L6 srealm tag
- * | |
- * | +--> 0x1B L6-2 srealm]
- * |
- * +--> [0xA9 L7 sname tag
- * | |
- * | +--> 0x30 L7-2 sname]
- * |
- * +--> [0xAA L8 caddr tag
- * |
- * +--> 0x30 L8-2 caddr
- * </pre>
- */
- @Override
- public int computeLength()
- {
- keyLen = key.computeLength();
- krbKredInfoSeqLen = 1 + TLV.getNbBytes( keyLen ) + keyLen;
-
- if ( pRealm != null )
- {
- pRealmBytes = Strings.getBytesUtf8( pRealm );
- pRealmLen = 1 + TLV.getNbBytes( pRealmBytes.length ) + pRealmBytes.length;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( pRealmLen ) + pRealmLen;
- }
-
- if ( pName != null )
- {
- pNameLen = pName.computeLength();
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( pNameLen ) + pNameLen;
- }
-
- if ( ticketFlags != null )
- {
- ticketFlagsLen = ticketFlags.getData().length;
- ticketFlagsLen = 1 + TLV.getNbBytes( ticketFlagsLen ) + ticketFlagsLen;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( ticketFlagsLen ) + ticketFlagsLen;
- }
-
- if ( authTime != null )
- {
- authTimeBytes = authTime.getBytes();
- authTimeLen = 1 + TLV.getNbBytes( authTimeBytes.length ) + authTimeBytes.length;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( authTimeLen ) + authTimeLen;
- }
-
- if ( startTime != null )
- {
- startTimeBytes = startTime.getBytes();
- startTimeLen = 1 + TLV.getNbBytes( startTimeBytes.length ) + startTimeBytes.length;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( startTimeLen ) + startTimeLen;
- }
-
- if ( endTime != null )
- {
- endTimeBytes = endTime.getBytes();
- endTimeLen = 1 + TLV.getNbBytes( endTimeBytes.length ) + endTimeBytes.length;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( endTimeLen ) + endTimeLen;
- }
-
- if ( renewtill != null )
- {
- renewtillBytes = renewtill.getBytes();
- renewtillLen = 1 + TLV.getNbBytes( renewtillBytes.length ) + renewtillBytes.length;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( renewtillLen ) + renewtillLen;
- }
-
- if ( sRealm != null )
- {
- sRealmBytes = Strings.getBytesUtf8( sRealm );
- sRealmLen = 1 + TLV.getNbBytes( sRealmBytes.length ) + sRealmBytes.length;
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( sRealmLen ) + sRealmLen;
- }
-
- if ( sName != null )
- {
- sNameLen = sName.computeLength();
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( sNameLen ) + sNameLen;
- }
-
- if ( clientAddresses != null )
- {
- clientAddressesLen = clientAddresses.computeLength();
- krbKredInfoSeqLen += 1 + TLV.getNbBytes( clientAddressesLen ) + clientAddressesLen;
- }
-
- return 1 + TLV.getNbBytes( krbKredInfoSeqLen ) + krbKredInfoSeqLen;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( krbKredInfoSeqLen ) );
-
- //key tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_KEY_TAG );
- buffer.put( TLV.getBytes( keyLen ) );
- key.encode( buffer );
-
- if ( pRealm != null )
- {
- // prealm tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_PREALM_TAG );
- buffer.put( TLV.getBytes( pRealmLen ) );
-
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( TLV.getBytes( pRealmBytes.length ) );
- buffer.put( pRealmBytes );
- }
-
- if ( pName != null )
- {
- // pname tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_PNAME_TAG );
- buffer.put( TLV.getBytes( pNameLen ) );
- pName.encode( buffer );
- }
-
- if ( ticketFlags != null )
- {
- // flags tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_FLAGS_TAG );
- buffer.put( TLV.getBytes( ticketFlagsLen ) );
- BerValue.encode( buffer, ticketFlags );
- }
-
- if ( authTime != null )
- {
- // authtime tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_AUTHTIME_TAG );
- buffer.put( TLV.getBytes( authTimeLen ) );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( authTimeBytes );
- }
-
- if ( startTime != null )
- {
- // starttime tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_STARTTIME_TAG );
- buffer.put( TLV.getBytes( startTimeLen ) );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( startTimeBytes );
- }
-
- if ( endTime != null )
- {
- // endtime tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_ENDTIME_TAG );
- buffer.put( TLV.getBytes( endTimeLen ) );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( endTimeBytes );
- }
-
- if ( renewtill != null )
- {
- // renewtill tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_RENEWTILL_TAG );
- buffer.put( TLV.getBytes( renewtillLen ) );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( renewtillBytes );
- }
-
- if ( sRealm != null )
- {
- // srealm tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_SREALM_TAG );
- buffer.put( TLV.getBytes( sRealmLen ) );
-
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( TLV.getBytes( sRealmBytes.length ) );
- buffer.put( sRealmBytes );
- }
-
- if ( sName != null )
- {
- // sname tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_SNAME_TAG );
- buffer.put( TLV.getBytes( sNameLen ) );
- sName.encode( buffer );
- }
-
- if ( clientAddresses != null )
- {
- // caddr tag and value
- buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_CADDR_TAG );
- buffer.put( TLV.getBytes( clientAddressesLen ) );
- clientAddresses.encode( buffer );
- }
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_739_CANNOT_ENCODE_KRB_CRED_INFO, 1 + TLV.getNbBytes( krbKredInfoSeqLen )
- + krbKredInfoSeqLen, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "KrbCredInfo encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "KrbCredInfo initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @return the key
- */
- public EncryptionKey getKey()
- {
- return key;
- }
-
-
- /**
- * @param key the key to set
- */
- public void setKey( EncryptionKey key )
- {
- this.key = key;
- }
-
-
- /**
- * @return the pRealm
- */
- public String getpRealm()
- {
- return pRealm;
- }
-
-
- /**
- * @param pRealm the pRealm to set
- */
- public void setpRealm( String pRealm )
- {
- this.pRealm = pRealm;
- }
-
-
- /**
- * @return the pName
- */
- public PrincipalName getpName()
- {
- return pName;
- }
-
-
- /**
- * @param pName the pName to set
- */
- public void setpName( PrincipalName pName )
- {
- this.pName = pName;
- }
-
-
- /**
- * @return the ticketFlags
- */
- public TicketFlags getTicketFlags()
- {
- return ticketFlags;
- }
-
-
- /**
- * @param ticketFlags the ticketFlags to set
- */
- public void setTicketFlags( TicketFlags ticketFlags )
- {
- this.ticketFlags = ticketFlags;
- }
-
-
- /**
- * @return the authTime
- */
- public KerberosTime getAuthTime()
- {
- return authTime;
- }
-
-
- /**
- * @param authTime the authTime to set
- */
- public void setAuthTime( KerberosTime authTime )
- {
- this.authTime = authTime;
- }
-
-
- /**
- * @return the startTime
- */
- public KerberosTime getStartTime()
- {
- return startTime;
- }
-
-
- /**
- * @param startTime the startTime to set
- */
- public void setStartTime( KerberosTime startTime )
- {
- this.startTime = startTime;
- }
-
-
- /**
- * @return the endTime
- */
- public KerberosTime getEndTime()
- {
- return endTime;
- }
-
-
- /**
- * @param endTime the endTime to set
- */
- public void setEndTime( KerberosTime endTime )
- {
- this.endTime = endTime;
- }
-
-
- /**
- * @return the renewtill
- */
- public KerberosTime getRenewtill()
- {
- return renewtill;
- }
-
-
- /**
- * @param renewtill the renewtill to set
- */
- public void setRenewtill( KerberosTime renewtill )
- {
- this.renewtill = renewtill;
- }
-
-
- /**
- * @return the sRealm
- */
- public String getsRealm()
- {
- return sRealm;
- }
-
-
- /**
- * @param sRealm the sRealm to set
- */
- public void setsRealm( String sRealm )
- {
- this.sRealm = sRealm;
- }
-
-
- /**
- * @return the sName
- */
- public PrincipalName getsName()
- {
- return sName;
- }
-
-
- /**
- * @param sName the sName to set
- */
- public void setsName( PrincipalName sName )
- {
- this.sName = sName;
- }
-
-
- /**
- * @return the clientAddresses
- */
- public HostAddresses getClientAddresses()
- {
- return clientAddresses;
- }
-
-
- /**
- * @param clientAddresses the clientAddresses to set
- */
- public void setClientAddresses( HostAddresses clientAddresses )
- {
- this.clientAddresses = clientAddresses;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "KrbCredInfo : {\n" );
- sb.append( " key: " ).append( key ).append( '\n' );
-
- if ( pRealm != null )
- {
- sb.append( " pRealm: " ).append( pRealm ).append( '\n' );
- }
-
- if ( pName != null )
- {
- sb.append( " pName: " ).append( pName ).append( '\n' );
- }
-
- if ( ticketFlags != null )
- {
- sb.append( " ticketFlags: " ).append( ticketFlags ).append( '\n' );
- }
-
- if ( authTime != null )
- {
- sb.append( " authTime: " ).append( authTime ).append( '\n' );
- }
-
- if ( startTime != null )
- {
- sb.append( " startTime: " ).append( startTime ).append( '\n' );
- }
-
- if ( endTime != null )
- {
- sb.append( " endTime: " ).append( endTime ).append( '\n' );
- }
-
- if ( renewtill != null )
- {
- sb.append( " renewtill: " ).append( renewtill ).append( '\n' );
- }
-
- if ( sRealm != null )
- {
- sb.append( " sRealm: " ).append( sRealm ).append( '\n' );
- }
-
- if ( sName != null )
- {
- sb.append( " sName: " ).append( sName ).append( '\n' );
- }
-
- if ( clientAddresses != null )
- {
- sb.append( " clientAddresses: " ).append( clientAddresses ).append( '\n' );
- }
-
- sb.append( "}\n" );
-
- return sb.toString();
-
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbSafeBody.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbSafeBody.java
deleted file mode 100644
index 9d67e2a156..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbSafeBody.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Class representing KRB-SAFE-BODY message
- *
- * <pre>
- * KRB-SAFE-BODY ::= SEQUENCE {
- * user-data [0] OCTET STRING,
- * timestamp [1] KerberosTime OPTIONAL,
- * usec [2] Microseconds OPTIONAL,
- * seq-number [3] UInt32 OPTIONAL,
- * s-address [4] HostAddress,
- * r-address [5] HostAddress OPTIONAL
- * }
- *</pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class KrbSafeBody implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( KrbSafeBody.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** the user data */
- private byte[] userData;
-
- /** the current time of the sender */
- private KerberosTime timestamp;
-
- /** the microsecond part of the timestamp */
- private Integer usec;
-
- /** the sequence number */
- private Integer seqNumber;
-
- /** the sender's address */
- private HostAddress senderAddress;
-
- /** the recipient's address */
- private HostAddress recipientAddress;
-
- // Storage for computed lengths
- private int userDataLen;
- private int timestampLen;
- private int usecLen;
- private int seqNumberLen;
- private int senderAddressLen;
- private int recipientAddressLen;
- private int krbSafeBodySeqLen;
-
-
- /**
- * Creates a new instance of KrbSafeBody.
- */
- public KrbSafeBody()
- {
- }
-
-
- /**
- * @return the userData
- */
- public byte[] getUserData()
- {
- return userData;
- }
-
-
- /**
- * @param userData the userData to set
- */
- public void setUserData( byte[] userData )
- {
- this.userData = userData;
- }
-
-
- /**
- * @return the timestamp
- */
- public KerberosTime getTimestamp()
- {
- return timestamp;
- }
-
-
- /**
- * @param timestamp the timestamp to set
- */
- public void setTimestamp( KerberosTime timestamp )
- {
- this.timestamp = timestamp;
- }
-
-
- /**
- * @return the usec
- */
- public int getUsec()
- {
- if ( usec == null )
- {
- return 0;
- }
-
- return usec;
- }
-
-
- /**
- * @param usec the usec to set
- */
- public void setUsec( int usec )
- {
- this.usec = usec;
- }
-
-
- /**
- * @return the seqNumber
- */
- public int getSeqNumber()
- {
- if ( seqNumber == null )
- {
- return 0;
- }
-
- return seqNumber;
- }
-
-
- /**
- * @param seqNumber the seqNumber to set
- */
- public void setSeqNumber( int seqNumber )
- {
- this.seqNumber = seqNumber;
- }
-
-
- /**
- * @return the senderAddress
- */
- public HostAddress getSenderAddress()
- {
- return senderAddress;
- }
-
-
- /**
- * @param senderAddress the senderAddress to set
- */
- public void setSenderAddress( HostAddress senderAddress )
- {
- this.senderAddress = senderAddress;
- }
-
-
- /**
- * @return the recipientAddress
- */
- public HostAddress getRecipientAddress()
- {
- return recipientAddress;
- }
-
-
- /**
- * @param recipientAddress the recipientAddress to set
- */
- public void setRecipientAddress( HostAddress recipientAddress )
- {
- this.recipientAddress = recipientAddress;
- }
-
-
- /**
- * Compute the KRB-SAFE-BODY length:
- *
- * <pre>
- * 0x30 L1 KRB-SAFE-BODY SEQ
- * |
- * +--> 0xA0 L2 user-data tag
- * | |
- * | +--> 0x04 L2-1 user-data (Octet String)
- * |
- * +--> 0xA1 0x11 timestamp tag
- * | |
- * | +--> 0x18 0x0F timestamp (KerberosTime)
- * |
- * +--> 0xA2 L3 usec tag
- * | |
- * | +--> 0x02 L3-1 usec (Microseconds)
- * |
- * +--> 0xA3 L4 seq-number tag
- * | |
- * | +--> 0x02 L4-1 seqnumber (UInt32)
- * |
- * +--> 0xA4 L5 s-address tag
- * | |
- * | +--> 0x30 L5-1 s-address (HostAddress)
- * |
- * +--> 0xA5 L6 r-address tag
- * |
- * +--> 0x30 L6-1 r-address (HostAddress)
- * </pre>
- */
- @Override
- public int computeLength()
- {
- userDataLen = 1 + TLV.getNbBytes( userData.length ) + userData.length;
- krbSafeBodySeqLen = 1 + TLV.getNbBytes( userDataLen ) + userDataLen;
-
- senderAddressLen = senderAddress.computeLength();
- krbSafeBodySeqLen += 1 + TLV.getNbBytes( senderAddressLen ) + senderAddressLen;
-
- if ( timestamp != null )
- {
- timestampLen = timestamp.getBytes().length;
- timestampLen = 1 + TLV.getNbBytes( timestampLen ) + timestampLen;
- krbSafeBodySeqLen += 1 + TLV.getNbBytes( timestampLen ) + timestampLen;
- }
-
- if ( usec != null )
- {
- usecLen = BerValue.getNbBytes( usec );
- usecLen = 1 + TLV.getNbBytes( usecLen ) + usecLen;
- krbSafeBodySeqLen += 1 + TLV.getNbBytes( usecLen ) + usecLen;
- }
-
- if ( seqNumber != null )
- {
- seqNumberLen = BerValue.getNbBytes( seqNumber );
- seqNumberLen = 1 + TLV.getNbBytes( seqNumberLen ) + seqNumberLen;
- krbSafeBodySeqLen += 1 + TLV.getNbBytes( seqNumberLen ) + seqNumberLen;
- }
-
- if ( recipientAddress != null )
- {
- recipientAddressLen = recipientAddress.computeLength();
- krbSafeBodySeqLen += 1 + TLV.getNbBytes( recipientAddressLen ) + recipientAddressLen;
- }
-
- return 1 + TLV.getNbBytes( krbSafeBodySeqLen ) + krbSafeBodySeqLen;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( krbSafeBodySeqLen ) );
-
- // user-data
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_USER_DATA_TAG );
- buffer.put( TLV.getBytes( userDataLen ) );
- BerValue.encode( buffer, userData );
-
- if ( timestamp != null )
- {
- // timestamp tag
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_TIMESTAMP_TAG );
- buffer.put( TLV.getBytes( timestampLen ) );
-
- // timestamp value
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( timestamp.getBytes() );
- }
-
- if ( usec != null )
- {
- // usec
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_USEC_TAG );
- buffer.put( TLV.getBytes( usecLen ) );
- BerValue.encode( buffer, usec );
- }
-
- if ( seqNumber != null )
- {
- // seq-number
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_SEQ_NUMBER_TAG );
- buffer.put( TLV.getBytes( seqNumberLen ) );
- BerValue.encode( buffer, seqNumber );
- }
-
- // s-address
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_SENDER_ADDRESS_TAG );
- buffer.put( TLV.getBytes( senderAddressLen ) );
- senderAddress.encode( buffer );
-
- if ( recipientAddress != null )
- {
- // s-address
- buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_RECIPIENT_ADDRESS_TAG );
- buffer.put( TLV.getBytes( recipientAddressLen ) );
- recipientAddress.encode( buffer );
- }
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_735_CANNOT_ENCODE_KRBSAFEBODY, 1 + TLV.getNbBytes( krbSafeBodySeqLen )
- + krbSafeBodySeqLen, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "KrbSafeBody encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "KrbSafeBody initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "KRB-SAFE-BODY : {\n" );
- sb.append( " user-data: " ).append( Strings.dumpBytes( userData ) ).append( '\n' );
-
- if ( timestamp != null )
- {
- sb.append( " timestamp: " ).append( timestamp.getDate() ).append( '\n' );
- }
-
- if ( usec != null )
- {
- sb.append( " usec: " ).append( usec ).append( '\n' );
- }
-
- if ( seqNumber != null )
- {
- sb.append( " seq-number: " ).append( seqNumber ).append( '\n' );
- }
-
- sb.append( " s-address: " ).append( senderAddress ).append( '\n' );
-
- if ( recipientAddress != null )
- {
- sb.append( " r-address: " ).append( recipientAddress ).append( '\n' );
- }
-
- sb.append( "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java
deleted file mode 100644
index 185ace2dc3..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.codec.types.LastReqType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The LastReq structure.
- *
- * The ASN.1 grammar is :
- * <pre>
- * LastReq ::= SEQUENCE OF SEQUENCE {
- * lr-type [0] Int32,
- * lr-value [1] KerberosTime
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class LastReq implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( LastReq.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The list of LastReq elements */
- private List<LastReqEntry> lastReqs = new ArrayList<>();
-
- /** The current LastReqEntry being processed */
- private LastReqEntry currentLR;
-
- // Storage for computed lengths
- private int lrTypeTagLen[];
- private int lrValueTagLen[];
- private int lastReqSeqLen[];
- private int lastReqSeqSeqLen;
-
-
- /**
- * Creates a new instance of LastReq.
- */
- public LastReq()
- {
- }
-
-
- /**
- * @return the CurrentLr type
- */
- public LastReqType getCurrentLrType()
- {
- return currentLR.getLrType();
- }
-
-
- /**
- * Set the CurrentLr type
- */
- public void setCurrentLrType( LastReqType lrType )
- {
- currentLR.setLrType( lrType );
- }
-
-
- /**
- * @return the CurrentLr value
- */
- public KerberosTime getCurrentLrValue()
- {
- return currentLR.getLrValue();
- }
-
-
- /**
- * Set the CurrentLr value
- */
- public void setCurrentLrValue( KerberosTime lrValue )
- {
- currentLR.setLrValue( lrValue );
- }
-
-
- /**
- * @return the CurrentLR
- */
- public LastReqEntry getCurrentLR()
- {
- return currentLR;
- }
-
-
- /**
- * Create a new currentLR
- */
- public void createNewLR()
- {
- currentLR = new LastReqEntry();
- lastReqs.add( currentLR );
- }
-
-
- /**
- * Add a new LastReqEntry
- * @param lastReqEntry The enry to add
- */
- public void addEntry( LastReqEntry lastReqEntry )
- {
- lastReqs.add( lastReqEntry );
- }
-
-
- /**
- * @return the LastReqs
- */
- public List<LastReqEntry> getLastReqs()
- {
- return lastReqs;
- }
-
-
- /**
- * Compute the LastReq length
- *
- * <pre>
- * LastReq :
- *
- * 0x30 L1 LastReq
- * |
- * +--> 0x30 L2
- * |
- * +--> 0xA0 L3 lr-type tag
- * | |
- * | +--> 0x02 L3-1 lrType (int)
- * |
- * +--> 0xA1 0x11 lr-value tag
- * |
- * +--> 0x18 0x0F ttt (KerberosString)
- * </pre>
- */
- public int computeLength()
- {
- int i = 0;
- lastReqSeqLen = new int[lastReqs.size()];
- lrTypeTagLen = new int[lastReqs.size()];
- lrValueTagLen = new int[lastReqs.size()];
- lastReqSeqSeqLen = 0;
-
- for ( LastReqEntry lre : lastReqs )
- {
- int lrTypeLen = BerValue.getNbBytes( lre.getLrType().getValue() );
- lrTypeTagLen[i] = 1 + TLV.getNbBytes( lrTypeLen ) + lrTypeLen;
- byte[] lrValyeBytes = lre.getLrValue().getBytes();
- lrValueTagLen[i] = 1 + TLV.getNbBytes( lrValyeBytes.length ) + lrValyeBytes.length;
-
- lastReqSeqLen[i] = 1 + TLV.getNbBytes( lrTypeTagLen[i] ) + lrTypeTagLen[i] +
- 1 + TLV.getNbBytes( lrValueTagLen[i] ) + lrValueTagLen[i];
-
- lastReqSeqSeqLen += 1 + TLV.getNbBytes( lastReqSeqLen[i] ) + lastReqSeqLen[i];
- i++;
- }
-
- return 1 + TLV.getNbBytes( lastReqSeqSeqLen ) + lastReqSeqSeqLen;
- }
-
-
- /**
- * Encode the LastReq message to a PDU.
- *
- * <pre>
- * LastReq :
- *
- * 0x30 LL
- * 0x30 LL
- * 0xA0 LL
- * 0x02 0x01 lrType
- * 0xA1 0x11
- * 0x18 0x0F lrValue
- * </pre>
- *
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The lastRequest SEQ OF Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( lastReqSeqSeqLen ) );
-
- int i = 0;
-
- for ( LastReqEntry lre : lastReqs )
- {
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( lastReqSeqLen[i] ) );
-
- // the lrType
- buffer.put( ( byte ) KerberosConstants.LAST_REQ_LR_TYPE_TAG );
- buffer.put( TLV.getBytes( lrTypeTagLen[i] ) );
- BerValue.encode( buffer, lre.getLrType().getValue() );
-
- // the lrValue tag
- buffer.put( ( byte ) KerberosConstants.LAST_REQ_LR_VALUE_TAG );
- buffer.put( TLV.getBytes( lrValueTagLen[i] ) );
-
- // the lrValue value
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( lre.getLrValue().getBytes() );
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( lastReqSeqSeqLen )
- + lastReqSeqSeqLen, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ) , boe);
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "LastReq encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "LastReq initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "LastReq : \n" );
-
- for ( LastReqEntry lre : lastReqs )
- {
- sb.append( lre.toString( tabs + " " ) );
- }
-
- return sb.toString();
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java
deleted file mode 100644
index 8234603196..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.codec.types.LastReqType;
-
-
-/**
- * The data structure hold into the LastReq element
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class LastReqEntry
-{
- /** The LastReq type. */
- private LastReqType lrType;
-
- /** The LastReq value */
- private KerberosTime lrValue;
-
-
- /**
- * Creates a new instance of LastReqEntry
- */
- public LastReqEntry()
- {
- }
-
-
- /**
- * Creates a new instance of LastReqEntry
- * @param lrType The LastRequest type
- * @param lrValue The associated Time
- */
- public LastReqEntry( LastReqType lrType, KerberosTime lrValue )
- {
- this.lrType = lrType;
- this.lrValue = lrValue;
- }
-
-
- /**
- * @return the LastReqType
- */
- public LastReqType getLrType()
- {
- return lrType;
- }
-
-
- /**
- * @param lrType the lrType to set
- */
- public void setLrType( LastReqType lrType )
- {
- this.lrType = lrType;
- }
-
-
- /**
- * @return the lr-value
- */
- public KerberosTime getLrValue()
- {
- return lrValue;
- }
-
-
- /**
- * @param lrValue the lrValue to set
- */
- public void setLrValue( KerberosTime lrValue )
- {
- this.lrValue = lrValue;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "LastRequestEntry : {\n" );
- sb.append( tabs ).append( " lrType : " ).append( lrType ).append( "\n" );
- sb.append( tabs ).append( " lrValue : " ).append( lrValue ).append( "\n" );
- sb.append( tabs ).append( "}" );
-
- return sb.toString();
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/MethodData.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/MethodData.java
deleted file mode 100644
index d6c12e8116..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/MethodData.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Store a list of METHOD-DATA
- *
- * The ASN.1 grammar is :
- * <pre>
- * METHOD-DATA ::= SEQUENCE OF <PA-DATA>
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class MethodData implements Asn1Object
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( MethodData.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** List of all PA-DATA stored */
- private List<PaData> paDatas;
-
- // Storage for computed lengths
- private int methodDataLength;
-
-
- /**
- * Creates a new instance of MethodData.
- */
- public MethodData()
- {
- this.paDatas = new ArrayList<>();
- }
-
-
- /**
- * Adds an {@link PaData} to the list
- * @param paData The PaData to add
- */
- public void addPaData( PaData paData )
- {
- paDatas.add( paData );
- }
-
-
- /**
- * Returns true if this {@link PaData} contains a specified {@link PaData}.
- *
- * @param paData The paData we are looking for in the existing list
- * @return true if this {@link PaData} contains a specified {@link PaData}.
- */
- public boolean contains( PaData paData )
- {
- if ( paDatas != null )
- {
- return paDatas.contains( paData );
- }
-
- return false;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- int hash = 37;
-
- if ( paDatas != null )
- {
- hash = hash * 17 + paDatas.size();
-
- for ( PaData paData : paDatas )
- {
- hash = hash * 17 + paData.hashCode();
- }
- }
-
- return hash;
- }
-
-
- /**
- * Returns true if two {@link MethodData} are equal.
- *
- * @param that The {@link MethodData} we want to compare with the current one
- * @return true if two {@link MethodData} are equal.
- */
- public boolean equals( MethodData that )
- {
- if ( that == null )
- {
- return false;
- }
-
- // infoEntries can't be null after creation
- if ( paDatas.size() != that.paDatas.size() )
- {
- return false;
- }
-
- for ( int i = 0; i < paDatas.size(); i++ )
- {
- if ( !paDatas.get( i ).equals( that.paDatas.get( i ) ) )
- {
- return false;
- }
- }
-
- return true;
- }
-
-
- /**
- * Returns the contained {@link PaData}s as an array.
- *
- * @return An array of {@link PaData}s.
- */
- public PaData[] getPaDatas()
- {
- return paDatas.toArray( new PaData[0] );
- }
-
-
- /**
- * Compute the METHOD-DATA length
- * <pre>
- * METHOD-DATA :
- *
- * 0x30 L1 METHOD-DATA sequence of PA-DATA
- * |
- * +--> 0x30 L2[1] PA-DATA[1]
- * |
- * +--> 0x30 L2[2] PA-DATA[2]
- * |
- * ...
- * |
- * +--> 0x30 L2[n] PA-DATA[n]
- *
- * where L1 = sum( L2[1], l2[2], ..., L2[n] )
- * </pre>
- */
- public int computeLength()
- {
- // Compute the PA-DATA length.
- methodDataLength = 0;
-
- if ( ( paDatas != null ) && !paDatas.isEmpty() )
- {
- for ( PaData paData : paDatas )
- {
- int length = paData.computeLength();
- methodDataLength += length;
- }
- }
-
- return 1 + TLV.getNbBytes( methodDataLength ) + methodDataLength;
- }
-
-
- /**
- * Encode the METHOD-DATA message to a PDU.
- * <pre>
- * METHOD-DATA :
- *
- * 0x30 LL
- * 0x30 LL PA-DATA[1]
- * 0x30 LL PA-DATA[1]
- * ...
- * 0x30 LL PA-DATA[1]
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The METHOD-DATA SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( methodDataLength ) );
-
- // The PA-DATA list, if it's not empty
- if ( ( paDatas != null ) && !paDatas.isEmpty() )
- {
- for ( PaData paData : paDatas )
- {
- paData.encode( buffer );
- }
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_144, 1 + TLV.getNbBytes( methodDataLength )
- + methodDataLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "METHOD-DATA encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "METHOD-DATA initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- boolean isFirst = true;
-
- sb.append( "METHOD-DATA : " );
-
- for ( PaData paData : paDatas )
- {
- if ( isFirst )
- {
- isFirst = false;
- }
- else
- {
- sb.append( ", " );
- }
-
- sb.append( paData.toString() );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java
deleted file mode 100644
index de2810244e..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.codec.types.PaDataType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The Pre-Authentication data. The ASN.1 GRAMMAR IS :
- * <pre>
- * PA-DATA ::= SEQUENCE {
- * -- NOTE: first tag is [1], not [0]
- * padata-type [1] Int32,
- * padata-value [2] OCTET STRING -- might be encoded AP-REQ
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class PaData implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( PaData.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** The Pre-authentication type */
- private PaDataType paDataType;
-
- /** The authentication data */
- private byte[] paDataValue;
-
- // Storage for computed lengths
- private int paDataTypeTagLength;
- private int paDataValueTagLength;
- private int preAuthenticationDataSeqLength;
-
-
- /**
- * Creates a new instance of PreAuthenticationData.
- */
- public PaData()
- {
- }
-
-
- /**
- * Creates a new instance of PreAuthenticationData.
- *
- * @param paDataType
- * @param paDataValue
- */
- public PaData( PaDataType paDataType, byte[] paDataValue )
- {
- this.paDataType = paDataType;
- this.paDataValue = paDataValue;
- }
-
-
- /**
- * Returns the {@link PaDataType}.
- *
- * @return The {@link PaDataType}.
- */
- public PaDataType getPaDataType()
- {
- return paDataType;
- }
-
-
- /**
- * Set the PA-DATA type
- *
- * @param paDataType The PA-DATA type
- */
- public void setPaDataType( int paDataType )
- {
- this.paDataType = PaDataType.getTypeByValue( paDataType );
- }
-
-
- /**
- * Set the PA-DATA type
- *
- * @param paDataType The PA-DATA type
- */
- public void setPaDataType( PaDataType paDataType )
- {
- this.paDataType = paDataType;
- }
-
-
- /**
- * Returns the raw bytes of the {@link PaData}.
- *
- * @return The raw bytes of the {@link PaData}.
- */
- public byte[] getPaDataValue()
- {
- return paDataValue;
- }
-
-
- /**
- * Set the PA-DATA value
- *
- * @param paDataValue The PA-DATA value
- */
- public void setPaDataValue( byte[] paDataValue )
- {
- this.paDataValue = paDataValue;
- }
-
-
- /**
- * Compute the PreAuthenticationData length
- * <pre>
- * PreAuthenticationData :
- *
- * 0x30 L1 PreAuthenticationData sequence
- * |
- * +--> 0xA0 L2 padata-type tag
- * | |
- * | +--> 0x02 L2-1 padata-type (int)
- * |
- * +--> 0xA1 L3 padata-value tag
- * |
- * +--> 0x04 L3-1 padata-value (OCTET STRING)
- *
- * where L1 = L2 + lenght(0xA0) + length(L2) +
- * L3 + lenght(0xA1) + length(L3)
- * and
- * L2 = L2-1 + length(0x02) + length( L2-1)
- * L3 = L3-1 + length(0x04) + length( L3-1)
- * </pre>
- */
- public int computeLength()
- {
- // Compute the paDataType. The Length will always be contained in 1 byte
- int paDataTypeLength = BerValue.getNbBytes( paDataType.getValue() );
- paDataTypeTagLength = 1 + TLV.getNbBytes( paDataTypeLength ) + paDataTypeLength;
- preAuthenticationDataSeqLength = 1 + TLV.getNbBytes( paDataTypeTagLength ) + paDataTypeTagLength;
-
- // Compute the paDataValue
- if ( paDataValue == null )
- {
- paDataValueTagLength = 1 + 1;
- }
- else
- {
- paDataValueTagLength = 1 + TLV.getNbBytes( paDataValue.length ) + paDataValue.length;
- }
-
- // Compute the whole sequence length
- preAuthenticationDataSeqLength += 1 + TLV.getNbBytes( paDataValueTagLength ) + paDataValueTagLength;
-
- return 1 + TLV.getNbBytes( preAuthenticationDataSeqLength ) + preAuthenticationDataSeqLength;
-
- }
-
-
- /**
- * Encode the PreAuthenticationData message to a PDU.
- * <pre>
- * PreAuthenticationData :
- *
- * 0x30 LL
- * 0xA1 LL
- * 0x02 0x01 padata-type
- * 0xA2 LL
- * 0x04 LL padata-value
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The PreAuthenticationData SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( preAuthenticationDataSeqLength ) );
-
- // The PaDataType, first the tag, then the value
- buffer.put( ( byte ) KerberosConstants.PADATA_TYPE_TAG );
- buffer.put( TLV.getBytes( paDataTypeTagLength ) );
- BerValue.encode( buffer, paDataType.getValue() );
-
- // The PaDataValue, first the tag, then the value
- buffer.put( ( byte ) KerberosConstants.PADATA_VALUE_TAG );
- buffer.put( TLV.getBytes( paDataValueTagLength ) );
- BerValue.encode( buffer, paDataValue );
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_145, 1 + TLV.getNbBytes( preAuthenticationDataSeqLength )
- + preAuthenticationDataSeqLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "PreAuthenticationData encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "PreAuthenticationData initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "PreAuthenticationData : \n" );
- sb.append( tabs ).append( " padata-type: " ).append( paDataType ).append( '\n' );
-
- if ( paDataValue != null )
- {
- sb.append( tabs + " padata-value:" ).append( Strings.dumpBytes( paDataValue ) ).append( '\n' );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaEncTimestamp.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaEncTimestamp.java
deleted file mode 100644
index 355a5eb2c9..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaEncTimestamp.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-/**
- * The PaEncTimestamp structure is used to store a PA-ENC-TIMESTAMP associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * PA-ENC-TIMESTAMP ::= EncryptedData -- PA-ENC-TS-ENC
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class PaEncTimestamp extends EncryptedData
-{
- /**
- * Creates a new instance of PA-ENC-TIMESTAMP.
- */
- public PaEncTimestamp()
- {
- super();
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "PA-ENC-TIMESTAMP : {\n" );
- sb.append( tabs ).append( super.toString( " " + tabs ) ).append( '\n' );
-
- sb.append( tabs + "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaEncTsEnc.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaEncTsEnc.java
deleted file mode 100644
index 5a20adb2c6..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaEncTsEnc.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The PaEncTsEnc structure is used to store a PA-ENC-TS-ENC associated to a type.
- *
- * The ASN.1 grammar is :
- * <pre>
- * PA-ENC-TS-ENC ::= SEQUENCE {
- * patimestamp [0] KerberosTime -- client's time --,
- * pausec [1] Microseconds OPTIONAL
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class PaEncTsEnc implements Asn1Object
-{
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( PaEncTsEnc.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
-
- /** The patimestamp */
- private KerberosTime patimestamp;
-
- /** The pausec */
- private Integer pausec;
-
- // Storage for computed lengths
- private int paTimestampLength;
- private int paUsecLength;
- private int paEncTsEncLength;
-
-
- /**
- * Creates a new instance of PaEncTsEnc.
- */
- public PaEncTsEnc()
- {
- }
-
-
- /**
- * Creates a new instance of PaEncTsEnc.
- */
- public PaEncTsEnc( KerberosTime paTimestamp, int pausec )
- {
- this.patimestamp = paTimestamp;
- this.pausec = pausec;
- }
-
-
- /**
- * Returns the patimestamp value.
- *
- * @return The patimestamp value.
- */
- public KerberosTime getPaTimestamp()
- {
- return patimestamp;
- }
-
-
- /**
- * Set the patimestamp.
- *
- * @param patimestamp The patimestamp value
- */
- public void setPaTimestamp( KerberosTime patimestamp )
- {
- this.patimestamp = patimestamp;
- }
-
-
- /**
- * @return the pausec
- */
- public int getPausec()
- {
- if ( pausec == null )
- {
- return -1;
- }
-
- return pausec;
- }
-
-
- /**
- * @param pausec the pausec to set
- */
- public void setPausec( int pausec )
- {
- this.pausec = pausec;
- }
-
-
- /**
- * Compute the PA-ENC-TS-ENC length
- * <pre>
- * PA-ENC-TS-ENC :
- *
- * 0x30 L1 PA-ENC-TS-ENC sequence
- * |
- * +--> 0xA0 0x11 patimestamp tag
- * | |
- * | +--> 0x18 0x0F patimestamp value (KerberosTime)
- * |
- * +--> 0xA1 L2 pausec tag
- * |
- * +--> 0x02 L2-1 pausec (INTEGER)
- *
- * </pre>
- */
- public int computeLength()
- {
- // The paTimestamp
- paTimestampLength = 0x11;
-
- paEncTsEncLength = 1 + TLV.getNbBytes( paTimestampLength ) + paTimestampLength;
-
- // The pausec, if any
- if ( pausec != null )
- {
- int pausecLength = BerValue.getNbBytes( pausec );
- paUsecLength = 1 + TLV.getNbBytes( pausecLength ) + pausecLength;
- paEncTsEncLength += 1 + TLV.getNbBytes( paUsecLength ) + paUsecLength;
- }
-
- // Compute the whole sequence length
- return 1 + TLV.getNbBytes( paEncTsEncLength ) + paEncTsEncLength;
- }
-
-
- /**
- * Encode the PA-ENC-TS-ENC message to a PDU.
- *
- * <pre>
- * PA-ENC-TS-ENC :
- *
- * 0x30 LL
- * 0xA0 0x11
- * 0x18 0x0F patimestamp
- * [0xA1 LL
- * 0x02 LL pausec]
- * </pre>
- * @param buffer The buffer where to put the PDU. It should have been allocated
- * before, with the right size.
- * @return The constructed PDU.
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The PA-ENC-TS-ENC SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( paEncTsEncLength ) );
-
- // The patimestamp, first the tag, then the value
- buffer.put( ( byte ) KerberosConstants.PA_ENC_TS_ENC_PA_TIMESTAMP_TAG );
- buffer.put( ( byte ) 0x11 );
-
- buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( patimestamp.getBytes() );
-
- // The pausec, first the tag, then the value, if any
- if ( pausec != null )
- {
- buffer.put( ( byte ) KerberosConstants.PA_ENC_TS_ENC_PA_USEC_TAG );
- buffer.put( TLV.getBytes( paUsecLength ) );
- BerValue.encode( buffer, pausec );
- }
- }
- catch ( BufferOverflowException boe )
- {
- log.error( I18n.err( I18n.ERR_140, 1 + TLV.getNbBytes( paEncTsEncLength ) + paEncTsEncLength,
- buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- log.debug( "Checksum encoding : {}", Strings.dumpBytes( buffer.array() ) );
- log.debug( "Checksum initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "PA-ENC-TS-ENC : {\n" );
- sb.append( tabs ).append( " patimestamp : " ).append( patimestamp ).append( '\n' );
-
- if ( pausec != null )
- {
- sb.append( tabs + " pausec :" ).append( pausec ).append( '\n' );
- }
-
- sb.append( tabs + "}\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java
deleted file mode 100644
index 6ae059ba22..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.shared.kerberos.components;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * TYPED-DATA ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE {
- * data-type [0] Int32,
- * data-value [1] OCTET STRING OPTIONAL
- * }
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class TypedData implements Asn1Object
-{
-
- // The inner class storing the individual TDs
- public class TD
- {
- /** the type of TypedData */
- private int dataType;
-
- /** the TypedData data */
- private byte[] dataValue;
-
-
- /**
- * @return the TD type
- */
- public int getDataType()
- {
- return dataType;
- }
-
-
- /**
- * @return the TD data
- */
- public byte[] getDataValue()
- {
- return dataValue;
- }
- }
-
- /** The list of TypedData elements */
- private List<TD> typedDataList = new ArrayList<>();
-
- /** The current TD being processed */
- private TD currentTD;
-
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( TypedData.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- // Storage for computed lengths
- private int dataTypeTagLength[];
- private int dataValueTagLength[];
- private int typedDataSeqLength[];
- private int typedDataSeqSeqLength;
-
-
- /**
- * @return the currentTD type
- */
- public int getCurrentDataType()
- {
- return currentTD.dataType;
- }
-
-
- /**
- * Set the current TD type
- */
- public void setCurrentDataType( int tdType )
- {
- currentTD.dataType = tdType;
- }
-
-
- /**
- * @return the currentTD data
- */
- public byte[] getCurrentDataValue()
- {
- return currentTD.dataValue;
- }
-
-
- /**
- * Set the current TD data
- */
- public void setCurrentDataValue( byte[] tdData )
- {
- currentTD.dataValue = tdData;
- }
-
-
- /**
- * @return the currentTD
- */
- public TD getCurrentTD()
- {
- return currentTD;
- }
-
-
- /**
- * Create a new currentTD
- */
- public void createNewTD()
- {
- currentTD = new TD();
- typedDataList.add( currentTD );
- }
-
-
- /**
- * @return the TypedData
- */
- public List<TD> getTypedData()
- {
- return typedDataList;
- }
-
-
- /**
- * Compute the TypedData length
- * <pre>
- * 0x30 L1 TypedData sequence
- * |
- * +-- 0x30 L2 The TD sequence
- * |
- * +--> 0xA0 L3 tdType tag
- * | |
- * | +--> 0x02 L3-2 tdType (int)
- * |
- * +--> [0xA1 L4 tdData tag
- * |
- * +--> 0x04 L4-2 tdData (OCTET STRING)]
- * </pre>
- */
- @Override
- public int computeLength()
- {
- int i = 0;
- typedDataSeqLength = new int[typedDataList.size()];
- dataTypeTagLength = new int[typedDataList.size()];
- dataValueTagLength = new int[typedDataList.size()];
- typedDataSeqSeqLength = 0;
-
- for ( TD td : typedDataList )
- {
- int adTypeLen = BerValue.getNbBytes( td.dataType );
- dataTypeTagLength[i] = 1 + TLV.getNbBytes( adTypeLen ) + adTypeLen;
- typedDataSeqLength[i] = 1 + TLV.getNbBytes( dataTypeTagLength[i] ) + dataTypeTagLength[i];
-
- if ( td.dataValue != null )
- {
- dataValueTagLength[i] = 1 + TLV.getNbBytes( td.dataValue.length ) + td.dataValue.length;
- typedDataSeqLength[i] += 1 + TLV.getNbBytes( dataValueTagLength[i] ) + dataValueTagLength[i];
- }
-
- typedDataSeqSeqLength += 1 + TLV.getNbBytes( typedDataSeqLength[i] ) + typedDataSeqLength[i];
- i++;
- }
-
- return 1 + TLV.getNbBytes( typedDataSeqSeqLength ) + typedDataSeqSeqLength;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_148 ) );
- }
-
- try
- {
- // The AuthorizationData SEQ OF Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( typedDataSeqSeqLength ) );
-
- int i = 0;
- for ( TD td : typedDataList )
- {
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( typedDataSeqLength[i] ) );
-
- // the tdType
- buffer.put( ( byte ) KerberosConstants.TYPED_DATA_TDTYPE_TAG );
- buffer.put( TLV.getBytes( dataTypeTagLength[i] ) );
- BerValue.encode( buffer, td.dataType );
-
- if ( td.dataValue != null )
- {
- // the tdData
- buffer.put( ( byte ) KerberosConstants.TYPED_DATA_TDDATA_TAG );
- buffer.put( TLV.getBytes( dataValueTagLength[i] ) );
- BerValue.encode( buffer, td.dataValue );
- }
-
- i++;
- }
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_743_CANNOT_ENCODE_TYPED_DATA, 1 + TLV.getNbBytes( typedDataSeqSeqLength )
- + typedDataSeqSeqLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "TypedData encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "TypedData initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- return toString( "" );
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString( String tabs )
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( tabs ).append( "TypedData : \n" );
-
- for ( TD td : typedDataList )
- {
- sb.append( tabs ).append( " {\n" );
- sb.append( tabs ).append( " tdType: " ).append( td.dataType ).append( '\n' );
- if ( td.dataValue != null )
- {
- sb.append( tabs ).append( " tdData: " ).append( Strings.dumpBytes( td.dataValue ) )
- .append( '\n' );
- }
- sb.append( tabs ).append( " }\n" );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApRep.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApRep.java
deleted file mode 100644
index f84ed03bd9..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApRep.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.messages;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.components.EncryptedData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * AP-REP message.
- * It will store the object described by the ASN.1 grammar :
- * <pre>
- * AP-REP ::= [APPLICATION 15] SEQUENCE {
- * pvno [0] INTEGER (5),
- * msg-type [1] INTEGER (15),
- * enc-part [2] <EncryptedData> -- EncAPRepPart
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class ApRep extends KerberosMessage
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( ApRep.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The encryptedData, an encrypted EncAPRepPart */
- private EncryptedData encPart;
-
- // Storage for computed lengths
- private int pvnoLength;
- private int msgTypeLength;
- private int encPartLength;
- private int apRepLength;
- private int apRepSeqLength;
-
-
- /**
- * Creates a new instance of AP-REP.
- */
- public ApRep()
- {
- super( KerberosMessageType.AP_REP );
- }
-
-
- /**
- * Returns the {@link EncryptedData}.
- *
- * @return The {@link EncryptedData}.
- */
- public EncryptedData getEncPart()
- {
- return encPart;
- }
-
-
- /**
- * Sets the {@link EncryptedData}.
- *
- * @param encPart The encrypted part
- */
- public void setEncPart( EncryptedData encPart )
- {
- this.encPart = encPart;
- }
-
-
- /**
- * Compute the AP-REP length
- * <pre>
- * AP-REP :
- *
- * 0x6F L1 AP-REP message
- * |
- * +--> 0x30 L2
- * |
- * +--> 0xA0 0x03
- * | |
- * | +--> 0x02 0x01 0x05 pvno
- * |
- * +--> 0xA1 0x03
- * | |
- * | +--> 0x02 0x01 0x0E msg-type
- * |
- * +--> 0xA2 L3
- * |
- * +--> 0x30 L3-1 enc-part
- *
- * </pre>
- */
- public int computeLength()
- {
- // Compute the PVNO length.
- pvnoLength = 1 + 1 + BerValue.getNbBytes( getProtocolVersionNumber() );
-
- // Compute the msg-type length
- msgTypeLength = 1 + 1 + BerValue.getNbBytes( getMessageType().getValue() );
-
- // Compute the enc-part length
- encPartLength = encPart.computeLength();
-
- // Compute the sequence size
- apRepLength =
- 1 + TLV.getNbBytes( pvnoLength ) + pvnoLength +
- 1 + TLV.getNbBytes( msgTypeLength ) + msgTypeLength +
- 1 + TLV.getNbBytes( encPartLength ) + encPartLength;
-
- apRepSeqLength = 1 + TLV.getNbBytes( apRepLength ) + apRepLength;
-
- return 1 + TLV.getNbBytes( apRepSeqLength ) + apRepSeqLength;
- }
-
-
- /**
- * Encode the AP-REP component
- *
- * @param buffer The buffer containing the encoded result
- * @return The encoded component
- * @throws EncoderException If the encoding failed
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- buffer = ByteBuffer.allocate( computeLength() );
- }
-
- try
- {
- // The AP-REP Tag
- buffer.put( ( byte ) KerberosConstants.AP_REP_TAG );
- buffer.put( TLV.getBytes( apRepSeqLength ) );
-
- // The AP-REP SEQ Tag
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( apRepLength ) );
-
- // The PVNO -------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.AP_REP_PVNO_TAG );
- buffer.put( TLV.getBytes( pvnoLength ) );
-
- // The value
- BerValue.encode( buffer, getProtocolVersionNumber() );
-
- // The msg-type ---------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.AP_REP_MSG_TYPE_TAG );
- buffer.put( TLV.getBytes( msgTypeLength ) );
-
- // The value
- BerValue.encode( buffer, getMessageType().getValue() );
-
- // The enc-part ---------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.AP_REP_ENC_PART_TAG );
- buffer.put( TLV.getBytes( encPartLength ) );
-
- // The value
- encPart.encode( buffer );
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_137, 1 + TLV.getNbBytes( apRepLength ) + apRepLength,
- buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "AP-REP encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "AP-REP initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "AP-REP :\n" );
- sb.append( " pvno : " ).append( getProtocolVersionNumber() ).append( "\n" );
- sb.append( " msg-type : " ).append( getMessageType() ).append( "\n" );
- sb.append( " enc-part : " ).append( encPart ).append( "\n" );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsRep.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsRep.java
deleted file mode 100644
index e5cd646e9a..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsRep.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.messages;
-
-
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.components.KdcRep;
-import org.apache.directory.shared.kerberos.components.PrincipalName;
-import org.apache.directory.shared.kerberos.flags.TicketFlags;
-
-
-/**
- * AS-REQ message. It's just a KDC-REP message with a message type set to 11.
- * It will store the object described by the ASN.1 grammar :
- * <pre>
- * AS-REP ::= [APPLICATION 11] <KDC-RE>P
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AsRep extends KdcRep
-{
- // Storage for computed lengths
- private int kdcRepLength;
- private int asRepLength;
-
-
- /**
- * Creates a new instance of AS-REP.
- */
- public AsRep()
- {
- super( KerberosMessageType.AS_REP );
- }
-
-
- /**
- * Returns the end {@link KerberosTime}.
- *
- * @return The end {@link KerberosTime}.
- */
- public KerberosTime getEndTime()
- {
- return encKdcRepPart.getEndTime();
- }
-
-
- /**
- * Returns the {@link TicketFlags}.
- *
- * @return The {@link TicketFlags}.
- */
- public TicketFlags getFlags()
- {
- return encKdcRepPart.getFlags();
- }
-
-
- /**
- * Returns the nonce.
- *
- * @return The nonce.
- */
- public int getNonce()
- {
- return encKdcRepPart.getNonce();
- }
-
-
- /**
- * Returns the renew till {@link KerberosTime}.
- *
- * @return The renew till {@link KerberosTime}.
- */
- public KerberosTime getRenewTill()
- {
- return encKdcRepPart.getRenewTill();
- }
-
-
- /**
- * Returns the start {@link KerberosTime}.
- *
- * @return The start {@link KerberosTime}.
- */
- public KerberosTime getStartTime()
- {
- return encKdcRepPart.getStartTime();
- }
-
-
- /**
- * Returns the server {@link PrincipalName}.
- *
- * @return The server {@link PrincipalName}.
- */
- public PrincipalName getSName()
- {
- return encKdcRepPart.getSName();
- }
-
-
- /**
- * Compute the AS-REP length
- * <pre>
- * AS-REP :
- *
- * 0x6B L1 AS-REP message
- * |
- * +--> 0x30 L2 KDC-REP sequence
- * </pre>
- */
- @Override
- public int computeLength()
- {
- kdcRepLength = super.computeLength();
- asRepLength = 1 + TLV.getNbBytes( kdcRepLength ) + kdcRepLength;
-
- return asRepLength;
- }
-
-
- /**
- * Encode the AS-REP component
- *
- * @param buffer The buffer containing the encoded result
- * @return The encoded component
- * @throws org.apache.directory.api.asn1.EncoderException If the encoding failed
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- buffer = ByteBuffer.allocate( computeLength() );
- }
-
- // The AS-REP SEQ Tag
- buffer.put( ( byte ) KerberosConstants.AS_REP_TAG );
- buffer.put( TLV.getBytes( kdcRepLength ) );
-
- // The KDC-REP --------------------------------------------------------
- super.encode( buffer );
-
- return buffer;
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ChangePasswdData.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ChangePasswdData.java
deleted file mode 100644
index b307498a13..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ChangePasswdData.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.messages;
-
-
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.components.PrincipalName;
-
-
-/**
- * Change password data structure
- *
- * ChangePasswdData ::= SEQUENCE {
- * newpasswd[0] OCTET STRING,
- * targname[1] PrincipalName OPTIONAL,
- * targrealm[2] Realm OPTIONAL
- * }
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class ChangePasswdData implements Asn1Object
-{
-
- /** the new password */
- private byte[] newPasswd;
-
- /** principal name of the client */
- private PrincipalName targName;
-
- /** name of client's realm */
- private String targRealm;
-
- private int newPasswdLen;
- private int targNameLen;
- private int targRealmLen;
- private int seqLen;
-
-
- public ChangePasswdData()
- {
- }
-
-
- /**
- * Compute the ChangePasswdData length
- * <pre>
- * ChangePasswdData :
- *
- * 0x30 L1 ChangePasswdData sequence
- * |
- * +--> 0xA0 L2 newPasswd tag
- * | |
- * | +--> 0x04 L2-1 newPasswd (Octet string)
- * |
- * +--> 0xA1 L3 targName tag
- * | |
- * | +--> 0x30 L3-1 targName (PrincipalName)
- * |
- * +--> 0xA2 L4 targRealm tag
- * |
- * +--> 0x1B L4-1 targRealm (KerberosString)
- * </pre>
- */
- @Override
- public int computeLength()
- {
- newPasswdLen = 1 + TLV.getNbBytes( newPasswd.length ) + newPasswd.length;
-
- seqLen = 1 + TLV.getNbBytes( newPasswdLen ) + newPasswdLen;
-
- if ( targName != null )
- {
- targNameLen = targName.computeLength();
- seqLen += 1 + TLV.getNbBytes( targNameLen ) + targNameLen;
- }
-
- if ( targRealm != null )
- {
- targRealmLen = Strings.getBytesUtf8( targRealm ).length;
- targRealmLen = 1 + TLV.getNbBytes( targRealmLen ) + targRealmLen;
- seqLen += 1 + TLV.getNbBytes( targRealmLen ) + targRealmLen;
- }
-
- return 1 + TLV.getNbBytes( seqLen ) + seqLen;
- }
-
-
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- buffer = ByteBuffer.allocate( computeLength() );
- }
-
- // ChangePasswdData
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( BerValue.getBytes( seqLen ) );
-
- // newpasswd
- buffer.put( ( byte ) KerberosConstants.CHNGPWD_NEWPWD_TAG );
- buffer.put( BerValue.getBytes( newPasswdLen ) );
- BerValue.encode( buffer, newPasswd );
-
- if ( targName != null )
- {
- buffer.put( ( byte ) KerberosConstants.CHNGPWD_TARGNAME_TAG );
- buffer.put( BerValue.getBytes( targNameLen ) );
-
- targName.encode( buffer );
- }
-
- if ( targRealm != null )
- {
- buffer.put( ( byte ) KerberosConstants.CHNGPWD_TARGREALM_TAG );
- buffer.put( BerValue.getBytes( targRealmLen ) );
- buffer.put( UniversalTag.GENERAL_STRING.getValue() );
- buffer.put( BerValue.getBytes( targRealmLen - 2 ) );
- buffer.put( Strings.getBytesUtf8( targRealm ) );
- }
-
- return buffer;
- }
-
-
- public byte[] getNewPasswd()
- {
- return newPasswd;
- }
-
-
- public void setNewPasswd( byte[] newPasswd )
- {
- this.newPasswd = newPasswd;
- }
-
-
- public PrincipalName getTargName()
- {
- return targName;
- }
-
-
- public void setTargName( PrincipalName targName )
- {
- this.targName = targName;
- }
-
-
- public String getTargRealm()
- {
- return targRealm;
- }
-
-
- public void setTargRealm( String targRealm )
- {
- this.targRealm = targRealm;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "ChangePasswdData : \n" );
-
- sb.append( " newPasswd : " ).append( Strings.utf8ToString( newPasswd ) ).append( '\n' );
- sb.append( " targName : " ).append( targName ).append( '\n' );
- sb.append( " targRealm : " ).append( targRealm ).append( '\n' );
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java
deleted file mode 100644
index 853934a786..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.messages;
-
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.components.EncryptionKey;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Encrypted part of the application response.
- * It will store the object described by the ASN.1 grammar :
- * <pre>
- * EncAPRepPart ::= [APPLICATION 27] SEQUENCE {
- * ctime [0] KerberosTime,
- * cusec [1] Microseconds,
- * subkey [2] <EncryptionKey> OPTIONAL,
- * seq-number [3] UInt32 OPTIONAL
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class EncApRepPart extends KerberosMessage
-{
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger( EncApRepPart.class );
-
- /** Speedup for logs */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** The client time */
- private KerberosTime ctime;
-
- /** the microsecond part of the client's timestamp */
- private int cusec;
-
- /** Encryption key */
- private EncryptionKey subkey; //optional
-
- /** Sequence number */
- private Integer seqNumber; //optional
-
- // Storage for computed lengths
- private int ctimeLength;
- private int cusecLength;
- private int subKeyLength;
- private int seqNumberLength;
- private int encApRepPartSeqLength;
- private int encApRepPartLength;
-
-
- /**
- * Creates a new instance of EncApRepPart.
- */
- public EncApRepPart()
- {
- super( KerberosMessageType.ENC_AP_REP_PART );
- }
-
-
- /**
- * Returns the client {@link KerberosTime}.
- *
- * @return The client {@link KerberosTime}.
- */
- public KerberosTime getCTime()
- {
- return ctime;
- }
-
-
- /**
- * @param ctime the ctime to set
- */
- public void setCTime( KerberosTime ctime )
- {
- this.ctime = ctime;
- }
-
-
- /**
- * @return the cusec
- */
- public int getCusec()
- {
- return cusec;
- }
-
-
- /**
- * @param cusec the cusec to set
- */
- public void setCusec( int cusec )
- {
- this.cusec = cusec;
- }
-
-
- /**
- * @return the subkey
- */
- public EncryptionKey getSubkey()
- {
- return subkey;
- }
-
-
- /**
- * @param subkey the subkey to set
- */
- public void setSubkey( EncryptionKey subkey )
- {
- this.subkey = subkey;
- }
-
-
- /**
- * @return the seqNumber
- */
- public Integer getSeqNumber()
- {
- return seqNumber;
- }
-
-
- /**
- * @param seqNumber the seqNumber to set
- */
- public void setSeqNumber( Integer seqNumber )
- {
- this.seqNumber = seqNumber;
- }
-
-
- /**
- * Compute the Authenticator length
- * <pre>
- * Authenticator :
- *
- * 0x7B L1 EncApRepPart [APPLICATION 27]
- * |
- * +--> 0x30 L2 SEQ
- * |
- * +--> 0xA0 11 ctime tag
- * | |
- * | +--> 0x18 0x0F ttt ctime (KerberosTime)
- * |
- * +--> 0xA1 L3 cusec tag
- * | |
- * | +--> 0x02 L3-1 cusec (INTEGER)
- * |
- * +--> 0xA2 L4 subkey (EncryptionKey)
- * |
- * +--> 0xA3 L5 seq-number tag
- * |
- * +--> 0x02 L5-1 NN seq-number (INTEGER)
- * </pre>
- */
- @Override
- public int computeLength()
- {
- // Compute the ctime length.
- ctimeLength = 1 + 1 + 0x0F;
- encApRepPartSeqLength = 1 + TLV.getNbBytes( ctimeLength ) + ctimeLength;
-
- // Compute the cusec length
- cusecLength = 1 + 1 + BerValue.getNbBytes( cusec );
- encApRepPartSeqLength += 1 + TLV.getNbBytes( cusecLength ) + cusecLength;
-
- // Compute the subkey length, if any
- if ( subkey != null )
- {
- subKeyLength = subkey.computeLength();
- encApRepPartSeqLength += 1 + TLV.getNbBytes( subKeyLength ) + subKeyLength;
- }
-
- // Compute the sequence size, if any
- if ( seqNumber != null )
- {
- seqNumberLength = 1 + 1 + BerValue.getNbBytes( seqNumber );
- encApRepPartSeqLength += 1 + TLV.getNbBytes( seqNumberLength ) + seqNumberLength;
- }
-
- encApRepPartLength = 1 + TLV.getNbBytes( encApRepPartSeqLength ) + encApRepPartSeqLength;
-
- return 1 + TLV.getNbBytes( encApRepPartLength ) + encApRepPartLength;
- }
-
-
- /**
- * Encode the EncApRepPart message to a PDU.
- * <pre>
- * EncApRepPart :
- *
- * 0x7B LL
- * 0x30 LL
- * 0xA0 0x11
- * 0x18 0x0F ttt ctime
- * 0xA1 LL
- * 0x02 LL NN cusec
- * [0xA2 LL
- * 0x30 LL abcd] subkey
- * [0xA3 LL
- * 0x02 LL NN] seq-number
- * </pre>
- * @return The constructed PDU.
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- buffer = ByteBuffer.allocate( computeLength() );
- }
-
- try
- {
- // The EncApRepPart APPLICATION Tag
- buffer.put( ( byte ) KerberosConstants.ENC_AP_REP_PART_TAG );
- buffer.put( TLV.getBytes( encApRepPartLength ) );
-
- // The EncApRepPart SEQ Tag
- buffer.put( ( byte ) UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( encApRepPartSeqLength ) );
-
- // The ctime ------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.ENC_AP_REP_PART_CTIME_TAG );
- buffer.put( ( byte ) 0x11 );
-
- // The value
- buffer.put( ( byte ) UniversalTag.GENERALIZED_TIME.getValue() );
- buffer.put( ( byte ) 0x0F );
- buffer.put( ctime.getBytes() );
-
- // The cusec ------------------------------------------------------
- // The tag
- buffer.put( ( byte ) KerberosConstants.ENC_AP_REP_PART_CUSEC_TAG );
- buffer.put( TLV.getBytes( cusecLength ) );
-
- // The value
- BerValue.encode( buffer, cusec );
-
- // The subkey if any ----------------------------------------------
- if ( subkey != null )
- {
- // The tag
- buffer.put( ( byte ) KerberosConstants.ENC_AP_REP_PART_SUB_KEY_TAG );
- buffer.put( TLV.getBytes( subKeyLength ) );
-
- // The value
- subkey.encode( buffer );
- }
-
- // The seq-number, if any -----------------------------------------
- if ( seqNumber != null )
- {
- // The tag
- buffer.put( ( byte ) KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG );
- buffer.put( TLV.getBytes( seqNumberLength ) );
-
- // The value
- BerValue.encode( buffer, seqNumber );
- }
-
- }
- catch ( BufferOverflowException boe )
- {
- LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( encApRepPartLength )
- + encApRepPartLength, buffer.capacity() ) );
- throw new EncoderException( I18n.err( I18n.ERR_138 ), boe );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "EncApRepPart encoding : {}", Strings.dumpBytes( buffer.array() ) );
- LOG.debug( "EncApRepPart initial value : {}", this );
- }
-
- return buffer;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "EncApRepPart : \n" );
-
- sb.append( " ctime : " ).append( ctime ).append( '\n' );
- sb.append( " cusec : " ).append( cusec ).append( '\n' );
-
- if ( subkey != null )
- {
- sb.append( " subkey : " ).append( subkey ).append( '\n' );
- }
-
- if ( seqNumber != null )
- {
- sb.append( " seq-number : " ).append( seqNumber ).append( '\n' );
- }
-
- return sb.toString();
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java
deleted file mode 100644
index f654b93cae..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.messages;
-
-
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.components.EncKdcRepPart;
-
-
-/**
- * EncASRepPart message.
- * It will store the object described by the ASN.1 grammar :
- * <pre>
- * EncASRepPart ::= [APPLICATION 25] EncKDCRepPart
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class EncAsRepPart extends KerberosMessage
-{
- /** The EncKdcRepPart */
- private EncKdcRepPart encKdcRepPart;
-
- // Storage for computed lengths
- private int encKdcRepPartLength;
-
-
- /**
- * Creates a new instance of EncAsRepPart.
- */
- public EncAsRepPart()
- {
- super( KerberosMessageType.ENC_AS_REP_PART );
- }
-
-
- /**
- * @return the encKdcRepPart
- */
- public EncKdcRepPart getEncKdcRepPart()
- {
- return encKdcRepPart;
- }
-
-
- /**
- * @param encKdcRepPart the encKdcRepPart to set
- */
- public void setEncKdcRepPart( EncKdcRepPart encKdcRepPart )
- {
- this.encKdcRepPart = encKdcRepPart;
- }
-
-
- /**
- * Compute the EncAsRepPart length
- * <pre>
- * EncAsRepPart :
- *
- * 0x79 L1 EncAsRepPart message
- * |
- * +--> 0x30 L2 EncKdcRepPart sequence
- * </pre>
- */
- public int computeLength()
- {
- encKdcRepPartLength = encKdcRepPart.computeLength();
- return 1 + TLV.getNbBytes( encKdcRepPartLength ) + encKdcRepPartLength;
- }
-
-
- /**
- * Encode the EncAsRepPart component
- *
- * @param buffer The buffer containing the encoded result
- * @return The encoded component
- * @throws EncoderException If the encoding failed
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- buffer = ByteBuffer.allocate( computeLength() );
- }
-
- // The EncAsRepPart Tag
- buffer.put( ( byte ) KerberosConstants.ENC_AS_REP_PART_TAG );
- buffer.put( TLV.getBytes( encKdcRepPartLength ) );
-
- // The EncKdcRepPart --------------------------------------------------------
- encKdcRepPart.encode( buffer );
-
- return buffer;
- }
-}
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncTgsRepPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncTgsRepPart.java
deleted file mode 100644
index 85e9b02f83..0000000000
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncTgsRepPart.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.shared.kerberos.messages;
-
-
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.components.EncKdcRepPart;
-
-
-/**
- * EncTGSRepPart message.
- * It will store the object described by the ASN.1 grammar :
- * <pre>
- * EncTGSRepPart ::= [APPLICATION 26] EncKDCRepPart
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class EncTgsRepPart extends KerberosMessage
-{
- /** The EncKdcRepPart */
- private EncKdcRepPart encKdcRepPart;
-
- // Storage for computed lengths
- private int encKdcRepPartLength;
-
-
- /**
- * Creates a new instance of EncTgsRepPart.
- */
- public EncTgsRepPart()
- {
- super( KerberosMessageType.ENC_TGS_REP_PART );
- }
-
-
- /**
- * @return the encKdcRepPart
- */
- public EncKdcRepPart getEncKdcRepPart()
- {
- return encKdcRepPart;
- }
-
-
- /**
- * @param encKdcRepPart the encKdcRepPart to set
- */
- public void setEncKdcRepPart( EncKdcRepPart encKdcRepPart )
- {
- this.encKdcRepPart = encKdcRepPart;
- }
-
-
- /**
- * Compute the EncTgsRepPart length
- * <pre>
- * EncTgsRepPart :
- *
- * 0x7A L1 EncTgsRepPart message
- * |
- * +--> 0x30 L2 EncKdcRepPart sequence
- * </pre>
- */
- public int computeLength()
- {
- encKdcRepPartLength = encKdcRepPart.computeLength();
- return 1 + TLV.getNbBytes( encKdcRepPartLength ) + encKdcRepPartLength;
- }
-
-
- /**
- * Encode the EncTgsRepPart component
- *
- * @param buffer The buffer containing the encoded result
- * @return The encoded component
- * @throws EncoderException If the encoding failed
- */
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- buffer = ByteBuffer.allocate( computeLength() );
- }
-
- // The EncAsRepPart Tag
- buffer.put( ( byte ) KerberosConstants.ENC_TGS_REP_PART_TAG );
- buffer.put( TLV.getBytes( encKdcRepPartLength ) );
-
- // The EncKdcRepPart --------------------------------------------------------
- encKdcRepPart.encode( buffer );
-
- return buffer;
- }
-}
diff --git a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
index 975e3c1178..2f98022419 100644
--- a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
+++ b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
@@ -21,23 +21,7 @@ package org.apache.directory.server.kerberos.shared.crypto.encryption;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import javax.security.auth.kerberos.KerberosKey;
-import javax.security.auth.kerberos.KerberosPrincipal;
-
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.codec.KerberosDecoder;
-import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
-import org.apache.directory.shared.kerberos.components.EncryptedData;
-import org.apache.directory.shared.kerberos.components.EncryptionKey;
-import org.apache.directory.shared.kerberos.components.PaEncTsEnc;
-import org.apache.directory.shared.kerberos.exceptions.KerberosException;
import org.junit.jupiter.api.Test;
@@ -99,9 +83,6 @@ public class CipherTextHandlerTest
( byte ) 0x65, ( byte ) 0x92, ( byte ) 0xbd, ( byte ) 0xf5, ( byte ) 0x52, ( byte ) 0x9f, ( byte ) 0x94,
( byte ) 0x67, ( byte ) 0x10, ( byte ) 0xd2 };
- /** Defines a default date format with a "yyyyMMddHHmmss'Z'" pattern */
- private static final SimpleDateFormat UTC_DATE_FORMAT = new SimpleDateFormat( "yyyyMMddHHmmss'Z'", Locale.ROOT );
-
/**
* Tests the lengths of the test vectors for encrypted timestamps for each
* of the supported encryption types. The length of the Kerberos Cipher Text
@@ -116,226 +97,4 @@ public class CipherTextHandlerTest
assertEquals( 56, AES256_ENCRYPTED_TIME_STAMP.length, "AES256 length" );
assertEquals( 52, ARCFOUR_ENCRYPTED_TIME_STAMP.length, "RC4-HMAC length" );
}
-
- /**
- * Tests the unsealing of Kerberos CipherText with a good password. After decryption and
- * an integrity check, an attempt is made to decode the bytes as an EncryptedTimestamp. The
- * result is timestamp data.
- */
- @Test
- public void testAes128GoodPasswordDecrypt()
- {
- if ( !VendorHelper.isCtsSupported() )
- {
- return;
- }
-
- CipherTextHandler lockBox = new CipherTextHandler();
- KerberosPrincipal principal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
- KerberosKey kerberosKey = new KerberosKey( principal, "secret".toCharArray(), "AES128" );
- EncryptionKey key = new EncryptionKey( EncryptionType.AES128_CTS_HMAC_SHA1_96, kerberosKey.getEncoded() );
- EncryptedData data = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, 0, AES128_ENCRYPTED_TIME_STAMP );
-
- try
- {
- byte[] paEncTsEncData = lockBox.decrypt( key, data, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY );
- PaEncTsEnc object = KerberosDecoder.decodePaEncTsEnc( paEncTsEncData );
- assertEquals( "20070410212557Z", object.getPaTimestamp().toString(), "TimeStamp" );
- assertEquals( 379386, object.getPausec(), "MicroSeconds" );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
- }
-
-
- /**
- * Tests the encryption and subsequent unsealing of an ASN.1 encoded timestamp with a
- * good password. After encryption, an attempt is made to unseal the encrypted bytes
- * as an EncryptedTimestamp. The result is timestamp data.
- *
- * @throws ParseException
- */
- @Test
- public void testAes128GoodPasswordEncrypt() throws ParseException
- {
- if ( !VendorHelper.isCtsSupported() )
- {
- return;
- }
-
- CipherTextHandler lockBox = new CipherTextHandler();
- KerberosPrincipal principal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
- KerberosKey kerberosKey = new KerberosKey( principal, "secret".toCharArray(), "AES128" );
- EncryptionKey key = new EncryptionKey( EncryptionType.AES128_CTS_HMAC_SHA1_96, kerberosKey.getEncoded() );
-
- String zuluTime = "20070410190400Z";
- int microSeconds = 460450;
- PaEncTsEnc encryptedTimeStamp = getEncryptedTimeStamp( zuluTime, microSeconds );
-
- EncryptedData encryptedData = null;
-
- try
- {
- encryptedData = lockBox.seal( key, encryptedTimeStamp, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
-
- try
- {
- byte[] paEncTsEncData = lockBox.decrypt( key, encryptedData, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY );
- PaEncTsEnc object = KerberosDecoder.decodePaEncTsEnc( paEncTsEncData );
- assertEquals( "20070410190400Z", object.getPaTimestamp().toString(), "TimeStamp" );
- assertEquals( 460450, object.getPausec(), "MicroSeconds" );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
- }
-
-
- /**
- * Tests the unsealing of Kerberos CipherText with a good password. After decryption and
- * an integrity check, an attempt is made to decode the bytes as an EncryptedTimestamp. The
- * result is timestamp data.
- */
- @Test
- public void testAes256GoodPasswordDecrypt()
- {
- if ( !VendorHelper.isCtsSupported() )
- {
- return;
- }
-
- CipherTextHandler lockBox = new CipherTextHandler();
- KerberosKey kerberosKey;
-
- try
- {
- KerberosPrincipal principal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
- kerberosKey = new KerberosKey( principal, "secret".toCharArray(), "AES256" );
- }
- catch ( IllegalArgumentException iae )
- {
- // Algorithm AES256 not enabled
- return;
- }
-
- EncryptionKey key = new EncryptionKey( EncryptionType.AES256_CTS_HMAC_SHA1_96, kerberosKey.getEncoded() );
- EncryptedData data = new EncryptedData( EncryptionType.AES256_CTS_HMAC_SHA1_96, 0, AES256_ENCRYPTED_TIME_STAMP );
-
- try
- {
- byte[] paEncTsEncData = lockBox.decrypt( key, data, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY );
- PaEncTsEnc object = KerberosDecoder.decodePaEncTsEnc( paEncTsEncData );
- assertEquals( "20070410212809Z", object.getPaTimestamp().toString(), "TimeStamp" );
- assertEquals( 298294, object.getPausec(), "MicroSeconds" );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
- }
-
-
- /**
- * Tests the encryption and subsequent unsealing of an ASN.1 encoded timestamp with a
- * good password. After encryption, an attempt is made to unseal the encrypted bytes
- * as an EncryptedTimestamp. The result is timestamp data.
- *
- * @throws ParseException
- */
- @Test
- public void testAes256GoodPasswordEncrypt() throws ParseException
- {
- if ( !VendorHelper.isCtsSupported() )
- {
- return;
- }
-
- CipherTextHandler lockBox = new CipherTextHandler();
-
- KerberosKey kerberosKey;
-
- try
- {
- KerberosPrincipal principal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
- kerberosKey = new KerberosKey( principal, "secret".toCharArray(), "AES256" );
- }
- catch ( IllegalArgumentException iae )
- {
- // Algorithm AES256 not enabled
- return;
- }
-
- EncryptionKey key = new EncryptionKey( EncryptionType.AES256_CTS_HMAC_SHA1_96, kerberosKey.getEncoded() );
-
- String zuluTime = "20070410190400Z";
- int microSeconds = 460450;
- PaEncTsEnc encryptedTimeStamp = getEncryptedTimeStamp( zuluTime, microSeconds );
-
- EncryptedData encryptedData = null;
-
- try
- {
- encryptedData = lockBox.seal( key, encryptedTimeStamp, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
-
- try
- {
- byte[] paEncTsEncData = lockBox.decrypt( key, encryptedData, KeyUsage.AS_REQ_PA_ENC_TIMESTAMP_WITH_CKEY );
- PaEncTsEnc object = KerberosDecoder.decodePaEncTsEnc( paEncTsEncData );
- assertEquals( "20070410190400Z", object.getPaTimestamp().toString(), "TimeStamp" );
- assertEquals( 460450, object.getPausec(), "MicroSeconds" );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
- }
-
-
- protected PaEncTsEnc getEncryptedTimeStamp( String zuluTime, int microSeconds ) throws ParseException
- {
- Date date = null;
-
- synchronized ( UTC_DATE_FORMAT )
- {
- date = UTC_DATE_FORMAT.parse( zuluTime );
- }
-
- KerberosTime timeStamp = new KerberosTime( date );
-
- return new PaEncTsEnc( timeStamp, microSeconds );
- }
-
- /*
- public void testArcFourGoodPassword()
- {
- LockBox lockBox = new LockBox();
- KerberosPrincipal principal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
- KerberosKey kerberosKey = new KerberosKey( principal, "secret".toCharArray(), "ArcFourHmac" );
- EncryptionKey key = new EncryptionKey( EncryptionType.RC4_HMAC, kerberosKey.getEncoded() );
- EncryptedData data = new EncryptedData( EncryptionType.RC4_HMAC, 0, arcfourEncryptedTimeStamp );
-
- try
- {
- PaEncTsEnc object = ( PaEncTsEnc ) lockBox.unseal( hint, key, data );
- assertEquals( "TimeStamp", "20070322233107Z", object.getTimeStamp().toString() );
- assertEquals( "MicroSeconds", 291067, object.getPausec() );
- }
- catch ( KerberosException ke )
- {
- fail( "Should not have caught exception." );
- }
- }*/
}
diff --git a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PaDataTest.java b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PaDataTest.java
deleted file mode 100644
index 51215a06fa..0000000000
--- a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PaDataTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.server.kerberos.shared.messages.value;
-
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-import org.apache.directory.shared.kerberos.codec.types.PaDataType;
-import org.apache.directory.shared.kerberos.components.PaData;
-import org.junit.jupiter.api.Test;
-
-
-/**
- * Test the PaData encoding and decoding
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class PaDataTest
-{
- @Test
- public void testEncodingPreAuthenticationData() throws Exception
- {
- PaData pad = new PaData( PaDataType.PA_ASF3_SALT, new byte[]
- { 0x01, 0x02, 0x03 } );
-
- ByteBuffer encoded = ByteBuffer.allocate( pad.computeLength() );
-
- pad.encode( encoded );
-
- byte[] expectedResult = new byte[]
- {
- 0x30, 0x0c,
- ( byte ) 0xA1, 0x03,
- 0x02, 0x01, 0x0A,
- ( byte ) 0xA2, 0x05,
- 0x04, 0x03,
- 0x01, 0x02, 0x03
- };
-
- assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
- }
-
-
- @Test
- public void testEncodingNullPreAuthenticationData() throws Exception
- {
- PaData pad = new PaData( PaDataType.PA_ASF3_SALT, null );
-
- ByteBuffer encoded = ByteBuffer.allocate( pad.computeLength() );
-
- pad.encode( encoded );
-
- byte[] expectedResult = new byte[]
- {
- 0x30, 0x09,
- ( byte ) 0xA1, 0x03,
- 0x02, 0x01, 0x0A,
- ( byte ) 0xA2, 0x02,
- 0x04, 0x00
- };
-
- assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
- }
-}