@SuppressWarnings("static-method") @Test @Ignore public void pruebaCofirmaXAdESEnveloped() throws Exception { final byte[] signature; try ( final InputStream is = ClassLoader.getSystemResourceAsStream("firma-xades-enveloped.xml"); ) { signature = AOUtil.getDataFromInputStream(is); } final KeyStore ks = KeyStore.getInstance("PKCS12"); ks.load(ClassLoader.getSystemResourceAsStream(CERT_PATH2), CERT_PASS2.toCharArray()); final PrivateKeyEntry pke = (PrivateKeyEntry) ks.getEntry(CERT_ALIAS2, new KeyStore.PasswordProtection(CERT_PASS2.toCharArray())); final AOXAdESTriPhaseSigner signer = new AOXAdESTriPhaseSigner(); final Properties config = new Properties(); config.put("format", "XAdES Enveloped"); config.setProperty("serverUrl", SERVER_URL); final byte[] result = signer.cosign( signature, AOSignConstants.SIGN_ALGORITHM_SHA1WITHRSA, pke.getPrivateKey(), pke.getCertificateChain(), config ); final File tempFile = File.createTempFile("xades-", ".xml"); try ( final OutputStream fos = new FileOutputStream(tempFile); ) { fos.write(result); } System.out.println("El resultado de la cofirma XAdES Enveloped se ha guardado en: " + tempFile.getAbsolutePath()); }
@Override public byte[] cosign(final byte[] data, final byte[] sign, final String algorithm, final PrivateKey key, final Certificate[] certChain, final Properties xParams) throws AOException { return triPhaseOperation( this.signFormat, CRYPTO_OPERATION_COSIGN, sign, algorithm, key, certChain, xParams ); }
AOXAdESTriPhaseSigner implements AOSigner { @Override public byte[] cosign(final byte[] data, final byte[] sign, final String algorithm, final PrivateKey key, final Certificate[] certChain, final Properties xParams) throws AOException { return triPhaseOperation( this.signFormat, CRYPTO_OPERATION_COSIGN, sign, algorithm, key, certChain, xParams ); } }
AOXAdESTriPhaseSigner implements AOSigner { @Override public byte[] cosign(final byte[] data, final byte[] sign, final String algorithm, final PrivateKey key, final Certificate[] certChain, final Properties xParams) throws AOException { return triPhaseOperation( this.signFormat, CRYPTO_OPERATION_COSIGN, sign, algorithm, key, certChain, xParams ); } protected  AOXAdESTriPhaseSigner(final String format);  AOXAdESTriPhaseSigner(); }
AOXAdESTriPhaseSigner implements AOSigner { @Override public byte[] cosign(final byte[] data, final byte[] sign, final String algorithm, final PrivateKey key, final Certificate[] certChain, final Properties xParams) throws AOException { return triPhaseOperation( this.signFormat, CRYPTO_OPERATION_COSIGN, sign, algorithm, key, certChain, xParams ); } protected  AOXAdESTriPhaseSigner(final String format);  AOXAdESTriPhaseSigner(); @Override byte[] sign(final byte[] data,
			           final String algorithm,
			           final PrivateKey key,
			           final Certificate[] certChain,
			           final Properties xParams); @Override final byte[] getData(final byte[] sign); @Override byte[] cosign(final byte[] data,
			             final byte[] sign,
			             final String algorithm,
			             final PrivateKey key,
			             final Certificate[] certChain,
			             final Properties xParams); @Override byte[] cosign(final byte[] sign,
			             final String algorithm,
			             final PrivateKey key,
			             final Certificate[] certChain,
			             final Properties xParams); @Override byte[] countersign(final byte[] sign,
			final String algorithm,
			final CounterSignTarget targetType,
			final Object[] targets,
			final PrivateKey key,
			final Certificate[] certChain,
			final Properties xParams); @Override final AOTreeModel getSignersStructure(final byte[] sign,
			                                     final boolean asSimpleSignInfo); @Override boolean isSign(final byte[] sign); @Override boolean isValidDataFile(final byte[] data); @Override String getSignedName(final String originalName, final String inText); @Override AOSignInfo getSignInfo(final byte[] sign); }
AOXAdESTriPhaseSigner implements AOSigner { @Override public byte[] cosign(final byte[] data, final byte[] sign, final String algorithm, final PrivateKey key, final Certificate[] certChain, final Properties xParams) throws AOException { return triPhaseOperation( this.signFormat, CRYPTO_OPERATION_COSIGN, sign, algorithm, key, certChain, xParams ); } protected  AOXAdESTriPhaseSigner(final String format);  AOXAdESTriPhaseSigner(); @Override byte[] sign(final byte[] data,
			           final String algorithm,
			           final PrivateKey key,
			           final Certificate[] certChain,
			           final Properties xParams); @Override final byte[] getData(final byte[] sign); @Override byte[] cosign(final byte[] data,
			             final byte[] sign,
			             final String algorithm,
			             final PrivateKey key,
			             final Certificate[] certChain,
			             final Properties xParams); @Override byte[] cosign(final byte[] sign,
			             final String algorithm,
			             final PrivateKey key,
			             final Certificate[] certChain,
			             final Properties xParams); @Override byte[] countersign(final byte[] sign,
			final String algorithm,
			final CounterSignTarget targetType,
			final Object[] targets,
			final PrivateKey key,
			final Certificate[] certChain,
			final Properties xParams); @Override final AOTreeModel getSignersStructure(final byte[] sign,
			                                     final boolean asSimpleSignInfo); @Override boolean isSign(final byte[] sign); @Override boolean isValidDataFile(final byte[] data); @Override String getSignedName(final String originalName, final String inText); @Override AOSignInfo getSignInfo(final byte[] sign); static final String DSIGNNS; static final String SIGNATURE_TAG; static final String COUNTERSIGN_TARGET_LEAFS; static final String COUNTERSIGN_TARGET_TREE; }