Package org.apache.directory.shared.kerberos.messages

Examples of org.apache.directory.shared.kerberos.messages.KrbError


        handler.messageReceived( session, message );

        Object msg = session.getMessage();
        assertEquals( "session.getMessage() instanceOf", KrbError.class, msg.getClass() );
        KrbError error = ( KrbError ) msg;
        assertEquals( "Additional pre-authentication required", ErrorType.KDC_ERR_PREAUTH_REQUIRED,
            error.getErrorCode() );
    }
View Full Code Here


        handler.messageReceived( session, message );

        Object msg = session.getMessage();
        assertEquals( "session.getMessage() instanceOf", KrbError.class, msg.getClass() );
        KrbError error = ( KrbError ) msg;
        assertEquals( "Integrity check on decrypted field failed", ErrorType.KRB_AP_ERR_BAD_INTEGRITY,
            error.getErrorCode() );
    }
View Full Code Here

        handler.messageReceived( session, message );

        Object msg = session.getMessage();
        assertEquals( "session.getMessage() instanceOf", KrbError.class, msg.getClass() );
        KrbError error = ( KrbError ) msg;

        assertEquals( "Pre-authentication information was invalid", ErrorType.KDC_ERR_PREAUTH_FAILED,
            error.getErrorCode() );
    }
View Full Code Here

        handler.messageReceived( session, message );

        Object msg = session.getMessage();
        assertEquals( "session.getMessage() instanceOf", KrbError.class, msg.getClass() );
        KrbError error = ( KrbError ) msg;

        assertEquals( "ignores unknown pre-auth type and expects PA_ENC_TMSTMP pre-auth",
            ErrorType.KDC_ERR_PREAUTH_REQUIRED, error.getErrorCode() );
    }
View Full Code Here

            else
            {
                log.warn( ke.getLocalizedMessage() );
            }

            KrbError errorMessage = getErrorMessage( server.getConfig().getServicePrincipal(), ke );

            session.write( new ChangePasswordError( request.getVersionNumber(), errorMessage ) );
        }
        catch ( Exception e )
        {
            log.error( I18n.err( I18n.ERR_152, e.getLocalizedMessage() ), e );

            KrbError error = getErrorMessage( server.getConfig().getServicePrincipal(), new ChangePasswordException(
                ChangePasswdErrorType.KRB5_KPASSWD_UNKNOWN_ERROR ) );
            session.write( new ChangePasswordError( request.getVersionNumber(), error ) );
        }
    }
View Full Code Here

    }


    private KrbError getErrorMessage( KerberosPrincipal principal, KerberosException exception )
    {
        KrbError krbError = new KrbError();

        KerberosTime now = new KerberosTime();

        //FIXME not sure if this is the correct error to set for KrbError instance
        // the correct change password protocol related error code is set in e-data anyway
        krbError.setErrorCode( ErrorType.KRB_ERR_GENERIC );
        krbError.setEText( exception.getLocalizedMessage() );
        krbError.setSName( new PrincipalName( principal ) );
        krbError.setSTime( now );
        krbError.setSusec( 0 );
        krbError.setRealm( principal.getRealm() );
        krbError.setEData( buildExplanatoryData( exception ) );

        return krbError;
    }
View Full Code Here

        handler.messageReceived( session, message );

        Object msg = session.getMessage();
        assertEquals( "session.getMessage() instanceOf", KrbError.class, msg.getClass() );
        KrbError error = ( KrbError ) msg;
        assertEquals( "KDC has no support for encryption type", ErrorType.KDC_ERR_ETYPE_NOSUPP, error.getErrorCode() );
    }
View Full Code Here

        catch ( DecoderException e )
        {
            fail();
        }

        KrbError krbError = container.getKrbError();

        String time = "20101119080043Z";
        assertEquals( 5, krbError.getProtocolVersionNumber() );
        assertEquals( KerberosMessageType.KRB_ERROR, krbError.getMessageType() );
        assertEquals( time, krbError.getCTime().getDate() );
        assertEquals( 1, krbError.getCusec() );
        assertEquals( time, krbError.getSTime().getDate() );
        assertEquals( 2, krbError.getSusec() );
        assertEquals( ErrorType.KDC_ERR_NONE, krbError.getErrorCode() );
        assertEquals( "crealm", krbError.getCRealm() );
        assertEquals( "cname", krbError.getCName().getNameString() );
        assertEquals( "realm", krbError.getRealm() );
        assertEquals( "sname", krbError.getSName().getNameString() );
        assertEquals( "etext", krbError.getEText() );
        assertTrue( Arrays.equals( new byte[]
            { 0, 1 }, krbError.getEData() ) );

        int encodedLen = krbError.computeLength();

        assertEquals( streamLen, encodedLen );

        ByteBuffer buffer = ByteBuffer.allocate( streamLen );
        try
        {
            buffer = krbError.encode( buffer );

            assertEquals( decoded, Strings.dumpBytes( buffer.array() ) );
        }
        catch ( EncoderException e )
        {
View Full Code Here

        catch ( DecoderException e )
        {
            fail();
        }

        KrbError krbError = container.getKrbError();

        assertNull( krbError.getCTime() );

        int encodedLen = krbError.computeLength();

        assertEquals( streamLen, encodedLen );

        ByteBuffer buffer = ByteBuffer.allocate( streamLen );
        try
        {
            buffer = krbError.encode( buffer );

            assertEquals( decoded, Strings.dumpBytes( buffer.array() ) );
        }
        catch ( EncoderException e )
        {
View Full Code Here

        catch ( DecoderException e )
        {
            fail();
        }

        KrbError krbError = container.getKrbError();

        assertEquals( 0, krbError.getCusec() );

        int encodedLen = krbError.computeLength();

        assertEquals( streamLen, encodedLen );

        ByteBuffer buffer = ByteBuffer.allocate( streamLen );
        try
        {
            buffer = krbError.encode( buffer );

            assertEquals( decoded, Strings.dumpBytes( buffer.array() ) );
        }
        catch ( EncoderException e )
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.kerberos.messages.KrbError

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.