use of org.apereo.cas.util.http.HttpClient in project cas by apereo.
the class FileTrustStoreSslSocketFactoryTests method verifyTrustStoreLoadingSuccessfullyWithCertAvailable2.
@Test
public void verifyTrustStoreLoadingSuccessfullyWithCertAvailable2() throws Exception {
final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
clientFactory.setSslSocketFactory(sslFactory());
final HttpClient client = clientFactory.getObject();
assertTrue(client.isValidEndPoint("https://untrusted-root.badssl.com"));
}
use of org.apereo.cas.util.http.HttpClient in project cas by apereo.
the class FileTrustStoreSslSocketFactoryTests method verifyTrustStoreLoadingSuccessfullyWihInsecureEndpoint.
@Test
public void verifyTrustStoreLoadingSuccessfullyWihInsecureEndpoint() throws Exception {
final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
clientFactory.setSslSocketFactory(sslFactory());
final HttpClient client = clientFactory.getObject();
assertTrue(client.isValidEndPoint("http://wikipedia.org"));
}
use of org.apereo.cas.util.http.HttpClient in project cas by apereo.
the class FileTrustStoreSslSocketFactoryTests method verifyTrustStoreLoadingSuccessfullyWithCertAvailable.
@Test
public void verifyTrustStoreLoadingSuccessfullyWithCertAvailable() throws Exception {
final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
clientFactory.setSslSocketFactory(sslFactory());
final HttpClient client = clientFactory.getObject();
assertTrue(client.isValidEndPoint("https://self-signed.badssl.com"));
}
use of org.apereo.cas.util.http.HttpClient in project cas by apereo.
the class RemoteEndpointServiceAccessStrategy method doPrincipalAttributesAllowServiceAccess.
@Override
public boolean doPrincipalAttributesAllowServiceAccess(final String principal, final Map<String, Object> principalAttributes) {
try {
if (super.doPrincipalAttributesAllowServiceAccess(principal, principalAttributes)) {
final HttpClient client = ApplicationContextProvider.getApplicationContext().getBean("noRedirectHttpClient", HttpClient.class);
final URIBuilder builder = new URIBuilder(this.endpointUrl);
builder.addParameter("username", principal);
final URL url = builder.build().toURL();
final HttpMessage message = client.sendMessageToEndPoint(url);
LOGGER.debug("Message received from [{}] is [{}]", url, message);
return message != null && StringUtils.commaDelimitedListToSet(this.acceptableResponseCodes).contains(String.valueOf(message.getResponseCode()));
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
use of org.apereo.cas.util.http.HttpClient in project cas by apereo.
the class HttpBasedServiceCredentialsAuthenticationHandlerTests method verifyNoAcceptableStatusCodeButOneSet.
@Test
public void verifyNoAcceptableStatusCodeButOneSet() throws Exception {
final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
clientFactory.setAcceptableCodes(new int[] { 900 });
final HttpClient httpClient = clientFactory.getObject();
this.authenticationHandler = new HttpBasedServiceCredentialsAuthenticationHandler("", null, null, null, httpClient);
this.thrown.expect(FailedLoginException.class);
this.thrown.expectMessage("https://www.ja-sig.org sent an unacceptable response status code");
this.authenticationHandler.authenticate(RegisteredServiceTestUtils.getHttpBasedServiceCredentials("https://www.ja-sig.org"));
}
Aggregations