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

import java.util.List;

import org.apache.commons.collections.CollectionUtils;

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

public class KeyUsageCheck extends ChainItem<XmlXCV> {

	private final CertificateWrapper certificate;
	private final List<String> expectedKeyUsages;

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

	@Override
	protected boolean process() {
		if (CollectionUtils.isNotEmpty(expectedKeyUsages)) {
			return expectedKeyUsages.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;
	}

}

@@ -61,32 +61,8 @@
 s;%0A%0A
-import java.util.List;%0A%0A
 impo
@@ -633,38 +633,40 @@
 nal 
-List%3CS
+MultiValuesCons
 tr
+a
 in
-g%3E expectedKeyUsages
+t constraint
 ;%0A%0A%09
@@ -839,33 +839,26 @@
 %0A%09%09this.
-expectedKeyUsages
+constraint
  = const
@@ -866,16 +866,8 @@
 aint
-.getId()
 ;%0A%09%7D
@@ -947,57 +947,59 @@
 pty(
-expectedKeyUsages)) %7B%0A%09%09%09return expectedKeyUsages
+constraint.getId())) %7B%0A%09%09%09return constraint.getId()
 .con

Fix NPE