use of org.apereo.cas.configuration.model.core.authentication.RestAuthenticationPolicyProperties in project cas by apereo.
the class CoreAuthenticationUtilsTests method verifyAuthnPolicyRest.
@Test
public void verifyAuthnPolicyRest() throws Exception {
val props = new AuthenticationPolicyProperties();
val rest = new RestAuthenticationPolicyProperties();
rest.setUrl("http://example.org");
props.getRest().add(rest);
val policy = CoreAuthenticationUtils.newAuthenticationPolicy(props);
verifySerialization(policy);
}
use of org.apereo.cas.configuration.model.core.authentication.RestAuthenticationPolicyProperties in project cas by apereo.
the class RestfulAuthenticationPolicyTests method assertPolicyFails.
private static void assertPolicyFails(final int port, final HttpStatus status, final Class<? extends Throwable> exceptionClass) {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
try (val webServer = new MockWebServer(port, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "Output"), status)) {
webServer.start();
val props = new RestAuthenticationPolicyProperties();
props.setUrl("http://localhost:" + port);
val policy = new RestfulAuthenticationPolicy(props);
assertThrowsWithRootCause(GeneralSecurityException.class, exceptionClass, () -> policy.isSatisfiedBy(CoreAuthenticationTestUtils.getAuthentication("casuser"), new LinkedHashSet<>(), applicationContext, Optional.empty()));
}
}
use of org.apereo.cas.configuration.model.core.authentication.RestAuthenticationPolicyProperties in project cas by apereo.
the class RestfulRegisteredServiceAuthenticationPolicyCriteria method toAuthenticationPolicy.
@Override
public AuthenticationPolicy toAuthenticationPolicy(final RegisteredService registeredService) {
val props = new RestAuthenticationPolicyProperties();
props.setUrl(url);
props.setBasicAuthUsername(basicAuthUsername);
props.setBasicAuthPassword(basicAuthPassword);
return new RestfulAuthenticationPolicy(props);
}
use of org.apereo.cas.configuration.model.core.authentication.RestAuthenticationPolicyProperties in project cas by apereo.
the class RestfulAuthenticationPolicyTests method verifyAllowedOperation.
@Test
public void verifyAllowedOperation() throws Exception {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
try (val webServer = new MockWebServer(9200, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val props = new RestAuthenticationPolicyProperties();
props.setUrl("http://localhost:9200");
val policy = new RestfulAuthenticationPolicy(props);
assertTrue(policy.isSatisfiedBy(CoreAuthenticationTestUtils.getAuthentication("casuser"), new LinkedHashSet<>(), applicationContext, Optional.empty()).isSuccess());
}
}
Aggregations