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

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


    }
   
    private PrincipalName readPrincipal( int version ) throws IOException
    {
        int type, length;
        PrincipalName pname;

        if (version == CredentialsCacheConstants.FCC_FVNO_1)
        {
            type = CredentialsCacheConstants.NT_UNKNOWN;
        }
        else
        {
            type = readInt();
        }
        length = readInt();
       
        if (version == CredentialsCacheConstants.FCC_FVNO_1)
        {
            length--;
        }
       
        String realm = readCountedString();
       
        String[] result = new String[length];
        for ( int i = 0; i < length; i++ )
        {
          result[i] = readCountedString();
        }
        pname = new PrincipalName(result, type);
        if ( isRealm( realm ) )
        {
          pname.setRealm( realm );
        }

        return pname;
    }
View Full Code Here


        return ticketFlags;
    }

    private Credentials readCredentials( int version ) throws IOException
    {
        PrincipalName cpname = readPrincipal(version);
        PrincipalName spname = readPrincipal(version);
       
        if ( cpname == null || spname == null )
        {
          throw new IOException("Invalid client principal name or service principal name");
        }
       
        EncryptionKey key = readKey(version);

        KerberosTime[] times = readKerberosTimes();
        KerberosTime authtime = times[0];
        KerberosTime starttime = times[1];
        KerberosTime endtime = times[2];
        KerberosTime renewTill = times[3];
       
        boolean skey = readskey();
       
        int flags = readFlags();
        TicketFlags tFlags = new TicketFlags(flags);
        HostAddress addr[] = readAddr();
        HostAddresses addrs = null;
        if (addr != null)
        {
            addrs = new HostAddresses(addr);
        }
       
        AuthorizationDataEntry[] auDataEntries = readAuth();
        AuthorizationData auData = null;
        if (auDataEntries != null)
        {
          auData = new AuthorizationData();
          for (AuthorizationDataEntry ade : auDataEntries)
          {
            auData.addEntry(ade);
          }
        }
       
        byte[] ticketData = readData();
        byte[] ticketData2 = readData();

        if ( version != CredentialsCacheConstants.FCC_FVNO_1 &&
            spname.getNameType().getValue() == CredentialsCacheConstants.NT_UNKNOWN )
        {
          // skip krb5_ccache_conf_data/fast_avail/krbtgt/REALM@REALM in MIT KRB5
          return null;
        }
       
View Full Code Here

        KerberosTime now = new KerberosTime();

        krbError.setErrorCode( ErrorType.getTypeByValue( exception.getErrorCode() ) );
        krbError.setEText( exception.getLocalizedMessage() );
        krbError.setSName( new PrincipalName( principal ) );
        krbError.setRealm( principal.getRealm() );
        krbError.setSTime( now );
        krbError.setSusec( 0 );
        krbError.setEData( exception.getExplanatoryData() );
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

        KdcReqBody body = new KdcReqBody();

        body.setKdcOptions( new KdcOptions( new byte[]
            { 0x00, 0x01, 0x04, 0x00, 0x32 } ) );
        body.setCName( new PrincipalName( "client", PrincipalNameType.KRB_NT_ENTERPRISE ) );
        body.setRealm( "EXAMPLE.COM" );
        body.setSName( new PrincipalName( "server", PrincipalNameType.KRB_NT_ENTERPRISE ) );

        body.setFrom( new KerberosTime( System.currentTimeMillis() ) );
        body.setTill( new KerberosTime( System.currentTimeMillis() ) );
        body.setRtime( new KerberosTime( System.currentTimeMillis() ) );
        body.setNonce( 12345 );

        body.addEType( EncryptionType.AES256_CTS_HMAC_SHA1_96 );
        body.addEType( EncryptionType.DES3_CBC_MD5 );
        body.addEType( EncryptionType.AES128_CTS_HMAC_SHA1_96 );

        HostAddresses addresses = new HostAddresses();
        addresses.addHostAddress( new HostAddress( HostAddrType.ADDRTYPE_INET, "192.168.0.1".getBytes() ) );
        addresses.addHostAddress( new HostAddress( HostAddrType.ADDRTYPE_INET, "192.168.0.2".getBytes() ) );
        body.setAddresses( addresses );

        EncryptedData encAuthorizationData = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96,
            "abcdef".getBytes() );
        body.setEncAuthorizationData( encAuthorizationData );

        Ticket ticket1 = new Ticket();
        ticket1.setTktVno( 5 );
        ticket1.setRealm( "EXAMPLE.COM" );
        ticket1.setSName( new PrincipalName( "client", PrincipalNameType.KRB_NT_PRINCIPAL ) );
        ticket1.setEncPart( new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, "abcdef".getBytes() ) );

        body.addAdditionalTicket( ticket1 );

        Ticket ticket2 = new Ticket();
        ticket2.setTktVno( 5 );
        ticket2.setRealm( "EXAMPLE.COM" );
        ticket2.setSName( new PrincipalName( "server", PrincipalNameType.KRB_NT_PRINCIPAL ) );
        ticket2.setEncPart( new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, "abcdef".getBytes() ) );

        body.addAdditionalTicket( ticket2 );

        // Check the encoding
View Full Code Here

           
        try
        {
          CredentialsCache cc = CredentialsCache.load(bais);
         
            PrincipalName principal = cc.getPrimaryPrincipalName();
            assertTrue( principal.getNameString().equals( SampleCredentialsCacheResource.getSamplePrincipal() ) );
            assertTrue( principal.getRealm().equals( SampleCredentialsCacheResource.getSampleRealm() ) );
           
            assertTrue( cc.getCredsList().size() == SampleCredentialsCacheResource.getSampleTicketsCount() );
           
            Set<String> servers = new HashSet<String>();
            for (String server : SampleCredentialsCacheResource.getSampleServers())
View Full Code Here

       
        KdcReqBody body = new KdcReqBody();
       
        body.setFrom( new KerberosTime( clientTgtReq.getStartTime() ) );
       
        PrincipalName cName = null;
        try
        {
            cName = new PrincipalName( clientTgtReq.getCName(), PrincipalNameType.KRB_NT_PRINCIPAL );
            body.setCName( cName );
            body.setRealm( realm );
            PrincipalName sName = new PrincipalName( clientTgtReq.getSName(), PrincipalNameType.KRB_NT_SRV_INST );
            body.setSName( sName );
        }
        catch( ParseException e )
        {
            throw new IllegalArgumentException( "Couldn't parse the given principals", e );
View Full Code Here

       
        Authenticator authenticator = new Authenticator();
       
        try
        {
            authenticator.setCName( new PrincipalName( srvTktReq.getTgt().getClientName(), PrincipalNameType.KRB_NT_PRINCIPAL ) );
        }
        catch( ParseException e )
        {
            throw new IllegalArgumentException( "Couldn't parse the given principal", e );
        }
       
        authenticator.setCRealm( srvTktReq.getTgt().getRealm() );
        authenticator.setCTime( new KerberosTime() );
        authenticator.setCusec( 0 );

        if( srvTktReq.getSubSessionKey() != null )
        {
            sessionKey = srvTktReq.getSubSessionKey();
            authenticator.setSubKey( sessionKey );
        }
       
        EncryptedData authnData = cipherTextHandler.encrypt( sessionKey, getEncoded( authenticator ), KeyUsage.TGS_REQ_PA_TGS_REQ_PADATA_AP_REQ_TGS_SESS_KEY );
       
        ApReq apReq = new ApReq();
       
        apReq.setAuthenticator( authnData );
        apReq.setTicket( srvTktReq.getTgt().getTicket() );

        apReq.setApOptions( srvTktReq.getApOptions() );
       
        KdcReqBody tgsReqBody = new KdcReqBody();
        tgsReqBody.setKdcOptions( srvTktReq.getKdcOptions() );
        tgsReqBody.setRealm( KdcClientUtil.extractRealm( serverPrincipal ) );
        tgsReqBody.setTill( getDefaultTill() );
        int currentNonce = nonceGenerator.nextInt();
        tgsReqBody.setNonce( currentNonce );
        tgsReqBody.setEType( config.getEncryptionTypes() );
       
        PrincipalName principalName = new PrincipalName( KdcClientUtil.extractName( serverPrincipal ), KerberosPrincipal.KRB_NT_SRV_HST );
        tgsReqBody.setSName( principalName );
       
        TgsReq tgsReq = new TgsReq();
        tgsReq.setKdcReqBody( tgsReqBody );
       
View Full Code Here

            ApOptions options = new ApOptions();
            apReq.setApOptions( options );
            apReq.setTicket( tgt.getTicket() );
           
            Authenticator authenticator = new Authenticator();
            authenticator.setCName( new PrincipalName( tgt.getClientName(), PrincipalNameType.KRB_NT_PRINCIPAL ) );
            authenticator.setCRealm( tgt.getRealm() );
            KerberosTime ctime = new KerberosTime();
            authenticator.setCTime( ctime );
            authenticator.setCusec( 0 );
            authenticator.setSeqNumber( nonceGenerator.nextInt() );
View Full Code Here

     
      TgTicket tgt = kdc.getTgt( principal, password );
     
      CredentialsCache credCache = new CredentialsCache();
     
      PrincipalName princ = new PrincipalName( principal, PrincipalNameType.KRB_NT_PRINCIPAL );
      princ.setRealm( tgt.getRealm() );
      credCache.setPrimaryPrincipalName( princ );
     
      Credentials cred = new Credentials( tgt );
      credCache.addCredentials( cred );
     
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.