Search in sources :

Example 1 with DefaultCasProtocolAttributeEncoder

use of org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder in project cas by apereo.

the class Cas30ResponseViewTests method renderView.

private Map<?, ?> renderView() 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 ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, NoOpCipherExecutor.getInstance());
    final View viewDelegated = new View() {

        @Override
        public String getContentType() {
            return MediaType.TEXT_HTML_VALUE;
        }

        @Override
        public void render(final Map<String, ?> map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
            map.forEach(request::setAttribute);
        }
    };
    final Cas30ResponseView view = new Cas30ResponseView(true, encoder, servicesManager, "attribute", viewDelegated, true);
    final MockHttpServletResponse resp = new MockHttpServletResponse();
    view.render(modelAndView.getModel(), req, resp);
    return (Map<?, ?>) req.getAttribute(CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_ATTRIBUTES);
}
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) 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) DefaultCasProtocolAttributeEncoder(org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder) DefaultCasProtocolAttributeEncoder(org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder) ProtocolAttributeEncoder(org.apereo.cas.authentication.ProtocolAttributeEncoder) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext) Map(java.util.Map) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 2 with DefaultCasProtocolAttributeEncoder

use of org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder in project cas by apereo.

the class Saml10SuccessResponseViewTests method setUp.

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

Aggregations

DefaultCasProtocolAttributeEncoder (org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ProtocolAttributeEncoder (org.apereo.cas.authentication.ProtocolAttributeEncoder)1 DefaultServicesManager (org.apereo.cas.services.DefaultServicesManager)1 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)1 RegisteredService (org.apereo.cas.services.RegisteredService)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 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 View (org.springframework.web.servlet.View)1