Search in sources :

Example 1 with JSONObject

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;
}
Also used : JSONObject(com.nimbusds.jose.shaded.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(com.nimbusds.jose.shaded.json.JSONArray) JSONObject(com.nimbusds.jose.shaded.json.JSONObject)

Example 2 with JSONObject

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;
}
Also used : JSONObject(com.nimbusds.jose.shaded.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(com.nimbusds.jose.shaded.json.JSONArray) JSONObject(com.nimbusds.jose.shaded.json.JSONObject)

Example 3 with JSONObject

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;
}
Also used : Claims(com.forgerock.openbanking.model.claim.Claims) JSONObject(com.nimbusds.jose.shaded.json.JSONObject) JWTClaimsSet(com.nimbusds.jwt.JWTClaimsSet) JSONObject(com.nimbusds.jose.shaded.json.JSONObject)

Example 4 with JSONObject

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());
}
Also used : SignRequest(com.amazonaws.services.kms.model.SignRequest) JSONObject(com.nimbusds.jose.shaded.json.JSONObject) Payload(com.nimbusds.jose.Payload) JWSObject(com.nimbusds.jose.JWSObject) JWSHeader(com.nimbusds.jose.JWSHeader) Test(org.junit.jupiter.api.Test)

Example 5 with JSONObject

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");
}
Also used : JSONObject(com.nimbusds.jose.shaded.json.JSONObject)

Aggregations

JSONObject (com.nimbusds.jose.shaded.json.JSONObject)52 lombok.val (lombok.val)22 Test (org.junit.jupiter.api.Test)21 Secret (io.kidsfirst.core.model.Secret)10 JSONArray (com.nimbusds.jose.shaded.json.JSONArray)9 Map (java.util.Map)5 Slf4j (lombok.extern.slf4j.Slf4j)5 JWSObject (com.nimbusds.jose.JWSObject)4 FenceService (io.kidsfirst.core.service.FenceService)4 SecretService (io.kidsfirst.core.service.SecretService)4 ResponseEntity (org.springframework.http.ResponseEntity)4 JwtAuthenticationToken (org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken)4 org.springframework.web.bind.annotation (org.springframework.web.bind.annotation)4 IOException (java.io.IOException)3 ECPublicKey (java.security.interfaces.ECPublicKey)3 Flux (reactor.core.publisher.Flux)3 Mono (reactor.core.publisher.Mono)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)2 URI (java.net.URI)2