use of com.nimbusds.jose.shaded.json.JSONObject in project openbanking-aspsp by OpenBankingToolkit.
the class DirectorySoftwareStatementFactory method getOrgContacts.
private List<OrganisationContact> getOrgContacts(RegistrationRequestJWTClaims softwareStatementClaims) {
List<OrganisationContact> contacts = new ArrayList<>();
JSONArray contactsJsonArray = (JSONArray) softwareStatementClaims.getClaim(SSAClaims.ORG_CONTACTS);
if (contactsJsonArray != null) {
for (Object contactJson : contactsJsonArray) {
JSONObject contactJsonObject = ((JSONObject) contactJson);
OrganisationContact orgContact = OrganisationContact.builder().name(getContactField(contactJsonObject, "name")).email(getContactField(contactJsonObject, "email")).type(getContactField(contactJsonObject, "type")).phone(getContactField(contactJsonObject, "phone")).build();
contacts.add(orgContact);
}
} else {
String errorString = "No " + SSAClaims.ORG_CONTACTS + " field available from Software Statement";
log.info("getOrgContacts() {}", errorString);
}
return contacts;
}
use of com.nimbusds.jose.shaded.json.JSONObject in project openbanking-aspsp by OpenBankingToolkit.
the class DirectorySoftwareStatementFactory method getAuthorizations.
private List<AuthorisationClaim> getAuthorizations(JSONObject contactsJsonArray) throws ParseException {
List<AuthorisationClaim> authClaims = new ArrayList<>();
JSONArray authorityClaims = (JSONArray) contactsJsonArray.get(SSAClaims.OCAC_AUTHORISATIONS);
for (Object authorityClaim : authorityClaims) {
JSONObject authorityClaimJson = (JSONObject) authorityClaim;
AuthorisationClaim authClaim = AuthorisationClaim.builder().member_state(JSONObjectUtils.getString(authorityClaimJson, SSAClaims.OCAC_MEMBER_STATE)).roles(JSONObjectUtils.getStringList(authorityClaimJson, SSAClaims.OCAC_ROLES)).build();
authClaims.add(authClaim);
}
return authClaims;
}
use of com.nimbusds.jose.shaded.json.JSONObject in project openbanking-aspsp by OpenBankingToolkit.
the class JwsClaimsUtils method getClaims.
/**
* getClaims extracts the claims from a JWT
*
* @param signedJWT the JWT from which the claims are to be returned
* @return a {@code Claims} object containing the claims extracted from {@code signedJWT}
* @throws ParseException
*/
public static Claims getClaims(SignedJWT signedJWT) throws ParseException {
JWTClaimsSet claimSet = signedJWT.getJWTClaimsSet();
Map<String, Object> jsonClaimSet = claimSet.getJSONObjectClaim(OIDCConstants.OIDCClaim.CLAIMS);
Claims claims = Claims.parseClaims(new JSONObject(jsonClaimSet));
return claims;
}
use of com.nimbusds.jose.shaded.json.JSONObject in project di-ipv-cri-uk-passport-back by alphagov.
the class KmsSignerTest method shouldSignJWSObject.
@Test
void shouldSignJWSObject() throws JOSEException {
when(kmsClient.sign(any(SignRequest.class))).thenReturn(signResult);
byte[] bytes = new byte[10];
when(signResult.getSignature()).thenReturn(ByteBuffer.wrap(bytes));
KmsSigner kmsSigner = new KmsSigner(KEY_ID, kmsClient);
JSONObject jsonPayload = new JSONObject(Map.of("test", "test"));
JWSHeader jwsHeader = new JWSHeader.Builder(JWSAlgorithm.ES256).build();
JWSObject jwsObject = new JWSObject(jwsHeader, new Payload(jsonPayload));
jwsObject.sign(kmsSigner);
assertEquals(JWSObject.State.SIGNED, jwsObject.getState());
assertEquals(jwsHeader, jwsObject.getHeader());
assertEquals(jsonPayload.toJSONString(), jwsObject.getPayload().toString());
}
use of com.nimbusds.jose.shaded.json.JSONObject in project Protocol by CloudburstMC.
the class SerializedSkin method convertSkinPatchToLegacy.
private static String convertSkinPatchToLegacy(String skinResourcePatch) {
checkArgument(validateSkinResourcePatch(skinResourcePatch), "Invalid skin resource patch");
JSONObject object = (JSONObject) JSONValue.parse(skinResourcePatch);
JSONObject geometry = (JSONObject) object.get("geometry");
return (String) geometry.get("default");
}
Aggregations