/****************************************************************************
 * Copyright (C) 2015 ecsec GmbH.
 * All rights reserved.
 * Contact: ecsec GmbH (info@ecsec.de)
 *
 * This file is part of SkIDentity.
 *
 * This file may be used in accordance with the terms and conditions
 * contained in a signed written agreement between you and ecsec GmbH.
 *
 ***************************************************************************/

package org.openecard.crypto.common.sal;

import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author René Lottes
 */
public enum ExtendedKeyUsage {
    SERVER_AUTH,
    CLIENT_AUTH,
    CODE_SIGNING,
    EMAIL_PROTECTION,
    OCSP_SIGNING;
    
    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ExtendedKeyUsage.class);

    public boolean hasUsage(X509Certificate x509cert) {
        try {
            List<String> extendedKeyUsage = x509cert.getExtendedKeyUsage();
        } catch (CertificateParsingException ex) {
            logger.error("Error parsing certificate", ex);
        }
        
        return false;
    }
}

@@ -606,64 +606,57 @@
 ort 
-java.util.logging.Level;%0Aimport java.util.logging.Logger
+org.openecard.bouncycastle.asn1.x509.KeyPurposeId
 ;%0Aim
@@ -686,16 +686,17 @@
 ctory;%0A%0A
+%0A
 /**%0A *%0A 
@@ -771,336 +771,856 @@
 AUTH
-,%0A    CLIENT_AUTH,%0A    CODE_SIGNING,%0A    EMAIL_PROTECTION,%0A    OCSP_SIGNING;%0A    %0A    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ExtendedKeyUsage.class);%0A%0A    public boolean hasUsage(X509Certificate x509cert) %7B%0A        try %7B%0A            List%3CString%3E extendedKeyUsage = x509cert.getExtendedKeyUsage();
+(KeyPurposeId.id_kp_serverAuth.getId()),%0A    CLIENT_AUTH(KeyPurposeId.id_kp_clientAuth.getId()),%0A    CODE_SIGNING(KeyPurposeId.id_kp_codeSigning.getId()),%0A    EMAIL_PROTECTION(KeyPurposeId.id_kp_emailProtection.getId()),%0A    OCSP_SIGNING(KeyPurposeId.id_kp_OCSPSigning.getId());%0A    %0A    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ExtendedKeyUsage.class);%0A%0A    private final String str;%0A%0A    private ExtendedKeyUsage(String str) %7B%0A        this.str = str;%0A    %7D%0A%0A    public String getValue() %7B%0A        return str;%0A    %7D%0A    %0A    public boolean hasUsage(X509Certificate x509cert) %7B%0A        try %7B%0A            List%3CString%3E extendedKeyUsage = x509cert.getExtendedKeyUsage();%0A            %0A            if (extendedKeyUsage != null) %7B%0A                return extendedKeyUsage.contains(this.getValue());%0A            %7D%0A            
 %0A   

implement ExtendedKeyUsage