/** * Signs the provided bytes using the private key associated with the service account. * * <p>The Compute Engine's project must enable the Identity and Access Management (IAM) API and * the instance's service account must have the iam.serviceAccounts.signBlob permission.</p> * * @param toSign bytes to sign * @return signed bytes * @throws SigningException if the attempt to sign the provided bytes failed * @see <a href="https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob">Blob Signing</a> */ @Override public byte[] sign(byte[] toSign) { BaseEncoding base64 = BaseEncoding.base64(); String signature; try { signature = getSignature(base64.encode(toSign)); } catch (IOException ex) { throw new SigningException("Failed to sign the provided bytes", ex); } return base64.decode(signature); }
/** * Signs the provided bytes using the private key associated with the service account. * * <p>The Compute Engine's project must enable the Identity and Access Management (IAM) API and * the instance's service account must have the iam.serviceAccounts.signBlob permission.</p> * * @param toSign bytes to sign * @return signed bytes * @throws SigningException if the attempt to sign the provided bytes failed * @see <a href="https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob">Blob Signing</a> */ @Override public byte[] sign(byte[] toSign) { BaseEncoding base64 = BaseEncoding.base64(); String signature; try { signature = getSignature(base64.encode(toSign)); } catch (IOException ex) { throw new SigningException("Failed to sign the provided bytes", ex); } return base64.decode(signature); }