Example usage for java.security.cert CertPath getCertificates

List of usage examples for java.security.cert CertPath getCertificates

Introduction

In this page you can find the example usage for java.security.cert CertPath getCertificates.

Prototype

public abstract List<? extends Certificate> getCertificates();

Source Link

Document

Returns the list of certificates in this certification path.

Usage

From source file:org.wso2.carbon.security.util.ServerCrypto.java

@Override
/**/*w  w w .j  a v  a 2s  . c o  m*/
 * @see org.apache.ws.security.components.crypto.Crypto#getX509Certificates(byte[], boolean)
 */
public X509Certificate[] getX509Certificates(byte[] data, boolean reverse) throws WSSecurityException {
    InputStream in = new ByteArrayInputStream(data);
    CertPath path;
    try {
        path = getCertificateFactory().generateCertPath(in);
    } catch (CertificateException e) {
        throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, "parseError");
    }
    List l = path.getCertificates();
    X509Certificate[] certs = new X509Certificate[l.size()];
    Iterator iterator = l.iterator();
    for (int i = 0; i < l.size(); i++) {
        certs[reverse ? (l.size() - 1 - i) : i] = (X509Certificate) iterator.next();
    }
    return certs;
}

From source file:org.wso2.carbon.webapp.ext.cxf.crypto.CXFServerCrypto.java

/**
 * @see org.apache.ws.security.components.crypto.Crypto#getX509Certificates(byte[], boolean)
 *//*  w  w w .  j  a  v  a2 s .  c o  m*/
public X509Certificate[] getX509Certificates(byte[] data, boolean reverse) throws WSSecurityException {
    InputStream in = new ByteArrayInputStream(data);
    CertPath path;
    try {
        path = getCertificateFactory().generateCertPath(in);
    } catch (CertificateException e) {
        throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, "parseError");
    }
    List l = path.getCertificates();
    X509Certificate[] certs = new X509Certificate[l.size()];
    Iterator iterator = l.iterator();
    for (int i = 0; i < l.size(); i++) {
        certs[(reverse) ? (l.size() - 1 - i) : i] = (X509Certificate) iterator.next();
    }
    return certs;
}