use of xades4j.providers.impl.DefaultX500NameStyleProvider in project xades4j by luisgoncalves.
the class KeyInfoBuilderTest method testIncludeCertAndKey.
@Test
public void testIncludeCertAndKey() throws Exception {
System.out.println("includeCertAndKey");
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(new BasicSignatureOptions().includeSigningCertificate(SigningCertificateMode.SIGNING_CERTIFICATE).includePublicKey(true), new SignatureAlgorithms(), new TestAlgorithmsParametersMarshallingProvider(), new DefaultX500NameStyleProvider());
XMLSignature xmlSignature = getTestSignature();
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
Assert.assertEquals(0, xmlSignature.getSignedInfo().getLength());
KeyValue kv = xmlSignature.getKeyInfo().itemKeyValue(0);
Assert.assertTrue(kv.getPublicKey().getAlgorithm().startsWith("RSA"));
XMLX509Certificate x509Certificate = xmlSignature.getKeyInfo().itemX509Data(0).itemCertificate(0);
Assert.assertEquals(testCertificate, x509Certificate.getX509Certificate());
}
use of xades4j.providers.impl.DefaultX500NameStyleProvider in project xades4j by luisgoncalves.
the class KeyInfoBuilderTest method testIncludeCertChain.
@Test
public void testIncludeCertChain() throws Exception {
System.out.println("includeCertChain");
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(new BasicSignatureOptions().includeSigningCertificate(SigningCertificateMode.FULL_CHAIN), new SignatureAlgorithms(), new TestAlgorithmsParametersMarshallingProvider(), new DefaultX500NameStyleProvider());
XMLSignature xmlSignature = getTestSignature();
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
Assert.assertEquals(0, xmlSignature.getSignedInfo().getLength());
Assert.assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
Assert.assertEquals(2, xmlSignature.getKeyInfo().itemX509Data(0).lengthCertificate());
XMLX509Certificate x509Certificate = xmlSignature.getKeyInfo().itemX509Data(0).itemCertificate(0);
Assert.assertEquals(testCertificate, x509Certificate.getX509Certificate());
x509Certificate = xmlSignature.getKeyInfo().itemX509Data(0).itemCertificate(1);
Assert.assertEquals(intermCertificate, x509Certificate.getX509Certificate());
}
use of xades4j.providers.impl.DefaultX500NameStyleProvider in project xades4j by luisgoncalves.
the class KeyInfoBuilderTest method testSignKeyInfo.
@Test
public void testSignKeyInfo() throws Exception {
System.out.println("signKeyInfo");
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(new BasicSignatureOptions().signKeyInfo(true), new SignatureAlgorithms(), new TestAlgorithmsParametersMarshallingProvider(), new DefaultX500NameStyleProvider());
XMLSignature xmlSignature = getTestSignature();
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
SignedInfo signedInfo = xmlSignature.getSignedInfo();
Assert.assertEquals(1, signedInfo.getLength());
Node refNode = signedInfo.item(0).getContentsBeforeTransformation().getSubNode();
Assert.assertSame(xmlSignature.getKeyInfo().getElement(), refNode);
}
use of xades4j.providers.impl.DefaultX500NameStyleProvider in project xades4j by luisgoncalves.
the class X500NameStyleProviderTest method normalWithExtendKeywords.
@Test
public void normalWithExtendKeywords() {
X500NameStyleProvider x500NameStyleProvider = new DefaultX500NameStyleProvider();
X500Principal name1 = x500NameStyleProvider.fromString(NAME_CANONICAL);
X500Principal name2 = x500NameStyleProvider.fromString(NAME_SIMPLE_NORMAL);
RFC4519ExtensibleStyle es = new RFC4519ExtensibleStyle();
es.addSymbol("1.2.840.113549.1.9.1", "E");
X500NameStyleProvider x500NameStyleProviderExtend = new DefaultX500NameStyleProvider(es);
X500Principal name3 = x500NameStyleProviderExtend.fromString(NAME_SIMPLE);
Assert.assertEquals(name1, name2);
Assert.assertEquals(name1, name3);
}
use of xades4j.providers.impl.DefaultX500NameStyleProvider in project xades4j by luisgoncalves.
the class KeyInfoBuilderTest method testIncludeIssuerSerial.
@Test
public void testIncludeIssuerSerial() throws Exception {
System.out.println("includeIssuerSerial");
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(new BasicSignatureOptions().includeIssuerSerial(true), new SignatureAlgorithms(), new TestAlgorithmsParametersMarshallingProvider(), new DefaultX500NameStyleProvider());
XMLSignature xmlSignature = getTestSignature();
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
Assert.assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
Assert.assertEquals(1, xmlSignature.getKeyInfo().itemX509Data(0).lengthIssuerSerial());
}
Aggregations