Package org.apache.directory.studio.connection.core

Examples of org.apache.directory.studio.connection.core.Credentials


    public ICredentials getCredentials( final ConnectionParameter connectionParameter )
    {

        if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) ) //$NON-NLS-1$
        {
            return new Credentials( "", "", connectionParameter ); //$NON-NLS-1$ //$NON-NLS-2$
        }
        else if ( connectionParameter.getBindPassword() != null && !"".equals( connectionParameter.getBindPassword() ) ) //$NON-NLS-1$
        {
            return new Credentials( connectionParameter.getBindPrincipal(), connectionParameter.getBindPassword(),
                connectionParameter );
        }
        else
        {
            final String[] pw = new String[1];
            PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable()
            {
                public void run()
                {
                    CredentialsDialog dialog = new CredentialsDialog(
                        PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                        NLS
                            .bind(
                                Messages.getString( "UIAuthHandler.EnterPasswordFor" ), new String[] { connectionParameter.getName() } ), //$NON-NLS-1$
                        Messages.getString( "UIAuthHandler.PleaseEnterPasswordOfUser" ) + connectionParameter.getBindPrincipal() + ":", "", null ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                    if ( dialog.open() == CredentialsDialog.OK )
                    {
                        pw[0] = dialog.getValue();
                    }
                    else
                    {
                        pw[0] = null;
                    }
                }
            } );

            if ( pw[0] == null )
            {
                return null;
            }
            else
            {
                return new Credentials( connectionParameter.getBindPrincipal(), pw[0], connectionParameter );
            }
        }

    }
View Full Code Here


    {
        IAuthHandler authHandler = new IAuthHandler()
        {
            public ICredentials getCredentials( ConnectionParameter connectionParameter )
            {
                return new Credentials( connectionParameter.getBindPrincipal(), connectionParameter.getBindPassword(),
                    connectionParameter );
            }
        };
        return authHandler;
    }
View Full Code Here

    public ICredentials getCredentials( final ConnectionParameter connectionParameter )
    {

        if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) )
        {
            return new Credentials( "", "", connectionParameter );
        }
        else if ( connectionParameter.getBindPassword() != null && !"".equals( connectionParameter.getBindPassword() ) )
        {
            return new Credentials( connectionParameter.getBindPrincipal(), connectionParameter.getBindPassword(),
                connectionParameter );
        }
        else
        {
            final String[] pw = new String[1];
            PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable()
            {
                public void run()
                {
                    CredentialsDialog dialog = new CredentialsDialog( PlatformUI.getWorkbench().getDisplay()
                        .getActiveShell(), "Enter Password for '" + connectionParameter.getName() + "'",
                        "Please enter password of user " + connectionParameter.getBindPrincipal() + ":", "", null );
                    if ( dialog.open() == CredentialsDialog.OK )
                    {
                        pw[0] = dialog.getValue();
                    }
                    else
                    {
                        pw[0] = null;
                    }
                }
            } );

            if ( pw[0] == null )
            {
                return null;
            }
            else
            {
                return new Credentials( connectionParameter.getBindPrincipal(), pw[0], connectionParameter );
            }
        }

    }
View Full Code Here

            }
        } );

        if ( password[0] != null )
        {
            return new Credentials( connectionParameter.getBindPrincipal(), password[0],
                connectionParameter );
        }

        return null;
    }
View Full Code Here

    public ICredentials getCredentials( final ConnectionParameter connectionParameter )
    {
        // Checking if the bind principal is null or empty (no authentication)
        if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) ) //$NON-NLS-1$
        {
            return new Credentials( "", "", connectionParameter ); //$NON-NLS-1$ //$NON-NLS-2$
        }
        else
        {
            // Checking of the connection passwords keystore is enabled
            if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
            {
                // Getting the passwords keystore manager
                PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
                    .getPasswordsKeyStoreManager();

                // Checking if the keystore is not loaded
                if ( !passwordsKeyStoreManager.isLoaded() )
                {
                    // Asking the user to load the keystore
                    if ( !PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
                    {
                        // The user failed to load the keystore and cancelled
                        return null;
                    }
                }

                // Getting the password
                String password = passwordsKeyStoreManager.getConnectionPassword( connectionParameter.getId() );

                // Checking if the bind password is available (the user chose to store the password)
                if ( password != null
                    && !"".equals( password ) ) //$NON-NLS-1$
                {
                    return new Credentials( connectionParameter.getBindPrincipal(),
                        password, connectionParameter );
                }
                // The user chose NOT to store the password, we need to ask him
                else
                {
                    return askConnectionPassword( connectionParameter );
                }
            }
            // Connection passwords keystore is NOT enabled
            else
            {
                // Checking if the bind password is available (the user chose to store the password)
                if ( connectionParameter.getBindPassword() != null
                    && !"".equals( connectionParameter.getBindPassword() ) ) //$NON-NLS-1$
                {
                    return new Credentials( connectionParameter.getBindPrincipal(),
                        connectionParameter.getBindPassword(), connectionParameter );
                }
                // The user chose NOT to store the password, we need to ask him
                else
                {
View Full Code Here

     */
    public ICredentials getCredentials( final ConnectionParameter connectionParameter )
    {
        if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) ) //$NON-NLS-1$
        {
            return new Credentials( "", "", connectionParameter ); //$NON-NLS-1$ //$NON-NLS-2$
        }
        else if ( connectionParameter.getBindPassword() != null && !"".equals( connectionParameter.getBindPassword() ) ) //$NON-NLS-1$
        {
            return new Credentials( connectionParameter.getBindPrincipal(), connectionParameter.getBindPassword(),
                connectionParameter );
        }
        else
        {
            final String[] pw = new String[1];
            PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable()
            {
                public void run()
                {
                    CredentialsDialog dialog = new CredentialsDialog(
                        PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                        NLS.bind(
                            Messages.getString( "UIAuthHandler.EnterPasswordFor" ), new String[] { connectionParameter.getName() } ), //$NON-NLS-1$
                        NLS.bind(
                            Messages.getString( "UIAuthHandler.PleaseEnterPasswordOfUser" ), connectionParameter.getBindPrincipal() ), "", null ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                    if ( dialog.open() == CredentialsDialog.OK )
                    {
                        pw[0] = dialog.getValue();
                    }
                    else
                    {
                        pw[0] = null;
                    }
                }
            } );

            if ( pw[0] == null )
            {
                return null;
            }
            else
            {
                return new Credentials( connectionParameter.getBindPrincipal(), pw[0], connectionParameter );
            }
        }
    }
View Full Code Here

    public ICredentials getCredentials( final ConnectionParameter connectionParameter )
    {

        if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) )
        {
            return new Credentials( "", "", connectionParameter );
        }
        else if ( connectionParameter.getBindPassword() != null && !"".equals( connectionParameter.getBindPassword() ) )
        {
            return new Credentials( connectionParameter.getBindPrincipal(), connectionParameter.getBindPassword(),
                connectionParameter );
        }
        else
        {
            final String[] pw = new String[1];
            PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable()
            {
                public void run()
                {
                    CredentialsDialog dialog = new CredentialsDialog( PlatformUI.getWorkbench().getDisplay()
                        .getActiveShell(), "Enter Password for '" + connectionParameter.getName() + "'",
                        "Please enter password of user " + connectionParameter.getBindPrincipal() + ":", "", null );
                    if ( dialog.open() == CredentialsDialog.OK )
                    {
                        pw[0] = dialog.getValue();
                    }
                    else
                    {
                        pw[0] = null;
                    }
                }
            } );

            if ( pw[0] == null )
            {
                return null;
            }
            else
            {
                return new Credentials( connectionParameter.getBindPrincipal(), pw[0], connectionParameter );
            }
        }

    }
View Full Code Here

    {
        IAuthHandler authHandler = new IAuthHandler()
        {
            public ICredentials getCredentials( ConnectionParameter connectionParameter )
            {
                return new Credentials( connectionParameter.getBindPrincipal(), connectionParameter.getBindPassword(),
                    connectionParameter );
            }
        };
        return authHandler;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.connection.core.Credentials

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.