Search in sources :

Example 1 with ShibGroup

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");
    }
}
Also used : ShibGroup(edu.harvard.iq.dataverse.authorization.groups.impl.shib.ShibGroup) JsonString(javax.json.JsonString) JsonString(javax.json.JsonString) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

ShibGroup (edu.harvard.iq.dataverse.authorization.groups.impl.shib.ShibGroup)1 JsonString (javax.json.JsonString)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1