use of org.gluu.oxtrust.api.server.model.AuthenticationMethod in project oxTrust by GluuFederation.
the class AuthenticationMethodWebResource method getCurrentAuthentication.
@GET
@Operation(summary = "Get current authentication methods", description = "Get current authentication methods")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = AuthenticationMethod.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getCurrentAuthentication() {
log(logger, "Processing getCurrentAuthentication()");
try {
GluuConfiguration configuration = configurationService.getConfiguration();
AuthenticationMethod method = new AuthenticationMethod();
method.setDefaultAcr(configuration.getAuthenticationMode());
method.setOxtrustAcr(configuration.getOxTrustAuthenticationMode());
return Response.ok(method).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.api.server.model.AuthenticationMethod in project oxTrust by GluuFederation.
the class AuthenticationMethodWebResourceTest method updateAuthenticationMethodTest.
@Test
public void updateAuthenticationMethodTest() {
HttpPut request = new HttpPut(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.ACRS);
AuthenticationMethod method = new AuthenticationMethod();
String defaultAcr = "auth_ldap_server";
method.setDefaultAcr(defaultAcr);
method.setOxtrustAcr(defaultAcr);
try {
String json = mapper.writeValueAsString(method);
HttpEntity entity = new ByteArrayEntity(json.toString().getBytes("UTF-8"));
request.setEntity(entity);
request.setHeader("Content-Type", MediaType.APPLICATION_JSON);
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity result = response.getEntity();
AuthenticationMethod value = mapper.readValue(EntityUtils.toString(result), AuthenticationMethod.class);
Assert.assertEquals(value.getOxtrustAcr(), defaultAcr);
Assert.assertEquals(value.getDefaultAcr(), defaultAcr);
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
use of org.gluu.oxtrust.api.server.model.AuthenticationMethod in project oxTrust by GluuFederation.
the class AuthenticationMethodWebResourceTest method getCurrentAuthenticationTest.
@Test
public void getCurrentAuthenticationTest() {
HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.ACRS);
try {
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity result = response.getEntity();
AuthenticationMethod method = mapper.readValue(EntityUtils.toString(result), AuthenticationMethod.class);
Assert.assertNotNull(method.getDefaultAcr());
Assert.assertNotNull(method.getOxtrustAcr());
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
Aggregations