Examples of ConnectionParameter


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

     * Test binding to the server.
     */
    public void testBind()
    {
        StudioProgressMonitor monitor = getProgressMonitor();
        ConnectionParameter connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, true, null );
        Connection connection = new Connection( connectionParameter );
        JNDIConnectionWrapper connectionWrapper = connection.getJNDIConnectionWrapper();
        IAuthHandler authHandler = getAuthHandler();
        ConnectionCorePlugin.getDefault().setAuthHandler( authHandler );
View Full Code Here

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

     * Test failed binds to the server.
     */
    public void testBindFailures()
    {
        StudioProgressMonitor monitor = null;
        ConnectionParameter connectionParameter = null;
        Connection connection = null;
        JNDIConnectionWrapper connectionWrapper = null;

        // simple auth without principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, null, null, null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertFalse( connectionWrapper.isConnected() );
        assertNotNull( monitor.getException() );
        assertTrue( monitor.getException() instanceof NamingException );

        // simple auth with invalid principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "bar", null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
View Full Code Here

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

     * Test searching.
     */
    public void testSearch()
    {
        StudioProgressMonitor monitor = null;
        ConnectionParameter connectionParameter = null;
        Connection connection = null;
        JNDIConnectionWrapper connectionWrapper = null;

        // simple auth without principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
View Full Code Here

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

     *
     * @return a test connection
     */
    private Connection getTestConnection()
    {
        ConnectionParameter cp = connectionParameterPageModifyListener.getTestConnectionParameters();
        Connection conn = new Connection( cp );
        return conn;
    }
View Full Code Here

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

    /**
     * @see org.apache.directory.studio.connection.ui.ConnectionParameterPageModifyListener#getTestConnectionParameters()
     */
    public ConnectionParameter getTestConnectionParameters()
    {
        ConnectionParameter connectionParameter = new ConnectionParameter();
        for ( int i = 0; i < pages.length; i++ )
        {
            pages[i].saveParameters( connectionParameter );
        }
        return connectionParameter;
View Full Code Here

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

        Connection connection = ( Connection ) getConnection( getElement() );
       
        // save modified parameters
        boolean parametersModified = false;
        boolean reconnectionRequired = false;
        ConnectionParameter connectionParameter = new ConnectionParameter();
        connectionParameter.setId( connection.getConnectionParameter().getId() );
        for ( int i = 0; i < pages.length; i++ )
        {
            pages[i].saveParameters( connectionParameter );
            pages[i].saveDialogSettings();
            parametersModified |= pages[i].areParametersModifed();
View Full Code Here

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

     *
     * @return a test connection
     */
    private Connection getTestConnection()
    {
        ConnectionParameter cp = new ConnectionParameter( null, getHostName(), getPort(), getEncyrptionMethod(),
            ConnectionParameter.AuthenticationMethod.NONE, null, null, null );
        Connection conn = new Connection( cp );
        return conn;
    }
View Full Code Here

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

     * @throws ConnectionIOException
     *      if an error occurs when converting values
     */
    private static ConnectionParameter readConnection( Element element ) throws ConnectionIOException
    {
        ConnectionParameter connection = new ConnectionParameter();

        // ID
        Attribute idAttribute = element.attribute( ID_TAG );
        if ( idAttribute != null )
        {
            connection.setId( idAttribute.getValue() );
        }

        // Name
        Attribute nameAttribute = element.attribute( NAME_TAG );
        if ( nameAttribute != null )
        {
            connection.setName( nameAttribute.getValue() );
        }

        // Host       
        Attribute hostAttribute = element.attribute( HOST_TAG );
        if ( hostAttribute != null )
        {
            connection.setHost( hostAttribute.getValue() );
        }

        // Port
        Attribute portAttribute = element.attribute( PORT_TAG );
        if ( portAttribute != null )
        {
            try
            {
                connection.setPort( Integer.parseInt( portAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Port' of connection '" + connection.getName()
                    + "' as int value. Port value :" + portAttribute.getValue() );
            }
        }

        // Encryption Method
        Attribute encryptionMethodAttribute = element.attribute( ENCRYPTION_METHOD_TAG );
        if ( encryptionMethodAttribute != null )
        {
            try
            {
                connection.setEncryptionMethod( EncryptionMethod.valueOf( encryptionMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Encryption Method' of connection '"
                    + connection.getName() + "' as int value. Encryption Method value :"
                    + encryptionMethodAttribute.getValue() );
            }
        }

        // Auth Method
        Attribute authMethodAttribute = element.attribute( AUTH_METHOD_TAG );
        if ( authMethodAttribute != null )
        {
            try
            {
                connection.setAuthMethod( AuthenticationMethod.valueOf( authMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Authentication Method' of connection '"
                    + connection.getName() + "' as int value. Authentication Method value :"
                    + authMethodAttribute.getValue() );
            }
        }

        // Bind Principal       
        Attribute bindPrincipalAttribute = element.attribute( BIND_PRINCIPAL_TAG );
        if ( bindPrincipalAttribute != null )
        {
            connection.setBindPrincipal( bindPrincipalAttribute.getValue() );
        }

        // Bind Password
        Attribute bindPasswordAttribute = element.attribute( BIND_PASSWORD_TAG );
        if ( bindPasswordAttribute != null )
        {
            connection.setBindPassword( bindPasswordAttribute.getValue() );
        }

        // Extended Properties
        Element extendedPropertiesElement = element.element( EXTENDED_PROPERTIES_TAG );
        if ( extendedPropertiesElement != null )
        {
            for ( Iterator<?> i = extendedPropertiesElement.elementIterator( EXTENDED_PROPERTY_TAG ); i.hasNext(); )
            {
                Element extendedPropertyElement = ( Element ) i.next();

                Attribute keyAttribute = extendedPropertyElement.attribute( KEY_TAG );
                Attribute valueAttribute = extendedPropertyElement.attribute( VALUE_TAG );

                if ( keyAttribute != null && valueAttribute != null )
                {
                    connection.setExtendedProperty( keyAttribute.getValue(), valueAttribute.getValue() );
                }
            }
        }

        return connection;
View Full Code Here

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

     * Creates the connection
     */
    private void createConnection( LdapServer server, ServerConfigurationV154 configuration )
    {
        // Creating the connection parameter object
        ConnectionParameter connectionParameter = new ConnectionParameter();

        // Authentication method
        connectionParameter.setAuthMethod( AuthenticationMethod.SIMPLE );

        // LDAP or LDAPS?
        if ( configuration.isEnableLdap() )
        {
            connectionParameter.setEncryptionMethod( EncryptionMethod.NONE );
            connectionParameter.setPort( configuration.getLdapPort() );
        }
        else if ( configuration.isEnableLdaps() )
        {
            connectionParameter.setEncryptionMethod( EncryptionMethod.LDAPS );
            connectionParameter.setPort( configuration.getLdapsPort() );
        }

        // Bind password
        // Checking of the connection passwords keystore is enabled
        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
        {
            // Getting the password keystore manager
            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
                .getPasswordsKeyStoreManager();

            // Checking if the keystore is loaded
            if ( passwordsKeyStoreManager.isLoaded() )
            {
                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
            }
            else
            {
                // Asking the user to load the keystore
                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
                {
                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
                }
            }
        }
        else
        {
            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
        }

        // Bind principal
        connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$

        // Host
        connectionParameter.setHost( "localhost" ); //$NON-NLS-1$

        // Name
        connectionParameter.setName( server.getName() );

        // Network Provider
        connectionParameter.setNetworkProvider( ConnectionCorePlugin.getDefault().getDefaultNetworkProvider() );

        // Creating the connection
        CreateConnectionActionHelper.createLdapBrowserConnection( server, new Connection( connectionParameter ) );
    }
View Full Code Here

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

     *
     * @return a test connection
     */
    private Connection getTestConnection()
    {
        ConnectionParameter cp = connectionParameterPageModifyListener.getTestConnectionParameters();
        Connection conn = new Connection( cp );
        return conn;
    }
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.