public static boolean isOfflineTokenRequested(String scopeParam) { return hasScope(scopeParam, OAuth2Constants.OFFLINE_ACCESS); }
public static <T> T readValue(InputStream bytes, Class<T> type) throws IOException { return readValue(bytes, type, false); }
@Override public String toString() { try { return JsonSerialization.writeValueAsPrettyString(this); } catch (IOException e) { return super.toString() + " - Error: " + e.toString(); } } }
private void outputResult(Object result) throws IOException { if (outputClient) { if (compressed) { printOut(JsonSerialization.writeValueAsString(result)); } else { printOut(JsonSerialization.writeValueAsPrettyString(result)); } } }
public static JsonNode convertToJsonNode(Object object) throws IOException { if (object instanceof JsonNode) { return (JsonNode) object; } ByteArrayOutputStream buffer = new ByteArrayOutputStream(); buffer.write(JsonSerialization.writeValueAsBytes(object)); return MAPPER.readValue(buffer.toByteArray(), JsonNode.class); }
public static AdapterConfig loadAdapterConfig(InputStream is) { ObjectMapper mapper = new ObjectMapper(new SystemPropertiesJsonParserFactory()); mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); AdapterConfig adapterConfig; try { adapterConfig = mapper.readValue(is, AdapterConfig.class); } catch (IOException e) { throw new RuntimeException(e); } return adapterConfig; }
@Override protected JsonParser _createParser(char[] data, int offset, int len, IOContext ctxt, boolean recyclable) throws IOException { JsonParser delegate = super._createParser(data, offset, len, ctxt, recyclable); return new SystemPropertiesAwareJsonParser(delegate); }
/** * Return true if given refreshToken represents offline token * * @param refreshToken * @return */ public static boolean isOfflineToken(String refreshToken) throws JWSInputException { RefreshToken token = getRefreshToken(refreshToken); return token.getType().equals(TOKEN_TYPE_OFFLINE); }
public <T> T readJsonContent(Class<T> type) throws JWSInputException { try { return JsonSerialization.readValue(content, type); } catch (IOException e) { throw new JWSInputException(e); } }
private void outputResult(String clientId, Object result) throws IOException { if (returnClientId) { printOut(clientId); } else if (outputClient) { if (compressed) { printOut(JsonSerialization.writeValueAsString(result)); } else { printOut(JsonSerialization.writeValueAsPrettyString(result)); } } else { printErr("Registered new client with client_id '" + clientId + "'"); } }
public String getBase64Header() throws IOException { if (base64Header == null && header != null) { byte[] contentBytes = JsonSerialization.writeValueAsBytes(header); base64Header = Base64Url.encode(contentBytes); } return base64Header; }
@Override public String toString() { try { return JsonSerialization.writeValueAsPrettyString(this); } catch (IOException e) { return super.toString() + " - Error: " + e.toString(); } }
@Override protected JsonParser _createParser(InputStream in, IOContext ctxt) throws IOException { JsonParser delegate = super._createParser(in, ctxt); return new SystemPropertiesAwareJsonParser(delegate); }
public static boolean isOIDCRequest(String scopeParam) { return hasScope(scopeParam, OAuth2Constants.SCOPE_OPENID); }
public static RefreshToken getRefreshToken(String refreshToken) throws JWSInputException { byte[] encodedContent = new JWSInput(refreshToken).getContent(); return getRefreshToken(encodedContent); }
/** * Return refresh token or offline token * * @param decodedToken * @return */ public static RefreshToken getRefreshToken(byte[] decodedToken) throws JWSInputException { try { return JsonSerialization.readValue(decodedToken, RefreshToken.class); } catch (IOException e) { throw new JWSInputException(e); } }
@Override protected JsonParser _createParser(Reader r, IOContext ctxt) throws IOException { JsonParser delegate = super._createParser(r, ctxt); return new SystemPropertiesAwareJsonParser(delegate); }
public static String attachOIDCScope(String scopeParam) { if (scopeParam == null || scopeParam.isEmpty()) { return OAuth2Constants.SCOPE_OPENID; } else if (hasScope(scopeParam, OAuth2Constants.SCOPE_OPENID)) { return scopeParam; } else { return OAuth2Constants.SCOPE_OPENID + " " + scopeParam; } }
JWEHeader getHeader() { if (header == null && base64Header != null) { try { byte[] decodedHeader = Base64Url.decode(base64Header); header = JsonSerialization.readValue(decodedHeader, JWEHeader.class); } catch (IOException ioe) { throw new RuntimeException(ioe); } } return header; }
@Override protected JsonParser _createParser(byte[] data, int offset, int len, IOContext ctxt) throws IOException { JsonParser delegate = super._createParser(data, offset, len, ctxt); return new SystemPropertiesAwareJsonParser(delegate); }