1package org.apache.harmony.xnet.tests.support;
2
3import javax.net.ssl.X509TrustManager;
4import java.security.cert.X509Certificate;
5import java.security.cert.CertificateException;
6
7public class X509TrustManagerImpl implements X509TrustManager {
8
9    public void checkClientTrusted(X509Certificate[] ax509certificate, String s)
10                                   throws CertificateException {
11
12        if(ax509certificate == null || ax509certificate.length == 0)
13            throw new IllegalArgumentException("null or zero-length certificate chain");
14        if(s == null || s.length() == 0)
15            throw new IllegalArgumentException("null or zero-length authentication type");
16
17        for (int i = 0; i < ax509certificate.length; i++) {
18            if (ax509certificate[i].getVersion() != 3) {
19                throw new CertificateException();
20            }
21        }
22    }
23
24    public void checkServerTrusted(X509Certificate[] ax509certificate, String s)
25                                   throws CertificateException {
26
27        if(ax509certificate == null || ax509certificate.length == 0)
28            throw new IllegalArgumentException("null or zero-length certificate chain");
29        if(s == null || s.length() == 0)
30            throw new IllegalArgumentException("null or zero-length authentication type");
31
32        for (int i = 0; i < ax509certificate.length; i++) {
33            if (ax509certificate[i].getVersion() != 3) {
34                throw new CertificateException();
35            }
36        }
37    }
38
39    public X509Certificate[] getAcceptedIssuers() {
40        X509Certificate[] cert = new X509Certificate[0];
41        return cert;
42    }
43}
44