0

I am not really sure how to translate this to groovy syntax.

Have checked this differences with java page already.

Thanks!

    TrustManager[] trustAllCerts = new TrustManager[] {
       new X509TrustManager() {
          public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return null;
          }

          public void checkClientTrusted(X509Certificate[] certs, String authType) {  }

          public void checkServerTrusted(X509Certificate[] certs, String authType) {  }

       }
    };

enter image description here

1
  • added screenshot to clarify Commented Jun 11, 2015 at 10:09

2 Answers 2

3

The following should work:

import java.security.cert.*
import javax.net.ssl.*

TrustManager[] trustAllCerts = [
    [ getAcceptedIssuers: { -> null },
      checkClientTrusted: { X509Certificate[] certs, String authType -> },
      checkServerTrusted: { X509Certificate[] certs, String authType -> } ] as X509TrustManager
]
Sign up to request clarification or add additional context in comments.

1 Comment

The code sample in the question has classic Groovy-style syntax, but this one in the answer looks cryptic.
0

in groovy {} is always a block/closure. You would have to use [ new X509TrustManager() { ... } ]. If there are problems casting this dash an ... as TrustManager[] at the end.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.