Search in sources :

Example 1 with SSLProtocolExceptionParser

use of org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser in project intellij-community by JetBrains.

the class SSLExceptionParserTest method testRealLifeCase.

@Test
public void testRealLifeCase() throws Exception {
    final String original = "handshake alert:  unrecognized_name";
    final SSLProtocolException exception = new SSLProtocolException(original);
    final SSLProtocolExceptionParser parser = new SSLProtocolExceptionParser(exception.getMessage());
    parser.parse();
    final String message = parser.getParsedMessage();
    System.out.println(message);
    Assert.assertNotSame(original, message);
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException) SSLProtocolExceptionParser(org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser) Test(org.junit.Test)

Example 2 with SSLProtocolExceptionParser

use of org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser in project intellij-community by JetBrains.

the class SvnKitDebugLogger method handleSpecificSSLExceptions.

private void handleSpecificSSLExceptions(Throwable th) {
    final long time = System.currentTimeMillis();
    if ((time - myPreviousTime) <= ourErrorNotificationInterval) {
        return;
    }
    if (th instanceof SSLHandshakeException) {
        // not trusted certificate exception is not the problem, just part of normal behaviour
        if (th.getCause() instanceof SVNSSLUtil.CertificateNotTrustedException) {
            myLog.info(th);
            return;
        }
        myPreviousTime = time;
        String info = SSLExceptionsHelper.getAddInfo();
        info = info == null ? "" : " (" + info + ") ";
        if (th.getCause() instanceof CertificateException) {
            PopupUtil.showBalloonForActiveFrame("Subversion: " + info + th.getCause().getMessage(), MessageType.ERROR);
        } else {
            final String postMessage = "\nPlease check Subversion SSL settings (Settings | Version Control | Subversion | Network)\n" + "Maybe you should specify SSL protocol manually - SSLv3 or TLSv1";
            PopupUtil.showBalloonForActiveFrame("Subversion: " + info + th.getMessage() + postMessage, MessageType.ERROR);
        }
    } else if (th instanceof SSLProtocolException) {
        final String message = th.getMessage();
        if (!StringUtil.isEmptyOrSpaces(message)) {
            myPreviousTime = time;
            String info = SSLExceptionsHelper.getAddInfo();
            info = info == null ? "" : " (" + info + ") ";
            final SSLProtocolExceptionParser parser = new SSLProtocolExceptionParser(message);
            parser.parse();
            final String errMessage = "Subversion: " + info + parser.getParsedMessage();
            PopupUtil.showBalloonForActiveFrame(errMessage, MessageType.ERROR);
        }
    }
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException) SSLProtocolExceptionParser(org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser) CertificateException(java.security.cert.CertificateException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException)

Aggregations

SSLProtocolException (javax.net.ssl.SSLProtocolException)2 SSLProtocolExceptionParser (org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser)2 CertificateException (java.security.cert.CertificateException)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1 Test (org.junit.Test)1