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

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


        if ( element instanceof IAdaptable )
        {
            browserConnection = ( IBrowserConnection ) ( ( IAdaptable ) element ).getAdapter( IBrowserConnection.class );
            if ( browserConnection == null )
            {
                Connection connection = ( Connection ) ( ( IAdaptable ) element ).getAdapter( Connection.class );
                browserConnection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection(
                    connection );
            }
        }
        return browserConnection;
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

        checkPrincipalPasswordAuthButton.addSelectionListener( new SelectionAdapter()
        {
            public void widgetSelected( SelectionEvent e )
            {
                Connection connection = getTestConnection();
                CheckBindRunnable runnable = new CheckBindRunnable( connection );
                IStatus status = RunnableContextRunner.execute( runnable, runnableContext, true );
                if ( status.isOK() )
                {
                    MessageDialog.openInformation( Display.getDefault().getActiveShell(), Messages
View Full Code Here

        // connections
        List<Connection> connections = getConnectionsToPaste();
        for ( Connection connection : connections )
        {
            Connection newConnection = ( Connection ) connection.clone();
            connectionManager.addConnection( newConnection );
            targetFolder.addConnectionId( newConnection.getId() );
        }

        // connection folders
        List<ConnectionFolder> connectionFolders = getConnectionFoldersToPaste();
        for ( ConnectionFolder connectionFolder : connectionFolders )
View Full Code Here

                        ConnectionParameter parameter = new ConnectionParameter();
                        for ( ConnectionParameterPage connectionParameterPage : connectionParameterPages )
                        {
                            connectionParameterPage.mergeLdapUrlToParameters( ldapUrl, parameter );
                        }
                        Connection connection = new Connection( parameter );
                        connections.add( connection );
                    }
                    catch ( LdapURLEncodingException e )
                    {
                        // this was a string that doesn't represent an LDAP URL, ignore
View Full Code Here

                InputStream connectionsInputStream = importFile.getInputStream( connectionsEntry );
                ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
                Set<ConnectionParameter> connectionParametersSet = ConnectionIO.load( connectionsInputStream );
                for ( ConnectionParameter connectionParameter : connectionParametersSet )
                {
                    connectionManager.addConnection( new Connection( connectionParameter ) );
                }
            }

            // Loading the ConnectionFolders
            ZipEntry connectionFoldersEntry = importFile.getEntry( "connectionFolders.xml" ); //$NON-NLS-1$
            ConnectionFolder rootConnectionFolder = null;
            if ( connectionFoldersEntry != null )
            {
                InputStream connectionFoldersInputStream = importFile.getInputStream( connectionFoldersEntry );
                ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
                    .getConnectionFolderManager();
                Set<ConnectionFolder> connectionFoldersSet = ConnectionIO
                    .loadConnectionFolders( connectionFoldersInputStream );
                for ( ConnectionFolder connectionFolder : connectionFoldersSet )
                {
                    if ( !"0".equals( connectionFolder.getId() ) ) //$NON-NLS-1$
                    {
                        connectionFolderManager.addConnectionFolder( connectionFolder );
                    }
                    else
                    {
                        rootConnectionFolder = connectionFolder;
                    }
                }

                // Root ConnectionFolder must be the last one to be loaded
                if ( rootConnectionFolder != null )
                {
                    ConnectionFolder realRootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
                    // Adding subfolders
                    List<String> realSubFolderIds = realRootConnectionFolder.getSubFolderIds();
                    for ( String subFolderId : rootConnectionFolder.getSubFolderIds() )
                    {
                        if ( !realSubFolderIds.contains( subFolderId ) )
                        {
                            realRootConnectionFolder.addSubFolderId( subFolderId );
                        }
                    }

                    // Adding connections
                    List<String> realConnectionIds = realRootConnectionFolder.getConnectionIds();
                    for ( String connectionId : rootConnectionFolder.getConnectionIds() )
                    {
                        if ( !realConnectionIds.contains( connectionId ) )
                        {
                            realRootConnectionFolder.addConnectionId( connectionId );
                        }
                    }
                }
            }

            // Loading the BrowserConnections
            ZipEntry browserConnectionsEntry = importFile.getEntry( "browserconnections.xml" ); //$NON-NLS-1$
            if ( browserConnectionsEntry != null )
            {
                InputStream browserConnectionsInputStream = importFile.getInputStream( browserConnectionsEntry );

                Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
                Map<String, IBrowserConnection> connectionsMap = new HashMap<String, IBrowserConnection>();
                for ( int i = 0; i < connections.length; i++ )
                {
                    Connection connection = connections[i];
                    BrowserConnection browserConnection = new BrowserConnection( connection );
                    connectionsMap.put( connection.getId(), browserConnection );
                }

                BrowserConnectionIO.load( browserConnectionsInputStream, connectionsMap );
            }
        }
View Full Code Here

            ConnectionFolder folder = ( ConnectionFolder ) obj;
            return folder.getName();
        }
        if ( obj instanceof Connection )
        {
            Connection conn = ( Connection ) obj;
            if ( conn.getEncryptionMethod() == EncryptionMethod.LDAPS )
            {
                return conn.getName() + " (LDAPS)"; //$NON-NLS-1$
            }
            else if ( conn.getEncryptionMethod() == EncryptionMethod.START_TLS )
            {
                return conn.getName() + " (StartTLS)"; //$NON-NLS-1$
            }
            else
            {
                return conn.getName();
            }
        }
        else if ( obj != null )
        {
            return obj.toString();
View Full Code Here

    protected IBrowserConnection getConnection()
    {
        if ( getSelectedConnections().length > 0
            && getSelectedConnections()[0].getJNDIConnectionWrapper().isConnected() )
        {
            Connection connection = getSelectedConnections()[0];
            IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
                .getBrowserConnection( connection );
            return browserConnection;
        }
        else
View Full Code Here

        // ensure connection was created
        ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
        assertNotNull( connectionManager.getConnections() );
        assertEquals( 1, connectionManager.getConnections().length );
        Connection connection = connectionManager.getConnections()[0];
        assertEquals( "NewConnectionWizardTest", connection.getName() );
        assertEquals( "localhost", connection.getHost() );
        assertEquals( ldapServer.getPort(), connection.getPort() );
        assertEquals( AuthenticationMethod.SIMPLE, connection.getAuthMethod() );
        assertEquals( "uid=admin,ou=system", connection.getBindPrincipal() );
        assertEquals( "secret", connection.getBindPassword() );

        // ensure connection is visible in Connections view
        assertEquals( 1, connectionsViewBot.getConnectionCount() );

        // close connection
View Full Code Here

    private void bindCurrentPassword()
    {
        if ( !"".equals( testPasswordText.getText() ) && entry != null //$NON-NLS-1$
            && entry.getBrowserConnection().getConnection() != null )
        {
            Connection connection = ( Connection ) entry.getBrowserConnection().getConnection().clone();
            connection.getConnectionParameter().setName( null );
            connection.getConnectionParameter().setBindPrincipal( entry.getDn().getUpName() );
            connection.getConnectionParameter().setBindPassword( testPasswordText.getText() );
            connection.getConnectionParameter().setAuthMethod( AuthenticationMethod.SIMPLE );

            CheckBindRunnable runnable = new CheckBindRunnable( connection );
            IStatus status = RunnableContextRunner.execute( runnable, null, true );
            if ( status.isOK() )
            {
View Full Code Here

TOP

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

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.