use of com.nimbusds.jose.shaded.json.JSONObject in project Protocol by CloudburstMC.
the class SerializedSkin method validateSkinResourcePatch.
private static boolean validateSkinResourcePatch(String skinResourcePatch) {
try {
JSONObject object = (JSONObject) JSONValue.parse(skinResourcePatch);
JSONObject geometry = (JSONObject) object.get("geometry");
return geometry.containsKey("default") && geometry.get("default") instanceof String;
} catch (ClassCastException | NullPointerException e) {
return false;
}
}
use of com.nimbusds.jose.shaded.json.JSONObject 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.JSONObject 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);
}
}
}
use of com.nimbusds.jose.shaded.json.JSONObject in project PowerNukkitX by PowerNukkitX.
the class Metrics method getPluginData.
/**
* Gets the plugin specific data.
*
* @return The plugin specific data.
*/
private JSONObject getPluginData() {
JSONObject data = new JSONObject();
// Append the name of the server software
data.put("pluginName", name);
JSONArray customCharts = new JSONArray();
for (CustomChart customChart : charts) {
// Add the data of the custom charts
JSONObject chart = customChart.getRequestJsonObject();
if (chart == null) {
// If the chart is null, we skip it
continue;
}
customCharts.add(chart);
}
data.put("customCharts", customCharts);
return data;
}
use of com.nimbusds.jose.shaded.json.JSONObject in project PowerNukkitX by PowerNukkitX.
the class Skin method isValidResourcePatch.
private boolean isValidResourcePatch() {
if (skinResourcePatch == null || skinResourcePatch.length() > 1000) {
return false;
}
try {
JSONObject object = (JSONObject) JSONValue.parse(skinResourcePatch);
JSONObject geometry = (JSONObject) object.get("geometry");
return geometry.containsKey("default") && geometry.get("default") instanceof String;
} catch (ClassCastException | NullPointerException e) {
return false;
}
}
Aggregations