Search in sources :

Example 1 with SvnAuthenticationManager

use of org.jetbrains.idea.svn.auth.SvnAuthenticationManager in project intellij-community by JetBrains.

the class SvnConfiguration method getAuthenticationManager.

public SvnAuthenticationManager getAuthenticationManager(@NotNull SvnVcs svnVcs) {
    if (myAuthManager == null) {
        // reloaded when configuration directory changes
        myAuthManager = new SvnAuthenticationManager(svnVcs, new File(getConfigurationDirectory()));
        Disposer.register(svnVcs.getProject(), () -> myAuthManager = null);
        getInteractiveManager(svnVcs);
        // to init
        myAuthManager.setAuthenticationProvider(new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, myAuthManager));
        myAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
    }
    return myAuthManager;
}
Also used : SvnAuthenticationManager(org.jetbrains.idea.svn.auth.SvnAuthenticationManager) SvnAuthenticationProvider(org.jetbrains.idea.svn.auth.SvnAuthenticationProvider) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File)

Example 2 with SvnAuthenticationManager

use of org.jetbrains.idea.svn.auth.SvnAuthenticationManager in project intellij-community by JetBrains.

the class SvnConfiguration method getInteractiveManager.

public SvnAuthenticationManager getInteractiveManager(@NotNull SvnVcs svnVcs) {
    if (myInteractiveManager == null) {
        myInteractiveManager = new SvnAuthenticationManager(svnVcs, new File(getConfigurationDirectory()));
        myInteractiveManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
        myInteractiveProvider = new SvnInteractiveAuthenticationProvider(svnVcs, myInteractiveManager);
        myInteractiveManager.setAuthenticationProvider(myInteractiveProvider);
    }
    return myInteractiveManager;
}
Also used : SvnAuthenticationManager(org.jetbrains.idea.svn.auth.SvnAuthenticationManager) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File) SvnInteractiveAuthenticationProvider(org.jetbrains.idea.svn.auth.SvnInteractiveAuthenticationProvider)

Example 3 with SvnAuthenticationManager

use of org.jetbrains.idea.svn.auth.SvnAuthenticationManager in project intellij-community by JetBrains.

the class SvnConfiguration method getPassiveAuthenticationManager.

public SvnAuthenticationManager getPassiveAuthenticationManager(@NotNull SvnVcs svnVcs) {
    if (myPassiveAuthManager == null) {
        myPassiveAuthManager = new SvnAuthenticationManager(svnVcs, new File(getConfigurationDirectory()));
        myPassiveAuthManager.setAuthenticationProvider(new ISVNAuthenticationProvider() {

            @Override
            public SVNAuthentication requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean authMayBeStored) {
                return null;
            }

            @Override
            public int acceptServerAuthentication(SVNURL url, String realm, Object certificate, boolean resultMayBeStored) {
                return REJECTED;
            }
        });
        myPassiveAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
    }
    return myPassiveAuthManager;
}
Also used : SvnAuthenticationManager(org.jetbrains.idea.svn.auth.SvnAuthenticationManager) SVNURL(org.tmatesoft.svn.core.SVNURL) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File) ISVNAuthenticationProvider(org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider) SVNErrorMessage(org.tmatesoft.svn.core.SVNErrorMessage) SVNAuthentication(org.tmatesoft.svn.core.auth.SVNAuthentication)

Example 4 with SvnAuthenticationManager

use of org.jetbrains.idea.svn.auth.SvnAuthenticationManager in project intellij-community by JetBrains.

the class SvnNativeClientAuthTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    final File certFile = new File(myPluginRoot, getTestDataDir() + "/svn/____.pfx");
    setNativeAcceleration(true);
    myVcs = SvnVcs.getInstance(myProject);
    // replace authentication provider so that pass credentials without dialogs
    final SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
    final File svnconfig = FileUtil.createTempDirectory("svnconfig", "");
    configuration.setConfigurationDirParameters(false, svnconfig.getPath());
    final SvnAuthenticationManager interactiveManager = configuration.getInteractiveManager(myVcs);
    final SvnTestInteractiveAuthentication authentication = new SvnTestInteractiveAuthentication(interactiveManager) {

        @Override
        public int acceptServerAuthentication(SVNURL url, String realm, Object certificate, boolean resultMayBeStored) {
            ++myCertificateAskedInteractivelyCount;
            return myCertificateAnswer;
        }

        @Override
        public SVNAuthentication requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean authMayBeStored) {
            if (myCancelAuth)
                return null;
            return super.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored);
        }
    };
    interactiveManager.setAuthenticationProvider(authentication);
    final SvnAuthenticationManager manager = configuration.getAuthenticationManager(myVcs);
    // will be the same as in interactive -> authentication notifier is not used
    manager.setAuthenticationProvider(authentication);
    authentication.addAuthentication(ISVNAuthenticationManager.PASSWORD, o -> {
        ++myCredentialsAskedInteractivelyCount;
        if (myCancelAuth)
            return null;
        if (myCredentialsCorrect) {
            return new SVNPasswordAuthentication(outHttpUser, outHttpPassword, mySaveCredentials, o, false);
        } else {
            myCredentialsCorrect = true;
            return new SVNPasswordAuthentication("1234214 23 4234", "324324", mySaveCredentials, o, false);
        }
    });
    authentication.addAuthentication(ISVNAuthenticationManager.SSL, o -> {
        ++myCredentialsAskedInteractivelyCount;
        if (myCancelAuth)
            return null;
        if (myCredentialsCorrect) {
            return new SVNSSLAuthentication(certFile, "12345", mySaveCredentials, o, false);
        } else {
            myCredentialsCorrect = true;
            return new SVNSSLAuthentication(new File("1232432423"), "3245321532534235445", mySaveCredentials, o, false);
        }
    });
    myCertificateAskedInteractivelyCount = 0;
    myCredentialsAskedInteractivelyCount = 0;
}
Also used : SvnAuthenticationManager(org.jetbrains.idea.svn.auth.SvnAuthenticationManager) SVNURL(org.tmatesoft.svn.core.SVNURL) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) SVNErrorMessage(org.tmatesoft.svn.core.SVNErrorMessage) Before(org.junit.Before)

Example 5 with SvnAuthenticationManager

use of org.jetbrains.idea.svn.auth.SvnAuthenticationManager in project intellij-community by JetBrains.

the class SvnProtocolsTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    myVcs = SvnVcs.getInstance(myProject);
    // replace authentication provider so that pass credentials without dialogs
    final SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
    final SvnAuthenticationManager interactiveManager = configuration.getInteractiveManager(myVcs);
    final SvnTestInteractiveAuthentication authentication = new SvnTestInteractiveAuthentication(interactiveManager) {

        @Override
        public int acceptServerAuthentication(SVNURL url, String realm, Object certificate, boolean resultMayBeStored) {
            return ISVNAuthenticationProvider.ACCEPTED;
        }
    };
    interactiveManager.setAuthenticationProvider(authentication);
    final SvnAuthenticationManager manager = configuration.getAuthenticationManager(myVcs);
    // will be the same as in interactive -> authentication notifier is not used
    manager.setAuthenticationProvider(authentication);
    authentication.addAuthentication(ISVNAuthenticationManager.SSH, o -> new SVNSSHAuthentication(SSH_USER_NAME, SSH_PASSWORD, SSH_PORT_NUMBER, true, o, false));
    authentication.addAuthentication(ISVNAuthenticationManager.USERNAME, o -> new SVNUserNameAuthentication(SSH_USER_NAME, true, o, false));
    authentication.addAuthentication(ISVNAuthenticationManager.PASSWORD, o -> new SVNPasswordAuthentication("sally", "abcde", true, o, false));
}
Also used : SvnAuthenticationManager(org.jetbrains.idea.svn.auth.SvnAuthenticationManager) SVNURL(org.tmatesoft.svn.core.SVNURL) Before(org.junit.Before)

Aggregations

SvnAuthenticationManager (org.jetbrains.idea.svn.auth.SvnAuthenticationManager)5 File (java.io.File)4 SVNURL (org.tmatesoft.svn.core.SVNURL)3 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)3 Before (org.junit.Before)2 SVNErrorMessage (org.tmatesoft.svn.core.SVNErrorMessage)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 SvnAuthenticationProvider (org.jetbrains.idea.svn.auth.SvnAuthenticationProvider)1 SvnInteractiveAuthenticationProvider (org.jetbrains.idea.svn.auth.SvnInteractiveAuthenticationProvider)1 ISVNAuthenticationProvider (org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider)1 SVNAuthentication (org.tmatesoft.svn.core.auth.SVNAuthentication)1