use of edu.harvard.iq.dataverse.authorization.groups.impl.shib.ShibGroup in project dataverse by IQSS.
the class Groups method createShibGroup.
@POST
@Path("shib")
public Response createShibGroup(JsonObject shibGroupInput) {
String expectedNameKey = "name";
JsonString name = shibGroupInput.getJsonString(expectedNameKey);
if (name == null) {
return error(Response.Status.BAD_REQUEST, "required field missing: " + expectedNameKey);
}
String expectedAttributeKey = "attribute";
JsonString attribute = shibGroupInput.getJsonString(expectedAttributeKey);
if (attribute == null) {
return error(Response.Status.BAD_REQUEST, "required field missing: " + expectedAttributeKey);
}
String expectedPatternKey = "pattern";
JsonString pattern = shibGroupInput.getJsonString(expectedPatternKey);
if (pattern == null) {
return error(Response.Status.BAD_REQUEST, "required field missing: " + expectedPatternKey);
}
ShibGroup shibGroupToPersist = new ShibGroup(name.getString(), attribute.getString(), pattern.getString(), shibGroupPrv);
ShibGroup persitedShibGroup = shibGroupPrv.persist(shibGroupToPersist);
if (persitedShibGroup != null) {
return ok("Shibboleth group persisted: " + persitedShibGroup);
} else {
return error(Response.Status.BAD_REQUEST, "Could not persist Shibboleth group");
}
}
Aggregations