@Override public Output append(String str) { try { if (str == null) { str = "null"; } os.write(StringUtils.toBytesUTF8(str)); } catch (IOException ex) { throw new RuntimeException(ex); } return this; } @Override
public byte[] getDecodedJwsPayloadBytes() { return StringUtils.toBytesUTF8(getDecodedJwsPayload()); } public String getEncodedProtectedHeader() {
protected void writeJws(JwsJsonProducer p, OutputStream os) throws IOException { byte[] bytes = StringUtils.toBytesUTF8(p.getJwsJsonSignedDocument()); IOUtils.copy(new ByteArrayInputStream(bytes), os); }
public boolean validateClientSecret(Client client, String clientSecret) { String hash = MessageDigestUtils.generate(StringUtils.toBytesUTF8(clientSecret), hashAlgorithm); return hash.equals(client.getClientSecret()); } public void setHashAlgorithm(String hashAlgorithm) {
protected void writeJws(JwsJsonProducer p, OutputStream os) throws IOException { byte[] bytes = StringUtils.toBytesUTF8(p.getJwsJsonSignedDocument()); IOUtils.copy(new ByteArrayInputStream(bytes), os); }
public static String encryptJwkSet(JsonWebKeys jwkSet, SecretKey key, KeyAlgorithm keyAlgo, ContentAlgorithm contentAlgo) { return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkSetToJson(jwkSet)), "jwk-set+json"); } public static JsonWebKeys decryptJwkSet(String jsonJwkSet, char[] password) {
public static String encryptJwkKey(JsonWebKey jwkKey, SecretKey key, KeyAlgorithm keyAlgo, ContentAlgorithm contentAlgo) { return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkKeyToJson(jwkKey)), "jwk+json"); } public static String signJwkKey(JsonWebKey jwkKey, PrivateKey key, SignatureAlgorithm algo) {
public static String encryptJwkSet(JsonWebKeys jwkSet, PublicKey key, KeyAlgorithm keyAlgo, ContentAlgorithm contentAlgo) { return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkSetToJson(jwkSet)), "jwk-set+json"); } public static String signJwkSet(JsonWebKeys jwkSet, PrivateKey key, SignatureAlgorithm algo) {
public static String encryptJwkKey(JsonWebKey jwkKey, PublicKey key, KeyAlgorithm keyAlgo, ContentAlgorithm contentAlgo) { return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkKeyToJson(jwkKey)), "jwk+json"); } public static String encryptJwkKey(JsonWebKey jwkKey, SecretKey key, KeyAlgorithm keyAlgo,
public static byte[] toCipherAdditionalAuthData(String headersJson) { byte[] headerBytes = StringUtils.toBytesUTF8(headersJson); String base64UrlHeadersInJson = Base64UrlUtility.encode(headerBytes); return StringUtils.toBytesASCII(base64UrlHeadersInJson); }
public static JweEncryptionProvider getClientSecretEncryptionProvider(String clientSecret) { Properties props = JweUtils.loadEncryptionInProperties(false); byte[] key = StringUtils.toBytesUTF8(clientSecret); return JweUtils.getDirectKeyJweEncryption(key, getClientSecretContentAlgorithm(props)); }
public static JweDecryptionProvider getClientSecretDecryptionProvider(String clientSecret) { Properties props = JweUtils.loadEncryptionInProperties(false); byte[] key = StringUtils.toBytesUTF8(clientSecret); return JweUtils.getDirectKeyJweDecryption(key, getClientSecretContentAlgorithm(props)); }
public static JweDecryptionProvider getClientSecretDecryptionProvider(String clientSecret) { Properties props = JweUtils.loadEncryptionInProperties(false); byte[] key = StringUtils.toBytesUTF8(clientSecret); return JweUtils.getDirectKeyJweDecryption(key, getClientSecretContentAlgorithm(props)); }
protected void writeJws(JwsCompactProducer p, JwsSignatureProvider theSigProvider, OutputStream os) throws IOException { p.signWith(theSigProvider); JoseUtils.traceHeaders(p.getJwsHeaders()); byte[] bytes = StringUtils.toBytesUTF8(p.getSignedEncodedJws()); IOUtils.copy(new ByteArrayInputStream(bytes), os); }
private MultivaluedMap<String, String> toFormData(ContainerRequestContext rc) { MultivaluedMap<String, String> requestState = new MetadataMap<>(); if (MediaType.APPLICATION_FORM_URLENCODED_TYPE.isCompatible(rc.getMediaType())) { String body = FormUtils.readBody(rc.getEntityStream(), StandardCharsets.UTF_8.name()); FormUtils.populateMapFromString(requestState, JAXRSUtils.getCurrentMessage(), body, StandardCharsets.UTF_8.name(), false); rc.setEntityStream(new ByteArrayInputStream(StringUtils.toBytesUTF8(body))); } return requestState; } public void setIdTokenReader(IdTokenReader idTokenReader) {
private MultivaluedMap<String, String> toFormData(ContainerRequestContext rc) { MultivaluedMap<String, String> requestState = new MetadataMap<>(); if (MediaType.APPLICATION_FORM_URLENCODED_TYPE.isCompatible(rc.getMediaType())) { String body = FormUtils.readBody(rc.getEntityStream(), StandardCharsets.UTF_8.name()); FormUtils.populateMapFromString(requestState, JAXRSUtils.getCurrentMessage(), body, StandardCharsets.UTF_8.name(), false); rc.setEntityStream(new ByteArrayInputStream(StringUtils.toBytesUTF8(body))); } return requestState; } public void setIdTokenReader(IdTokenReader idTokenReader) {
public static String encryptJwkKey(JsonWebKey jwkKey, JweEncryptionProvider jwe) { return jwe.encrypt(StringUtils.toBytesUTF8(new JwkReaderWriter().jwkToJson(jwkKey)), toJweHeaders("jwk+json")); } public static String encryptJwkKey(JsonWebKey jwkKey, PublicKey key, KeyAlgorithm keyAlgo,
public static String encryptJwkSet(JsonWebKeys jwkSet, JweEncryptionProvider jwe) { return jwe.encrypt(StringUtils.toBytesUTF8(new JwkReaderWriter().jwkSetToJson(jwkSet)), toJweHeaders("jwk-set+json")); } public static String encryptJwkSet(JsonWebKeys jwkSet, PublicKey key, KeyAlgorithm keyAlgo,
private MultivaluedMap<String, String> toRequestState(ContainerRequestContext rc) { MultivaluedMap<String, String> requestState = new MetadataMap<>(); requestState.putAll(rc.getUriInfo().getQueryParameters(true)); if (MediaType.APPLICATION_FORM_URLENCODED_TYPE.isCompatible(rc.getMediaType())) { String body = FormUtils.readBody(rc.getEntityStream(), StandardCharsets.UTF_8.name()); FormUtils.populateMapFromString(requestState, JAXRSUtils.getCurrentMessage(), body, StandardCharsets.UTF_8.name(), true); rc.setEntityStream(new ByteArrayInputStream(StringUtils.toBytesUTF8(body))); } return requestState; } public void setRedirectUri(String redirectUri) {
public String signWith(JwsSignatureProvider signer) { if (headers.getSignatureAlgorithm() == null) { headers.setSignatureAlgorithm(signer.getAlgorithm()); } byte[] bytes = StringUtils.toBytesUTF8(getSigningInput()); byte[] sig = signer.sign(getJwsHeaders(), bytes); return setSignatureBytes(sig); }