use of com.nimbusds.jose.shaded.json.JSONArray 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.JSONArray 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.JSONArray in project oauth2-server by gw2auth.
the class TestHelper method createSubtokenJWT.
public static String createSubtokenJWT(UUID sub, Set<Gw2ApiPermission> permissions, Instant issuedAt, Duration expiresIn) {
final JSONArray jsonPermissions = new JSONArray();
permissions.stream().map(Gw2ApiPermission::gw2).forEach(jsonPermissions::add);
JWTClaimsSet claims = new JWTClaimsSet.Builder().subject(sub.toString()).jwtID(UUID.randomUUID().toString()).issueTime(new Date(issuedAt.toEpochMilli())).expirationTime(new Date(issuedAt.plus(expiresIn).toEpochMilli())).claim("permissions", jsonPermissions).build();
final SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256, JOSEObjectType.JWT, null, null, null, null, null, null, null, null, null, true, null, null), claims);
try {
signedJWT.sign(new MACSigner(new byte[32]));
} catch (JOSEException e) {
throw new RuntimeException(e);
}
return signedJWT.serialize();
}
use of com.nimbusds.jose.shaded.json.JSONArray in project spring-addons by ch4mpy.
the class SpringAddonsSecurityProperties method getRoles.
private static Stream<String> getRoles(Map<String, Object> claims, String rolesPath) {
final var claimsToWalk = rolesPath.split("\\.");
var i = 0;
var obj = Optional.of(claims);
while (i++ < claimsToWalk.length) {
final var claimName = claimsToWalk[i - 1];
if (i == claimsToWalk.length) {
return obj.map(o -> (JSONArray) o.get(claimName)).orElse(new JSONArray()).stream().map(Object::toString);
}
obj = obj.map(o -> (JSONObject) o.get(claimName));
}
return Stream.empty();
}
use of com.nimbusds.jose.shaded.json.JSONArray in project PowerNukkitX by PowerNukkitX.
the class Metrics method submitData.
/**
* Collects the data and sends it afterwards.
*/
private void submitData() {
final JSONObject data = getServerData();
JSONArray pluginData = new JSONArray();
pluginData.add(getPluginData());
data.put("plugins", pluginData);
try {
// We are still in the Thread of the timer, so nothing get blocked :)
sendData(data);
} catch (Exception e) {
// Something went wrong! :(
if (logFailedRequests) {
log.warn("Could not submit stats of {}", name, e);
}
}
}
Aggregations