Search in sources :

Example 1 with SecurityInfoImpl

use of org.microemu.cldc.SecurityInfoImpl in project J2ME-Loader by nikita36078.

the class Connection method getSecurityInfo.

@Override
public SecurityInfo getSecurityInfo() throws IOException {
    if (securityInfo == null) {
        SSLSession session = ((SSLSocket) socket).getSession();
        Certificate[] certs = session.getPeerCertificates();
        if (certs.length == 0) {
            throw new IOException();
        }
        securityInfo = new SecurityInfoImpl(session.getCipherSuite(), session.getProtocol(), new CertificateImpl((X509Certificate) certs[0]));
    }
    return securityInfo;
}
Also used : SecurityInfoImpl(org.microemu.cldc.SecurityInfoImpl) SSLSocket(javax.net.ssl.SSLSocket) SSLSession(javax.net.ssl.SSLSession) IOException(java.io.IOException) CertificateImpl(org.microemu.cldc.CertificateImpl) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 2 with SecurityInfoImpl

use of org.microemu.cldc.SecurityInfoImpl in project J2ME-Loader by nikita36078.

the class Connection method getSecurityInfo.

@Override
public SecurityInfo getSecurityInfo() throws IOException {
    if (securityInfo == null) {
        if (cn == null) {
            throw new IOException();
        }
        if (!connected) {
            cn.connect();
            connected = true;
        }
        HttpsURLConnection https = (HttpsURLConnection) cn;
        Certificate[] certs = https.getServerCertificates();
        if (certs.length == 0) {
            throw new IOException();
        }
        securityInfo = new SecurityInfoImpl(https.getCipherSuite(), sslContext.getProtocol(), new CertificateImpl((X509Certificate) certs[0]));
    }
    return securityInfo;
}
Also used : SecurityInfoImpl(org.microemu.cldc.SecurityInfoImpl) IOException(java.io.IOException) CertificateImpl(org.microemu.cldc.CertificateImpl) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Aggregations

IOException (java.io.IOException)2 Certificate (java.security.cert.Certificate)2 X509Certificate (java.security.cert.X509Certificate)2 CertificateImpl (org.microemu.cldc.CertificateImpl)2 SecurityInfoImpl (org.microemu.cldc.SecurityInfoImpl)2 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)1 SSLSession (javax.net.ssl.SSLSession)1 SSLSocket (javax.net.ssl.SSLSocket)1