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());
}
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));
}
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;
}
Aggregations