Advertisement
Guest User

NullX509TrustManager.java

a guest
Apr 13th, 2015
1,325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package com.example;
  2.  
  3. import java.security.cert.CertificateException;
  4. import java.security.cert.X509Certificate;
  5.  
  6. import javax.net.ssl.X509TrustManager;
  7.  
  8. /**
  9.  * Trust manager that does not perform any checks.
  10.  */
  11. public class NullX509TrustManager implements X509TrustManager {
  12.     /**
  13.      * Does nothing.
  14.      *
  15.      * @param chain
  16.      *            certificate chain
  17.      * @param authType
  18.      *            authentication type
  19.      */
  20.     @Override
  21.     public void checkClientTrusted(final X509Certificate[] chain,
  22.             final String authType) throws CertificateException {
  23.         // Does nothing
  24.     }
  25.  
  26.     /**
  27.      * Does nothing.
  28.      *
  29.      * @param chain
  30.      *            certificate chain
  31.      * @param authType
  32.      *            authentication type
  33.      */
  34.     @Override
  35.     public void checkServerTrusted(final X509Certificate[] chain,
  36.             final String authType) throws CertificateException {
  37.         // Does nothing
  38.     }
  39.  
  40.     /**
  41.      * Gets a list of accepted issuers.
  42.      *
  43.      * @return empty array
  44.      */
  45.     @Override
  46.     public X509Certificate[] getAcceptedIssuers() {
  47.         return new X509Certificate[0];
  48.         // Does nothing
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement