Examples of ChangePasswordException


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

            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

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

            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

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

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

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

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

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

        {
            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

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

        {
            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

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

        }
        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

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

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

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

            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
TOP
Copyright © 2018 www.massapi.com. 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.