Package org.apache.directory.shared.kerberos.components

Examples of org.apache.directory.shared.kerberos.components.PrincipalName



    @Test
    public void testEncodingPrincipalNameNullName() throws Exception
    {
        PrincipalName principal = new PrincipalName( null, PrincipalNameType.KRB_NT_PRINCIPAL );

        ByteBuffer encoded = ByteBuffer.allocate( principal.computeLength() );

        principal.encode( encoded );

        byte[] expectedResult = new byte[]
            {
                0x30, 0x0B,
                ( byte ) 0xA0, 0x03,
View Full Code Here


            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );
        }

        // Get the principalName
        PrincipalName principalName = principalNameContainer.getPrincipalName();

        BerValue value = tlv.getValue();

        // The PrincipalName must be pure ASCII witout any control character
        if ( KerberosUtils.isKerberosString( value.getData() ) )
        {
            String nameString = Strings.utf8ToString( value.getData() );

            principalName.addName( nameString );
            principalNameContainer.setGrammarEndAllowed( true );

            if ( IS_DEBUG )
            {
                LOG.debug( "PrincipalName String : {}", nameString );
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected void setIntegerValue( int value, PrincipalNameContainer principalNameContainer )
    {
        PrincipalName principalName = principalNameContainer.getPrincipalName();

        PrincipalNameType principalNameType = PrincipalNameType.getTypeByValue( value );
        principalName.setNameType( principalNameType );

        if ( IS_DEBUG )
        {
            LOG.debug( "name-type : {}" + principalNameType );
        }
View Full Code Here

        Ticket ticket = ( ( TicketContainer ) ticketContainer ).getTicket();

        assertEquals( 5, ticket.getTktVno() );
        assertEquals( "EXAMPLE.COM", ticket.getRealm() );

        PrincipalName principalName = ticket.getSName();

        assertNotNull( principalName );
        assertEquals( PrincipalNameType.KRB_NT_PRINCIPAL, principalName.getNameType() );
        assertTrue( principalName.getNames().contains( "hnelson" ) );

        EncryptedData encryptedData = ticket.getEncPart();

        assertNotNull( encryptedData );
        assertEquals( EncryptionType.AES256_CTS_HMAC_SHA1_96, encryptedData.getEType() );
View Full Code Here

        encTicketPart.setFlags( ticketFlags );

        EncryptionKey sessionKey = RandomKeyFactory.getRandomKey( EncryptionType.DES_CBC_MD5 );

        encTicketPart.setKey( sessionKey );
        encTicketPart.setCName( new PrincipalName( clientPrincipal.getName(), PrincipalNameType.KRB_NT_PRINCIPAL ) );
        encTicketPart.setTransited( new TransitedEncoding() );
        encTicketPart.setAuthTime( new KerberosTime() );

        long now = System.currentTimeMillis();
        KerberosTime endTime = new KerberosTime( now + ONE_DAY );
        encTicketPart.setEndTime( endTime );

        KerberosTime renewTill = new KerberosTime( now + ONE_WEEK );
        encTicketPart.setRenewTill( renewTill );

        EncryptedData encryptedTicketPart = cipherTextHandler.seal( serverKey, encTicketPart,
            KeyUsage.AS_OR_TGS_REP_TICKET_WITH_SRVKEY );

        Ticket ticket = new Ticket();
        ticket.setTktVno( KerberosConstants.KERBEROS_V5 );
        ticket.setSName( new PrincipalName( serverPrincipal.getName(), PrincipalNameType.KRB_NT_PRINCIPAL ) );
        ticket.setRealm( serverPrincipal.getRealm() );
        ticket.setEncPart( encryptedTicketPart );

        return ticket;
    }
View Full Code Here

        {
            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
        }

        // get the decoded PrincipalName
        PrincipalName principalName = ( ( PrincipalNameContainer ) principalNameContainer ).getPrincipalName();

        return principalName;
    }
View Full Code Here

        assertEquals( ChecksumType.getTypeByValue( 2 ), checksum.getChecksumType() );
        assertTrue( Arrays.equals( Strings.getBytesUtf8( "chksum" ), checksum.getChecksumValue() ) );

        assertEquals( "EXAMPLE.COM", adKdcIssued.getIRealm() );

        PrincipalName principalName = adKdcIssued.getISName();

        assertNotNull( principalName );
        assertEquals( PrincipalNameType.KRB_NT_PRINCIPAL, principalName.getNameType() );
        assertTrue( principalName.getNames().contains( "hnelson" ) );

        AuthorizationData authData = adKdcIssued.getElements();

        assertNotNull( authData.getAuthorizationData().size() );
        assertEquals( 2, authData.getAuthorizationData().size() );
View Full Code Here

        optionalFieldValueList.add( new FieldValueHolder( "renewtill", renewtill ) );

        sRealm = "srealm";
        optionalFieldValueList.add( new FieldValueHolder( "sRealm", sRealm ) );

        pName = new PrincipalName( "pname", PrincipalNameType.KRB_NT_PRINCIPAL );
        optionalFieldValueList.add( new FieldValueHolder( "pName", pName ) );

        sName = new PrincipalName( "sname", PrincipalNameType.KRB_NT_PRINCIPAL );
        optionalFieldValueList.add( new FieldValueHolder( "sName", sName ) );

        clientAddresses = new HostAddresses( new HostAddress[]
            { new HostAddress( InetAddress.getByName( "localhost" ) ) } );
        optionalFieldValueList.add( new FieldValueHolder( "clientAddresses", clientAddresses ) );
View Full Code Here

        {
            fail( de.getMessage() );
        }

        // Check the decoded PrincipalName
        PrincipalName principalName = ( ( PrincipalNameContainer ) principalNameContainer ).getPrincipalName();

        assertEquals( PrincipalNameType.KRB_NT_PRINCIPAL, principalName.getNameType() );
        assertTrue( principalName.getNames().contains( "hnelson1" ) );
        assertTrue( principalName.getNames().contains( "hnelson2" ) );
        assertTrue( principalName.getNames().contains( "hnelson3" ) );

        // Check the encoding
        ByteBuffer bb = ByteBuffer.allocate( principalName.computeLength() );

        try
        {
            bb = principalName.encode( bb );

            // Check the length
            assertEquals( 0x29, bb.limit() );

            String encodedPdu = Strings.dumpBytes( bb.array() );
View Full Code Here

    @Test
    public void testDecodeKrebCred() throws Exception
    {
        EncryptedData encPart = new EncryptedData( EncryptionType.DES3_CBC_MD5, 0, new byte[]
            { 0, 1 } );
        PrincipalName pName = new PrincipalName( "pname", PrincipalNameType.KRB_NT_PRINCIPAL );

        String realm = "ticketRealm";
        Ticket t1 = new Ticket( pName, encPart );
        t1.setRealm( realm );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.kerberos.components.PrincipalName

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.