TypeByCertificatePostEIDAS implements TypeStrategy { @Override public Type getType() { boolean esign = QCTypeIdentifiers.isQCTypeEsign(signingCertificate); boolean eseal = QCTypeIdentifiers.isQCTypeEseal(signingCertificate); boolean web = QCTypeIdentifiers.isQCTypeWeb(signingCertificate); boolean noneType = !(esign || eseal || web); boolean onlyOne = esign ^ eseal ^ web; if (noneType || (esign && onlyOne)) { return Type.ESIGN; } else if (eseal && onlyOne) { return Type.ESEAL; } else if (web && onlyOne) { return Type.WSA; } else { return Type.UNKNOWN; } } TypeByCertificatePostEIDAS(CertificateWrapper signingCertificate); @Override Type getType();  }
@Test public void esig() { CertificateWrapper cert = getCertificate(QCStatement.QCT_ESIGN); TypeByCertificatePostEIDAS strategy = new TypeByCertificatePostEIDAS(cert); assertEquals(Type.ESIGN, strategy.getType()); }
@Test public void esigDefault() { CertificateWrapper cert = getCertificate(); TypeByCertificatePostEIDAS strategy = new TypeByCertificatePostEIDAS(cert); assertEquals(Type.ESIGN, strategy.getType()); }
@Test public void eseal() { CertificateWrapper cert = getCertificate(QCStatement.QCT_ESEAL); TypeByCertificatePostEIDAS strategy = new TypeByCertificatePostEIDAS(cert); assertEquals(Type.ESEAL, strategy.getType()); }
@Test public void wsa() { CertificateWrapper cert = getCertificate(QCStatement.QCT_WEB); TypeByCertificatePostEIDAS strategy = new TypeByCertificatePostEIDAS(cert); assertEquals(Type.WSA, strategy.getType()); }
@Test public void multiple() { CertificateWrapper cert = getCertificate(QCStatement.QCT_ESIGN, QCStatement.QCT_ESEAL); TypeByCertificatePostEIDAS strategy = new TypeByCertificatePostEIDAS(cert); assertEquals(Type.UNKNOWN, strategy.getType()); }