Search in sources :

Example 1 with SVNErrorMessage

use of org.tmatesoft.svn.core.SVNErrorMessage in project intellij-community by JetBrains.

the class SvnUtil method parseWarning.

@Nullable
public static SVNErrorMessage parseWarning(@NotNull String text) {
    Matcher matcher = WARNING_PATTERN.matcher(text);
    SVNErrorMessage error = null;
    // currently treating only first warning
    if (matcher.find()) {
        error = SVNErrorMessage.create(SVNErrorCode.getErrorCode(Integer.parseInt(matcher.group(2))), matcher.group(3), SVNErrorMessage.TYPE_WARNING);
    }
    return error;
}
Also used : Matcher(java.util.regex.Matcher) SVNErrorMessage(org.tmatesoft.svn.core.SVNErrorMessage) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with SVNErrorMessage

use of org.tmatesoft.svn.core.SVNErrorMessage 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 3 with SVNErrorMessage

use of org.tmatesoft.svn.core.SVNErrorMessage 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)

Aggregations

SVNErrorMessage (org.tmatesoft.svn.core.SVNErrorMessage)3 File (java.io.File)2 SvnAuthenticationManager (org.jetbrains.idea.svn.auth.SvnAuthenticationManager)2 SVNURL (org.tmatesoft.svn.core.SVNURL)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Matcher (java.util.regex.Matcher)1 Nullable (org.jetbrains.annotations.Nullable)1 Before (org.junit.Before)1 ISVNAuthenticationProvider (org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider)1 SVNAuthentication (org.tmatesoft.svn.core.auth.SVNAuthentication)1 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)1