Example usage for java.security.cert X509CertSelector setKeyUsage

List of usage examples for java.security.cert X509CertSelector setKeyUsage

Introduction

In this page you can find the example usage for java.security.cert X509CertSelector setKeyUsage.

Prototype

public void setKeyUsage(boolean[] keyUsage) 

Source Link

Document

Sets the keyUsage criterion.

Usage

From source file:mitm.application.djigzo.ws.impl.CACertStoreViewWSImpl.java

private CloseableIterator<? extends X509CertStoreEntry> getIterator(CACertStoreViewFilter filter)
        throws CertStoreException {
    X509CertSelector selector = new X509CertSelector();

    /*/* w ww  .  ja  v a2  s.co m*/
     * Make sure we only get CA certificates
     */
    selector.setBasicConstraints(0);

    Set<KeyUsageType> keyUsage = new HashSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.KEYCERTSIGN);

    if (filter == CACertStoreViewFilter.CRL_SIGN) {
        keyUsage.add(KeyUsageType.CRLSIGN);
    }

    selector.setKeyUsage(KeyUsageType.getKeyUsageArray(keyUsage));

    return certStore.getCertStoreIterator(selector, MissingKeyAlias.NOT_ALLOWED, null, null);
}