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

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


    /**
     * @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

        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

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

        Connection[] connections = getSelectedConnections();
        ConnectionParameterPage[] connectionParameterPages = ConnectionParameterPageManager
            .getConnectionParameterPages();
        for ( Connection connection : connections )
        {
            ConnectionParameter parameter = connection.getConnectionParameter();
            LdapURL ldapUrl = new LdapURL();
            ldapUrl.setDn( LdapDN.EMPTY_LDAPDN );
            for ( ConnectionParameterPage connectionParameterPage : connectionParameterPages )
            {
                connectionParameterPage.mergeParametersToLdapURL( parameter, ldapUrl );
View Full Code Here

                if ( StringUtils.isNotEmpty( line ) )
                {
                    try
                    {
                        LdapURL ldapUrl = new LdapURL( line );
                        ConnectionParameter parameter = new ConnectionParameter();
                        for ( ConnectionParameterPage connectionParameterPage : connectionParameterPages )
                        {
                            connectionParameterPage.mergeLdapUrlToParameters( ldapUrl, parameter );
                        }
                        Connection connection = new Connection( parameter );
View Full Code Here

     *
     */
    public Connection createTestConnection( String name, int port ) throws Exception
    {
        ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
        ConnectionParameter connectionParameter = new ConnectionParameter();
        connectionParameter.setName( name );
        connectionParameter.setHost( "localhost" );
        connectionParameter.setPort( port );
        connectionParameter.setEncryptionMethod( EncryptionMethod.NONE );
        connectionParameter.setAuthMethod( AuthenticationMethod.SIMPLE );
        connectionParameter.setBindPrincipal( "uid=admin,ou=system" );
        connectionParameter.setBindPassword( "secret" );
        Connection connection = new Connection( connectionParameter );
        connectionManager.addConnection( connection );

        ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
            .getConnectionFolderManager();
View Full Code Here

     * @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() //$NON-NLS-1$
                    + "' as int value. Port value :" + portAttribute.getValue() ); //$NON-NLS-1$
            }
        }

        // 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 '" //$NON-NLS-1$
                    + connection.getName() + "' as int value. Encryption Method value :" //$NON-NLS-1$
                    + 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 '" //$NON-NLS-1$
                    + connection.getName() + "' as int value. Authentication Method value :" //$NON-NLS-1$
                    + 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() );
        }

        // SASL Realm
        Attribute saslRealmAttribute = element.attribute( SASL_REALM_TAG );
        if ( saslRealmAttribute != null )
        {
            connection.setSaslRealm( saslRealmAttribute.getValue() );
        }

        // SASL Quality of Protection
        Attribute saslQopAttribute = element.attribute( SASL_QOP_TAG );
        if ( saslQopAttribute != null )
        {
            connection.setSaslQop( SaslQop.valueOf( saslQopAttribute.getValue() ) );
        }

        // SASL Security Strength
        Attribute saslSecStrengthAttribute = element.attribute( SASL_SEC_STRENGTH_TAG );
        if ( saslSecStrengthAttribute != null )
        {
            connection.setSaslSecurityStrength( SaslSecurityStrength.valueOf( saslSecStrengthAttribute.getValue() ) );
        }

        // SASL Mutual Authentication
        Attribute saslMutualAuthAttribute = element.attribute( SASL_MUTUAL_AUTH_TAG );
        if ( saslMutualAuthAttribute != null )
        {
            connection.setSaslMutualAuthentication( Boolean.parseBoolean( saslMutualAuthAttribute.getValue() ) );
        }

        // KRB5 Credentials Conf
        Attribute krb5CredentialsConf = element.attribute( KRB5_CREDENTIALS_CONF_TAG );
        if ( krb5CredentialsConf != null )
        {
            connection.setKrb5CredentialConfiguration( Krb5CredentialConfiguration.valueOf( krb5CredentialsConf
                .getValue() ) );
        }

        // KRB5 Configuration
        Attribute krb5Config = element.attribute( KRB5_CONFIG_TAG );
        if ( krb5Config != null )
        {
            connection.setKrb5Configuration( Krb5Configuration.valueOf( krb5Config.getValue() ) );
        }

        // KRB5 Configuration File
        Attribute krb5ConfigFile = element.attribute( KRB5_CONFIG_FILE_TAG );
        if ( krb5ConfigFile != null )
        {
            connection.setKrb5ConfigurationFile( krb5ConfigFile.getValue() );
        }

        // KRB5 REALM
        Attribute krb5Realm = element.attribute( KRB5_REALM_TAG );
        if ( krb5Realm != null )
        {
            connection.setKrb5Realm( krb5Realm.getValue() );
        }

        // KRB5 KDC Host
        Attribute krb5KdcHost = element.attribute( KRB5_KDC_HOST_TAG );
        if ( krb5KdcHost != null )
        {
            connection.setKrb5KdcHost( krb5KdcHost.getValue() );
        }

        // KRB5 KDC Port
        Attribute krb5KdcPort = element.attribute( KRB5_KDC_PORT_TAG );
        if ( krb5KdcPort != null )
        {
            connection.setKrb5KdcPort( Integer.valueOf( krb5KdcPort.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

     * Tests connecting to the server.
     */
    public void testConnect()
    {
        StudioProgressMonitor monitor = getProgressMonitor();
        ConnectionParameter connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getPort(),
            EncryptionMethod.NONE, AuthenticationMethod.NONE, null, null, null, true, null );
        Connection connection = new Connection( connectionParameter );
        JNDIConnectionWrapper connectionWrapper = connection.getJNDIConnectionWrapper();

        assertFalse( connectionWrapper.isConnected() );
View Full Code Here

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

        // invalid port
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getPort() + 1,
            EncryptionMethod.NONE, AuthenticationMethod.NONE, null, null, null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        assertFalse( connectionWrapper.isConnected() );
        assertNotNull( monitor.getException() );
        assertTrue( monitor.getException() instanceof CommunicationException );
        assertNotNull( monitor.getException().getCause() );
        assertTrue( monitor.getException().getCause() instanceof ConnectException );

        // unknown host
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "555.555.555.555", ldapServer.getPort(),
            EncryptionMethod.NONE, AuthenticationMethod.NONE, null, null, null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        assertFalse( connectionWrapper.isConnected() );
View Full Code Here

TOP

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

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.