/** {@inheritDoc} */ public SAML1ArtifactType0001 buildArtifact( SAMLMessageContext<RequestAbstractType, Response, NameIdentifier> requestContext, Assertion assertion) { try { MessageDigest sha1Digester = MessageDigest.getInstance("SHA-1"); byte[] source = sha1Digester.digest(requestContext.getLocalEntityId().getBytes()); SecureRandom handleGenerator = SecureRandom.getInstance("SHA1PRNG"); byte[] assertionHandle = new byte[20]; handleGenerator.nextBytes(assertionHandle); return new SAML1ArtifactType0001(source, assertionHandle); } catch (NoSuchAlgorithmException e) { log.error("JVM does not support required cryptography algorithms.", e); throw new InternalError("JVM does not support required cryptography algorithms: SHA-1 and/or SHA1PRNG."); } } }
/** {@inheritDoc} */ public SAML2ArtifactType0004 buildArtifact(SAMLMessageContext<SAMLObject, SAMLObject, NameID> requestContext) { try { IndexedEndpoint acsEndpoint = (IndexedEndpoint) getAcsEndpoint(requestContext); if (acsEndpoint == null) { return null; } byte[] endpointIndex = DatatypeHelper.intToByteArray(acsEndpoint.getIndex()); byte[] trimmedIndex = new byte[2]; trimmedIndex[0] = endpointIndex[2]; trimmedIndex[1] = endpointIndex[3]; MessageDigest sha1Digester = MessageDigest.getInstance("SHA-1"); byte[] source = sha1Digester.digest(requestContext.getLocalEntityId().getBytes()); SecureRandom handleGenerator = SecureRandom.getInstance("SHA1PRNG"); byte[] assertionHandle; assertionHandle = new byte[20]; handleGenerator.nextBytes(assertionHandle); return new SAML2ArtifactType0004(trimmedIndex, source, assertionHandle); } catch (NoSuchAlgorithmException e) { log.error("JVM does not support required cryptography algorithms: SHA-1/SHA1PRNG.", e); throw new InternalError("JVM does not support required cryptography algorithms: SHA-1/SHA1PRNG."); } }