Search in sources :

Example 1 with CasProtocolDTO

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

the class CasProtocolWebResource method getCasConfig.

@GET
@Operation(summary = "Get existing configuration", description = "Get the existing configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CasProtocolDTO.class)), description = "Success") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getCasConfig() {
    log(logger, "Get the existing cas configuration");
    try {
        CASProtocolConfiguration casProtocolConfiguration = casProtocolConfigurationProvider.get();
        CasProtocolDTO casProtocolDto = casProtocolDtoAssembly.toDto(casProtocolConfiguration);
        return Response.ok(casProtocolDto).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : CASProtocolConfiguration(org.gluu.oxtrust.util.CASProtocolConfiguration) CasProtocolDTO(org.gluu.oxtrust.api.server.model.CasProtocolDTO) 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 CasProtocolDTO

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

the class CasProtocolWebResourceTest method getCasConfigTest.

@Test
public void getCasConfigTest() {
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.CONFIGURATION + ApiConstants.CAS);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        String content = EntityUtils.toString(entity);
        CasProtocolDTO configuration = mapper.readValue(content, CasProtocolDTO.class);
        Assert.assertNotNull(configuration);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) CasProtocolDTO(org.gluu.oxtrust.api.server.model.CasProtocolDTO) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with CasProtocolDTO

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

the class CasProtocolDtoAssembly method toDto.

public CasProtocolDTO toDto(CASProtocolConfiguration casProtocolConfiguration) {
    CasProtocolDTO casProtocolDTO = new CasProtocolDTO();
    casProtocolDTO.setCasBaseURL(casProtocolConfiguration.getCasBaseURL());
    casProtocolDTO.setShibbolethCASProtocolConfiguration(toDto(casProtocolConfiguration.getConfiguration()));
    return casProtocolDTO;
}
Also used : CasProtocolDTO(org.gluu.oxtrust.api.server.model.CasProtocolDTO)

Aggregations

CasProtocolDTO (org.gluu.oxtrust.api.server.model.CasProtocolDTO)3 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 IOException (java.io.IOException)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1 ParseException (org.apache.http.ParseException)1 HttpGet (org.apache.http.client.methods.HttpGet)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)1 CASProtocolConfiguration (org.gluu.oxtrust.util.CASProtocolConfiguration)1 Test (org.junit.Test)1