/** {@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."); } }
byte[] artifactTypeBytes = DatatypeHelper.intToByteArray(Integer.parseInt(artifactType)); byte[] trimmedArtifactTypeBytes = { artifactTypeBytes[2], artifactTypeBytes[3] }; builder.addPropertyValue("outboundArtifactType", trimmedArtifactTypeBytes);