Search in sources :

Example 1 with DefaultAuthenticationAttributeReleasePolicy

use of org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy in project cas by apereo.

the class Saml10SuccessResponseViewTests method setUp.

@Before
public void setUp() {
    final List<RegisteredService> list = new ArrayList<>();
    list.add(RegisteredServiceTestUtils.getRegisteredService("https://.+"));
    final InMemoryServiceRegistry dao = new InMemoryServiceRegistry();
    dao.setRegisteredServices(list);
    final ServicesManager mgmr = new DefaultServicesManager(dao, mock(ApplicationEventPublisher.class));
    mgmr.load();
    this.response = new Saml10SuccessResponseView(new DefaultCasProtocolAttributeEncoder(mgmr, CipherExecutor.noOpOfStringToString()), mgmr, "attribute", new Saml10ObjectBuilder(configBean), new DefaultArgumentExtractor(new SamlServiceFactory()), StandardCharsets.UTF_8.name(), 1000, 30, "testIssuer", "whatever", new DefaultAuthenticationAttributeReleasePolicy());
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) SamlServiceFactory(org.apereo.cas.support.saml.authentication.principal.SamlServiceFactory) ArrayList(java.util.ArrayList) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) DefaultAuthenticationAttributeReleasePolicy(org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy) ServicesManager(org.apereo.cas.services.ServicesManager) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) DefaultArgumentExtractor(org.apereo.cas.web.support.DefaultArgumentExtractor) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) DefaultCasProtocolAttributeEncoder(org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) Saml10ObjectBuilder(org.apereo.cas.support.saml.util.Saml10ObjectBuilder) Before(org.junit.Before)

Example 2 with DefaultAuthenticationAttributeReleasePolicy

use of org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy in project cas by apereo.

the class Cas20ResponseViewTests method verifyView.

@Test
public void verifyView() throws Exception {
    final ModelAndView modelAndView = this.getModelAndViewUponServiceValidationWithSecurePgtUrl();
    final MockHttpServletRequest req = new MockHttpServletRequest(new MockServletContext());
    req.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, new GenericWebApplicationContext(req.getServletContext()));
    final MockHttpServletResponse resp = new MockHttpServletResponse();
    final View delegatedView = new View() {

        @Override
        public String getContentType() {
            return "text/html";
        }

        @Override
        public void render(final Map<String, ?> map, final HttpServletRequest request, final HttpServletResponse response) {
            map.forEach(request::setAttribute);
        }
    };
    final Cas20ResponseView view = new Cas20ResponseView(true, null, null, "attribute", delegatedView, new DefaultAuthenticationAttributeReleasePolicy(), new DefaultAuthenticationServiceSelectionPlan());
    view.render(modelAndView.getModel(), req, resp);
    assertNotNull(req.getAttribute(CasViewConstants.MODEL_ATTRIBUTE_NAME_CHAINED_AUTHENTICATIONS));
    assertNotNull(req.getAttribute(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRIMARY_AUTHENTICATION));
    assertNotNull(req.getAttribute(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL));
    assertNotNull(req.getAttribute(CasProtocolConstants.VALIDATION_CAS_MODEL_PROXY_GRANTING_TICKET_IOU));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ModelAndView(org.springframework.web.servlet.ModelAndView) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) ModelAndView(org.springframework.web.servlet.ModelAndView) View(org.springframework.web.servlet.View) MockServletContext(org.springframework.mock.web.MockServletContext) HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultAuthenticationAttributeReleasePolicy(org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext) Map(java.util.Map) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 3 with DefaultAuthenticationAttributeReleasePolicy

use of org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy in project cas by apereo.

the class CasCoreAuthenticationConfiguration method authenticationAttributeReleasePolicy.

@ConditionalOnMissingBean(name = "authenticationAttributeReleasePolicy")
@RefreshScope
@Bean
public AuthenticationAttributeReleasePolicy authenticationAttributeReleasePolicy() {
    final AuthenticationAttributeReleaseProperties authenticationAttributeRelease = casProperties.getAuthn().getAuthenticationAttributeRelease();
    final DefaultAuthenticationAttributeReleasePolicy policy = new DefaultAuthenticationAttributeReleasePolicy();
    policy.setAttributesToRelease(authenticationAttributeRelease.getOnlyRelease());
    final Set<String> attributesToNeverRelease = CollectionUtils.wrapSet(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL_CREDENTIAL, RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
    attributesToNeverRelease.addAll(authenticationAttributeRelease.getNeverRelease());
    policy.setAttributesToNeverRelease(attributesToNeverRelease);
    return policy;
}
Also used : DefaultAuthenticationAttributeReleasePolicy(org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy) AuthenticationAttributeReleaseProperties(org.apereo.cas.configuration.model.core.authentication.AuthenticationAttributeReleaseProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DefaultAuthenticationAttributeReleasePolicy (org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy)3 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)1 DefaultCasProtocolAttributeEncoder (org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder)1 AuthenticationAttributeReleaseProperties (org.apereo.cas.configuration.model.core.authentication.AuthenticationAttributeReleaseProperties)1 DefaultServicesManager (org.apereo.cas.services.DefaultServicesManager)1 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)1 RegisteredService (org.apereo.cas.services.RegisteredService)1 ServicesManager (org.apereo.cas.services.ServicesManager)1 SamlServiceFactory (org.apereo.cas.support.saml.authentication.principal.SamlServiceFactory)1 Saml10ObjectBuilder (org.apereo.cas.support.saml.util.Saml10ObjectBuilder)1 DefaultArgumentExtractor (org.apereo.cas.web.support.DefaultArgumentExtractor)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1