package eu.europa.esig.dss.validation.process.bbb.xcv.checks;

import org.apache.commons.collections.CollectionUtils;

import eu.europa.esig.dss.jaxb.detailedreport.XmlXCV;
import eu.europa.esig.dss.validation.MessageTag;
import eu.europa.esig.dss.validation.policy.rules.Indication;
import eu.europa.esig.dss.validation.policy.rules.SubIndication;
import eu.europa.esig.dss.validation.process.ChainItem;
import eu.europa.esig.dss.validation.wrappers.CertificateWrapper;
import eu.europa.esig.jaxb.policy.MultiValuesConstraint;

public class KeyUsageCheck extends ChainItem<XmlXCV> {

	private final CertificateWrapper certificate;
	private final MultiValuesConstraint constraint;

	public KeyUsageCheck(XmlXCV result, CertificateWrapper certificate, MultiValuesConstraint constraint) {
		super(result, constraint);
		this.certificate = certificate;
		this.constraint = constraint;
	}

	@Override
	protected boolean process() {
		if (CollectionUtils.isNotEmpty(constraint.getId())) {
			return constraint.getId().containsAll(certificate.getKeyUsages());
		}
		return true;
	}

	@Override
	protected MessageTag getMessageTag() {
		return MessageTag.BBB_XCV_ISCGKU;
	}

	@Override
	protected MessageTag getErrorMessageTag() {
		return MessageTag.BBB_XCV_ISCGKU_ANS;
	}

	@Override
	protected Indication getFailedIndicationForConclusion() {
		return Indication.INVALID;
	}

	@Override
	protected SubIndication getFailedSubIndicationForConclusion() {
		return SubIndication.SIG_CONSTRAINTS_FAILURE;
	}

}

@@ -67,54 +67,22 @@
 ort 
-org.apache.commons.collections.CollectionUtils
+java.util.List
 ;%0A%0Ai
@@ -355,21 +355,44 @@
 process.
-Chain
+bbb.AbstractMultiValuesCheck
 Item;%0Aim
@@ -552,13 +552,32 @@
 nds 
-Chain
+AbstractMultiValuesCheck
 Item
@@ -937,103 +937,88 @@
 %7B%0A%09%09
-if (CollectionUtils.isNotEmpty(constraint.getId())) %7B%0A%09%09%09return cons
+List%3CString%3E expectedKeyUsages = constraint.getId();%0A%09%09List%3CS
 tr
-a
 in
-t.getId().containsAll(
+g%3E keyUsages = 
 cert
@@ -1043,14 +1043,9 @@
 es()
-);%0A%09%09%7D
+;
 %0A%09%09r
@@ -1054,12 +1054,56 @@
 urn 
-true
+processValuesCheck(keyUsages, expectedKeyUsages)
 ;%0A%09%7D

Fix KU Check