Package org.apache.directory.shared.asn1.der

Examples of org.apache.directory.shared.asn1.der.DERSequence


    }


    private DERSequence encodePrivateMessageSequence( PrivateMessage message )
    {
        DERSequence sequence = new DERSequence();

        sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( message.getProtocolVersionNumber() ) ) );
        sequence.add( new DERTaggedObject( 1, DERInteger.valueOf( message.getMessageType().getOrdinal() ) ) );
        sequence.add( new DERTaggedObject( 3, EncryptedDataEncoder.encodeSequence( message.getEncryptedPart() ) ) );

        return sequence;
    }
View Full Code Here


    public byte[] encode( Encodable apRepPart ) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ASN1OutputStream aos = new ASN1OutputStream( baos );

        DERSequence privPartSequence = encodeApRepPartSequence( ( EncApRepPart ) apRepPart );
        aos.writeObject( DERApplicationSpecific.valueOf( APPLICATION_CODE, privPartSequence ) );
        aos.close();

        return baos.toByteArray();
    }
View Full Code Here

    }


    private DERSequence encodeApRepPartSequence( EncApRepPart message )
    {
        DERSequence sequence = new DERSequence();

        sequence.add( new DERTaggedObject( 0, KerberosTimeEncoder.encode( message.getClientTime() ) ) );
        sequence.add( new DERTaggedObject( 1, DERInteger.valueOf( message.getClientMicroSecond() ) ) );

        if ( message.getSubSessionKey() != null )
        {
            sequence.add( new DERTaggedObject( 2, EncryptionKeyEncoder.encodeSequence( message.getSubSessionKey() ) ) );
        }

        if ( message.getSequenceNumber() != null )
        {
            sequence.add( new DERTaggedObject( 3, DERInteger.valueOf( message.getSequenceNumber().intValue() ) ) );
        }

        return sequence;
    }
View Full Code Here

    {
        ASN1InputStream ais = new ASN1InputStream( encodedPrivatePart );

        DERApplicationSpecific app = ( DERApplicationSpecific ) ais.readObject();

        DERSequence privatePart = ( DERSequence ) app.getObject();

        return decodePrivatePartSequence( privatePart );
    }
View Full Code Here

                case 3:
                    DERInteger tag3 = ( DERInteger ) derObject;
                    modifier.setSequenceNumber( new Integer( tag3.intValue() ) );
                    break;
                case 4:
                    DERSequence tag4 = ( DERSequence ) derObject;
                    modifier.setSenderAddress( HostAddressDecoder.decode( tag4 ) );
                    break;
                case 5:
                    DERSequence tag5 = ( DERSequence ) derObject;
                    modifier.setRecipientAddress( HostAddressDecoder.decode( tag5 ) );
                    break;
            }
        }
        return modifier.getEncKrbPrivPart();
View Full Code Here

    public byte[] encode( Encodable app ) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ASN1OutputStream aos = new ASN1OutputStream( baos );

        DERSequence initialSequence = encodeInitialSequence( ( KdcReply ) app );
        aos.writeObject( DERApplicationSpecific.valueOf( applicationCode, initialSequence ) );

        return baos.toByteArray();
    }
View Full Code Here

     *                caddr[11]                    HostAddresses OPTIONAL
     * }
     */
    protected DERSequence encodeInitialSequence( KdcReply reply )
    {
        DERSequence sequence = new DERSequence();

        sequence.add( new DERTaggedObject( 0, EncryptionKeyEncoder.encodeSequence( reply.getKey() ) ) );
        sequence.add( new DERTaggedObject( 1, LastRequestEncoder.encode( reply.getLastRequest() ) ) );
        sequence.add( new DERTaggedObject( 2, DERInteger.valueOf( reply.getNonce() ) ) );

        // OPTIONAL
        if ( reply.getKeyExpiration() != null )
        {
            sequence.add( new DERTaggedObject( 3, KerberosTimeEncoder.encode( reply.getKeyExpiration() ) ) );
        }

        sequence.add( new DERTaggedObject( 4, new DERBitString( reply.getFlags().getBytes() ) ) );
        sequence.add( new DERTaggedObject( 5, KerberosTimeEncoder.encode( reply.getAuthTime() ) ) );

        // OPTIONAL
        if ( reply.getStartTime() != null )
        {
            sequence.add( new DERTaggedObject( 6, KerberosTimeEncoder.encode( reply.getStartTime() ) ) );
        }

        sequence.add( new DERTaggedObject( 7, KerberosTimeEncoder.encode( reply.getEndTime() ) ) );

        // OPTIONAL
        if ( reply.getRenewTill() != null )
        {
            sequence.add( new DERTaggedObject( 8, KerberosTimeEncoder.encode( reply.getRenewTill() ) ) );
        }

        sequence.add( new DERTaggedObject( 9, DERGeneralString.valueOf( reply.getServerRealm().toString() ) ) );
        sequence.add( new DERTaggedObject( 10, PrincipalNameEncoder.encode( reply.getServerPrincipal() ) ) );

        // OPTIONAL
        if ( reply.getClientAddresses() != null )
        {
            sequence.add( new DERTaggedObject( 11, HostAddressesEncoder.encodeSequence( reply.getClientAddresses() ) ) );
        }

        return sequence;
    }
View Full Code Here

     */
    public static EncryptionKey decode( byte[] encodedEncryptionKey ) throws IOException
    {
        ASN1InputStream ais = new ASN1InputStream( encodedEncryptionKey );

        DERSequence sequence = ( DERSequence ) ais.readObject();

        return decode( sequence );
    }
View Full Code Here

    public byte[] encode( ApplicationReply reply ) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ASN1OutputStream aos = new ASN1OutputStream( baos );

        DERSequence replySequence = encodeReplySequence( reply );
        aos.writeObject( DERApplicationSpecific.valueOf( APPLICATION_CODE, replySequence ) );
        aos.close();

        return baos.toByteArray();
    }
View Full Code Here

    }


    private DERSequence encodeReplySequence( ApplicationReply message )
    {
        DERSequence sequence = new DERSequence();

        sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( message.getProtocolVersionNumber() ) ) );
        sequence.add( new DERTaggedObject( 1, DERInteger.valueOf( message.getMessageType().getOrdinal() ) ) );
        sequence.add( new DERTaggedObject( 2, EncryptedDataEncoder.encodeSequence( message.getEncPart() ) ) );

        return sequence;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.asn1.der.DERSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.