Search in sources :

Example 1 with SimpleHttpClientFactoryBean

use of org.apereo.cas.util.http.SimpleHttpClientFactoryBean in project cas by apereo.

the class Cas20ProxyHandlerTests method setUp.

@Before
public void setUp() throws Exception {
    final SimpleHttpClientFactoryBean factory = new SimpleHttpClientFactoryBean();
    factory.setConnectionTimeout(10000);
    factory.setReadTimeout(10000);
    this.handler = new Cas20ProxyHandler(factory.getObject(), new DefaultUniqueTicketIdGenerator());
    when(this.proxyGrantingTicket.getId()).thenReturn("proxyGrantingTicket");
}
Also used : SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) Before(org.junit.Before)

Example 2 with SimpleHttpClientFactoryBean

use of org.apereo.cas.util.http.SimpleHttpClientFactoryBean in project cas by apereo.

the class FileTrustStoreSslSocketFactoryTests method verifyTrustStoreLoadingSuccessfullyWithCertAvailable2.

@Test
public void verifyTrustStoreLoadingSuccessfullyWithCertAvailable2() {
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setSslSocketFactory(sslFactory());
    final HttpClient client = clientFactory.getObject();
    assertTrue(client.isValidEndPoint("https://untrusted-root.badssl.com"));
}
Also used : SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) HttpClient(org.apereo.cas.util.http.HttpClient) Test(org.junit.Test)

Example 3 with SimpleHttpClientFactoryBean

use of org.apereo.cas.util.http.SimpleHttpClientFactoryBean in project cas by apereo.

the class TrustedProxyAuthenticationTrustStoreSslSocketFactoryTests method prepareHttpClient.

@Before
public void prepareHttpClient() throws Exception {
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setSslSocketFactory(new SSLConnectionSocketFactory(new DefaultCasSslContext(TRUST_STORE, TRUST_STORE_PSW, KeyStore.getDefaultType()).getSslContext()));
    this.client = clientFactory.getObject();
}
Also used : SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) DefaultCasSslContext(org.apereo.cas.authentication.DefaultCasSslContext) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) Before(org.junit.Before)

Example 4 with SimpleHttpClientFactoryBean

use of org.apereo.cas.util.http.SimpleHttpClientFactoryBean in project cas by apereo.

the class FrontChannelLogoutActionTests method onSetUp.

@Before
public void onSetUp() throws Exception {
    final UrlValidator validator = new SimpleUrlValidatorFactoryBean(false).getObject();
    final DefaultSingleLogoutServiceMessageHandler handler = new DefaultSingleLogoutServiceMessageHandler(new SimpleHttpClientFactoryBean().getObject(), new SamlCompliantLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(validator), false, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
    final DefaultLogoutManager logoutManager = new DefaultLogoutManager(new SamlCompliantLogoutMessageCreator(), handler, false, mock(LogoutExecutionPlan.class));
    this.frontChannelLogoutAction = new FrontChannelLogoutAction(logoutManager);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockHttpServletResponse response = new MockHttpServletResponse();
    this.requestContext = mock(RequestContext.class);
    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(this.requestContext.getExternalContext()).thenReturn(servletExternalContext);
    when(servletExternalContext.getNativeRequest()).thenReturn(request);
    when(servletExternalContext.getNativeResponse()).thenReturn(response);
    final LocalAttributeMap flowScope = new LocalAttributeMap();
    when(this.requestContext.getFlowScope()).thenReturn(flowScope);
    final MockFlowExecutionKey mockFlowExecutionKey = new MockFlowExecutionKey(FLOW_EXECUTION_KEY);
    final MockFlowExecutionContext mockFlowExecutionContext = new MockFlowExecutionContext();
    mockFlowExecutionContext.setKey(mockFlowExecutionKey);
    when(this.requestContext.getFlowExecutionContext()).thenReturn(mockFlowExecutionContext);
}
Also used : DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockFlowExecutionKey(org.springframework.webflow.test.MockFlowExecutionKey) DefaultSingleLogoutServiceMessageHandler(org.apereo.cas.logout.DefaultSingleLogoutServiceMessageHandler) DefaultLogoutManager(org.apereo.cas.logout.DefaultLogoutManager) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.DefaultSingleLogoutServiceLogoutUrlBuilder) FrontChannelLogoutAction(org.apereo.cas.web.flow.logout.FrontChannelLogoutAction) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) LogoutExecutionPlan(org.apereo.cas.logout.LogoutExecutionPlan) SimpleUrlValidatorFactoryBean(org.apereo.cas.web.SimpleUrlValidatorFactoryBean) MockFlowExecutionContext(org.springframework.webflow.test.MockFlowExecutionContext) SamlCompliantLogoutMessageCreator(org.apereo.cas.logout.SamlCompliantLogoutMessageCreator) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) UrlValidator(org.apereo.cas.web.UrlValidator) RequestContext(org.springframework.webflow.execution.RequestContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Example 5 with SimpleHttpClientFactoryBean

use of org.apereo.cas.util.http.SimpleHttpClientFactoryBean in project cas by apereo.

the class HttpBasedServiceCredentialsAuthenticationHandlerTests method verifyNoAcceptableStatusCodeButOneSet.

@Test
public void verifyNoAcceptableStatusCodeButOneSet() {
    val clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setAcceptableCodes(CollectionUtils.wrapList(900));
    val httpClient = clientFactory.getObject();
    this.authenticationHandler = new HttpBasedServiceCredentialsAuthenticationHandler(StringUtils.EMPTY, null, null, null, httpClient);
    assertThrows(FailedLoginException.class, () -> this.authenticationHandler.authenticate(RegisteredServiceTestUtils.getHttpBasedServiceCredentials("https://www.ja-sig.org")));
}
Also used : lombok.val(lombok.val) SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleHttpClientFactoryBean (org.apereo.cas.util.http.SimpleHttpClientFactoryBean)9 lombok.val (lombok.val)5 DefaultUniqueTicketIdGenerator (org.apereo.cas.util.DefaultUniqueTicketIdGenerator)3 Before (org.junit.Before)3 Test (org.junit.jupiter.api.Test)3 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)2 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)2 URL (java.net.URL)1 SSLConnectionSocketFactory (org.apache.http.conn.ssl.SSLConnectionSocketFactory)1 DefaultCasSslContext (org.apereo.cas.authentication.DefaultCasSslContext)1 HttpBasedServiceCredential (org.apereo.cas.authentication.credential.HttpBasedServiceCredential)1 Service (org.apereo.cas.authentication.principal.Service)1 DefaultLogoutManager (org.apereo.cas.logout.DefaultLogoutManager)1 DefaultSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.DefaultSingleLogoutServiceLogoutUrlBuilder)1 DefaultSingleLogoutServiceMessageHandler (org.apereo.cas.logout.DefaultSingleLogoutServiceMessageHandler)1 LogoutExecutionPlan (org.apereo.cas.logout.LogoutExecutionPlan)1 SamlCompliantLogoutMessageCreator (org.apereo.cas.logout.SamlCompliantLogoutMessageCreator)1 DefaultSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder)1 DefaultSingleLogoutServiceMessageHandler (org.apereo.cas.logout.slo.DefaultSingleLogoutServiceMessageHandler)1 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)1