Search in sources :

Example 1 with OxtrustSetting

use of org.gluu.oxtrust.api.server.model.OxtrustSetting in project oxTrust by GluuFederation.

the class OxtrustSettingWebResource method getOxtrustSettings.

@GET
@Operation(summary = "Get oxtrust settings", description = "Get oxtrust settings")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxtrustSetting.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getOxtrustSettings() {
    try {
        log(logger, "Processing oxtrust settings retrieval request");
        GluuConfiguration configurationUpdate = configurationService.getConfiguration();
        OxtrustSetting setting = new OxtrustSetting();
        setting.setAllowPasswordReset(String.valueOf(configurationUpdate.isPasswordResetAllowed()));
        setting.setAllowProfileManagement(String.valueOf(configurationUpdate.isProfileManagment()));
        setting.setEnablePassport(String.valueOf(configurationUpdate.isPassportEnabled()));
        setting.setEnableScim(String.valueOf(configurationUpdate.isScimEnabled()));
        return Response.ok(setting).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : OxtrustSetting(org.gluu.oxtrust.api.server.model.OxtrustSetting) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) GET(javax.ws.rs.GET) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 2 with OxtrustSetting

use of org.gluu.oxtrust.api.server.model.OxtrustSetting in project oxTrust by GluuFederation.

the class OxtrustSettingWebResourceTest method updateOxtrustSettingTest.

@Test
public void updateOxtrustSettingTest() {
    OxtrustSetting oxtrustSetting = getOxTrustSetting();
    try {
        HttpPut second = new HttpPut(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.CONFIGURATION + ApiConstants.OXTRUST_SETTINGS);
        HttpEntity entity = new ByteArrayEntity(mapper.writeValueAsString(oxtrustSetting).toString().getBytes("UTF-8"), ContentType.APPLICATION_FORM_URLENCODED);
        second.setEntity(entity);
        second.setHeader(CONTENT_TYPE, MediaType.APPLICATION_JSON);
        HttpResponse response = handle(second);
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : OxtrustSetting(org.gluu.oxtrust.api.server.model.OxtrustSetting) HttpEntity(org.apache.http.HttpEntity) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 3 with OxtrustSetting

use of org.gluu.oxtrust.api.server.model.OxtrustSetting in project oxTrust by GluuFederation.

the class OxtrustSettingWebResourceTest method getOxTrustSetting.

private OxtrustSetting getOxTrustSetting() {
    OxtrustSetting oxtrustSetting = new OxtrustSetting();
    oxtrustSetting.setAllowPasswordReset(GluuBoolean.ENABLED.getValue());
    oxtrustSetting.setAllowProfileManagement(GluuBoolean.ENABLED.getValue());
    oxtrustSetting.setEnablePassport(GluuBoolean.ENABLED.getValue());
    oxtrustSetting.setEnableScim(GluuBoolean.ENABLED.getValue());
    return oxtrustSetting;
}
Also used : OxtrustSetting(org.gluu.oxtrust.api.server.model.OxtrustSetting)

Aggregations

OxtrustSetting (org.gluu.oxtrust.api.server.model.OxtrustSetting)3 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 IOException (java.io.IOException)1 GET (javax.ws.rs.GET)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1 ParseException (org.apache.http.ParseException)1 HttpPut (org.apache.http.client.methods.HttpPut)1 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)1 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)1 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)1 Test (org.junit.Test)1