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

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


    }


    private static DERSequence encodeNameSequence( PrincipalName principalName )
    {
        DERSequence vector = new DERSequence();

        for ( String name:principalName.getNames() )
        {
            vector.add( DERGeneralString.valueOf( name ) );
        }

        return vector;
    }
View Full Code Here


     * etype[8]             SEQUENCE OF INTEGER, -- EncryptionEngine,
     *             -- in preference order
     */
    protected static DERSequence encode( Set<EncryptionType> eType )
    {
        DERSequence sequence = new DERSequence();

        for ( EncryptionType encryptionType:eType )
        {
            sequence.add( DERInteger.valueOf( encryptionType.getOrdinal() ) );
        }

        return sequence;
    }
View Full Code Here

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

        DERSequence ticketSequence = encodeInitialSequence( ( EncTicketPart ) ticketPart );
        aos.writeObject( DERApplicationSpecific.valueOf( APPLICATION_CODE, ticketSequence ) );
        aos.close();

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

     * @param ticketPart
     * @return The {@link DERSequence}.
     */
    public DERSequence encodeInitialSequence( EncTicketPart ticketPart )
    {
        DERSequence sequence = new DERSequence();

        sequence.add( new DERTaggedObject( 0, new DERBitString( ticketPart.getFlags().getBytes() ) ) );
        sequence.add( new DERTaggedObject( 1, EncryptionKeyEncoder.encodeSequence( ticketPart.getSessionKey() ) ) );
        sequence.add( new DERTaggedObject( 2, DERGeneralString.valueOf( ticketPart.getClientRealm().toString() ) ) );
        sequence.add( new DERTaggedObject( 3, PrincipalNameEncoder.encode( ticketPart.getClientPrincipal() ) ) );
        sequence.add( new DERTaggedObject( 4, TransitedEncodingEncoder.encode( ticketPart.getTransitedEncoding() ) ) );
        sequence.add( new DERTaggedObject( 5, KerberosTimeEncoder.encode( ticketPart.getAuthTime() ) ) );

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

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

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

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

        // OPTIONAL
        if ( ticketPart.getAuthorizationData() != null )
        {
            sequence
                .add( new DERTaggedObject( 10, AuthorizationDataEncoder.encode( ticketPart.getAuthorizationData() ) ) );
        }

        return sequence;
    }
View Full Code Here

    {
        ASN1InputStream ais = new ASN1InputStream( encodedEncApRepPart );

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

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

        return decodeEncApRepPartSequence( apRepPart );
    }
View Full Code Here

                case 1:
                    DERInteger tag1 = ( DERInteger ) derObject;
                    modifier.setClientMicroSecond( new Integer( tag1.intValue() ) );
                    break;
                case 2:
                    DERSequence tag2 = ( DERSequence ) derObject;
                    modifier.setSubSessionKey( EncryptionKeyDecoder.decode( tag2 ) );
                    break;
                case 3:
                    DERInteger tag3 = ( DERInteger ) derObject;
                    modifier.setSequenceNumber( new Integer( tag3.intValue() ) );
View Full Code Here

     */
    public EncryptionTypeInfoEntry[] decode( byte[] encodedEntries ) throws IOException
    {
        ASN1InputStream ais = new ASN1InputStream( encodedEntries );

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

        return decodeSequence( sequence );
    }
View Full Code Here

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

        DERSequence replySequence = encodeInitialSequence( ( Authenticator ) authenticator );
        aos.writeObject( DERApplicationSpecific.valueOf( APPLICATION_CODE, replySequence ) );
        aos.close();

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

        EncryptionTypeInfoEntry[] entrySequence = new EncryptionTypeInfoEntry[sequence.size()];

        int ii = 0;
        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
        {
            DERSequence object = (DERSequence)e.nextElement();
            entrySequence[ii] = decode( object );
            ii++;
        }

        return entrySequence;
View Full Code Here

     */
    private DERSequence encodeInitialSequence( Authenticator authenticator )
    {
        String clientRealm = authenticator.getClientPrincipal().getRealm();

        DERSequence sequence = new DERSequence();

        sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( authenticator.getVersionNumber() ) ) );
        sequence.add( new DERTaggedObject( 1, DERGeneralString.valueOf( clientRealm ) ) );
        sequence.add( new DERTaggedObject( 2, PrincipalNameEncoder.encode( authenticator.getClientPrincipal() ) ) );

        // OPTIONAL
        if ( authenticator.getChecksum() != null )
        {
            sequence.add( new DERTaggedObject( 3, ChecksumEncoder.encode( authenticator.getChecksum() ) ) );
        }

        sequence.add( new DERTaggedObject( 4, DERInteger.valueOf( authenticator.getClientMicroSecond() ) ) );
        sequence.add( new DERTaggedObject( 5, KerberosTimeEncoder.encode( authenticator.getClientTime() ) ) );

        // OPTIONAL
        if ( authenticator.getSubSessionKey() != null )
        {
            sequence.add( new DERTaggedObject( 6, EncryptionKeyEncoder
                .encodeSequence( authenticator.getSubSessionKey() ) ) );
        }

        // OPTIONAL
        if ( authenticator.getSequenceNumber() > 0 )
        {
            sequence.add( new DERTaggedObject( 7, DERInteger.valueOf( authenticator.getSequenceNumber() ) ) );
        }

        // OPTIONAL
        if ( authenticator.getAuthorizationData() != null )
        {
            sequence.add( new DERTaggedObject( 8, AuthorizationDataEncoder
                .encode( authenticator.getAuthorizationData() ) ) );
        }

        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.