Package org.apache.directory.server.kerberos.changepwd.exceptions

Examples of org.apache.directory.server.kerberos.changepwd.exceptions.ChangePasswordException


        short pvno = request.getVersionNumber();
       
        if ( ( pvno != AbstractPasswordMessage.PVNO ) && ( pvno != AbstractPasswordMessage.OLD_PVNO ) )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_BAD_VERSION );
        }

        if ( request.getAuthHeader() == null || request.getAuthHeader().getTicket() == null )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_AUTHERROR );
        }

        ApReq authHeader = request.getAuthHeader();
        Ticket ticket = authHeader.getTicket();
View Full Code Here


            byte[] decryptedData = cipherTextHandler.decrypt( subSessionKey, encReqPrivPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
            EncKrbPrivPart privatePart = KerberosDecoder.decodeEncKrbPrivPart( decryptedData );

            if( authenticator.getSeqNumber() != privatePart.getSeqNumber() )
            {
                throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_MALFORMED );   
            }
           
            if ( request.getVersionNumber() == AbstractPasswordMessage.OLD_PVNO )
            {
                passwordData = new ChangePasswdData();
                passwordData.setNewPasswd( privatePart.getUserData() );
            }
            else
            {
                Asn1Decoder passwordDecoder = new Asn1Decoder();
                ByteBuffer stream = ByteBuffer.wrap( privatePart.getUserData() );
                ChangePasswdDataContainer container = new ChangePasswdDataContainer( stream );
                passwordDecoder.decode( stream, container );
                passwordData = container.getChngPwdData();
            }
        }
        catch ( KerberosException ke )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_SOFTERROR, ke );
        }

        changepwContext.setChngPwdData( passwordData );
    }
View Full Code Here

        {
            encPrivPart = cipherTextHandler.seal( subSessionKey, privPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
        }
        catch ( KerberosException ke )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_SOFTERROR, ke );
        }

        KrbPriv privateMessage = new KrbPriv();
        privateMessage.setEncPart( encPrivPart );

        // Begin AP_REP generation
        EncApRepPart repPart = new EncApRepPart();
        repPart.setCTime( authenticator.getCtime() );
        repPart.setCusec( authenticator.getCusec() );
       
        if ( authenticator.getSeqNumber() != null )
        {
            repPart.setSeqNumber( authenticator.getSeqNumber() );
        }
       
        repPart.setSubkey( subSessionKey );

        EncryptedData encRepPart;

        try
        {
            encRepPart = cipherTextHandler.seal( ticket.getEncTicketPart().getKey(), repPart, KeyUsage.AP_REP_ENC_PART_SESS_KEY );
        }
        catch ( KerberosException ke )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_SOFTERROR, ke );
        }

        ApRep appReply = new ApRep();
        appReply.setEncPart( encRepPart );
View Full Code Here

        }
        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

        {
            kerberosDecoder.decode( stream, encTgsRepPartContainer );
        }
        catch ( DecoderException de )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_MALFORMED, de );
        }

        // get the decoded EncTgsRepPart
        EncTgsRepPart encTgsRepPart = ( ( EncTgsRepPartContainer ) encTgsRepPartContainer ).getEncTgsRepPart();
View Full Code Here

            ebyPrincipalEntry = StoreUtils.findPrincipalEntry( adminSession, searchBaseDn, byPrincipal.getName() );

            if ( ebyPrincipalEntry == null )
            {
                throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_HARDERROR,
                    ( "No such principal " + byPrincipal ).getBytes() );
            }

            SchemaManager schemaManager = directoryService.getSchemaManager();

            CoreSession bySession = null;

            boolean isAdmin = ebyPrincipalEntry.getDn().getNormName()
                .equals( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );

            if ( !isInitialTicket && !isAdmin )
            {
                throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_INITIAL_FLAG_NEEDED );
            }

            // if admin assign the admin session
            if ( isAdmin )
            {
                bySession = adminSession;
            }
            // otherwise create a new session for the user with 'byPrincipal' who is trying to change the password for 'forPrincipal'
            else
            {
                LdapPrincipal byLdapPrincipal = new LdapPrincipal( schemaManager, ebyPrincipalEntry.getDn(),
                    AuthenticationLevel.SIMPLE );

                bySession = new DefaultCoreSession( byLdapPrincipal, directoryService );
            }

            Attribute newPasswordAttribute = new DefaultAttribute(
                schemaManager.lookupAttributeTypeRegistry( SchemaConstants.USER_PASSWORD_AT ),
                Strings.getBytesUtf8( newPassword ) );
            Modification passwordMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
                newPasswordAttribute );

            Attribute principalAttribute = new DefaultAttribute(
                schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ),
                forPrincipal.getName() );
            Modification principalMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
                principalAttribute );

            Entry forPrincipalEntry = StoreUtils.findPrincipalEntry( bySession, searchBaseDn, forPrincipal.getName() );

            adminSession.modify( forPrincipalEntry.getDn(), passwordMod, principalMod );
        }
        catch ( LdapException e )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_ACCESSDENIED, e );
        }
        catch ( Exception e )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_HARDERROR, e );
        }
    }
View Full Code Here

            throw e;
        }
        catch( Exception e )
        {
            LOG.warn( "failed to change the password", e );
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_HARDERROR, e );
        }
        finally
        {
            if ( channel != null )
            {
View Full Code Here

           
            return new ChangePasswordRequest( pvno, authHeader, privMessage );
        }
        catch( KerberosException e )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_MALFORMED, e );
        }
    }
View Full Code Here

            return new ChangePasswordReply( protocolVersion, applicationReply, privateMessage );
        }
        catch ( KerberosException e )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_MALFORMED, e );
        }
    }
View Full Code Here

        {
            decoder.decode( errorBuffer, container );
        }
        catch( DecoderException e )
        {
            throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_MALFORMED, e );
        }
       
        KrbError errorMessage = container.getKrbError();

        return new ChangePasswordError( pvno, errorMessage );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.kerberos.changepwd.exceptions.ChangePasswordException

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.