List of usage examples for org.bouncycastle.asn1.x509 GeneralName getEncoded
public byte[] getEncoded() throws IOException
From source file:org.signserver.module.tsa.TimeStampSignerTest.java
License:Open Source License
/** * Test using the TSA_FROM_CERT property to set the TSA name from * the signing cert.//w w w .j av a 2 s . com * * @throws Exception */ @Test public void test34TSANameFromCert() throws Exception { workerSession.setWorkerProperty(WORKER1, TimeStampSigner.TSA_FROM_CERT, "true"); workerSession.reloadConfiguration(WORKER1); final TimeStampResponse response = assertSuccessfulTimestamp(WORKER1, true); final GeneralName name = response.getTimeStampToken().getTimeStampInfo().getTsa(); final GeneralName expectedName = new GeneralName( new X500Name("CN=TS Signer 1,OU=Testing,O=SignServer,C=SE")); assertEquals("TSA included", expectedName, name); final GeneralName certName = new GeneralName( new JcaX509CertificateHolder((X509Certificate) workerSession.getSignerCertificate(WORKER1)) .getSubject()); assertTrue("TSA name content equals cert", Arrays.equals(certName.getEncoded(), name.getEncoded())); // restore workerSession.removeWorkerProperty(WORKER1, TimeStampSigner.TSA_FROM_CERT); workerSession.reloadConfiguration(WORKER1); }