org.apache.cxf.transport.http.UntrustedURLConnectionIOException Java Examples

The following examples show how to use org.apache.cxf.transport.http.UntrustedURLConnectionIOException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HTTPSConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void establishTrust(
    String            conduitName,
    URLConnectionInfo cinfo,
    Message           message
) throws UntrustedURLConnectionIOException {

    called++;

    HttpsURLConnectionInfo ci = (HttpsURLConnectionInfo) cinfo;
    boolean trusted = false;
    for (int i = 0; i < trustName.length; i++) {
        trusted = trusted
                 || ci.getPeerPrincipal()
                         .toString().contains("OU=" + trustName[i]);
    }
    if (!trusted) {
        throw new UntrustedURLConnectionIOException(
                "Peer Principal \""
                + ci.getPeerPrincipal()
                + "\" does not contain "
                + getTrustNames());
    }
}
 
Example #2
Source File: HttpsMessageTrustDecider.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void establishTrust(String conduitName,
        URLConnectionInfo connectionInfo,
        Message message)
    throws UntrustedURLConnectionIOException {
    if (orig != null) {
        orig.establishTrust(conduitName, connectionInfo, message);
    }
    HttpsURLConnectionInfo info = (HttpsURLConnectionInfo)connectionInfo;

    if (info.getServerCertificates() == null
            || info.getServerCertificates().length == 0) {
        throw new UntrustedURLConnectionIOException(
            "No server certificates were found"
        );
    }
    X509Certificate[] certs = (X509Certificate[])info.getServerCertificates();
    if (!certConstraints.matches(certs[0])) {
        throw new UntrustedURLConnectionIOException(
            "The server certificate(s) do not match the defined cert constraints"
        );
    }
}