Search in sources :

Example 1 with ProtocolAttributeEncoder

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

the class DefaultCasAttributeEncoderTests method checkAttributesEncodedCorrectly.

@Test
public void checkAttributesEncodedCorrectly() {
    final Service service = RegisteredServiceTestUtils.getService("testencryption");
    final ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, NoOpCipherExecutor.getInstance());
    final Map<String, Object> encoded = encoder.encodeAttributes(this.attributes, this.servicesManager.findServiceBy(service));
    assertEquals(encoded.size(), this.attributes.size());
    checkEncryptedValues(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL_CREDENTIAL, encoded);
    checkEncryptedValues(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET, encoded);
}
Also used : Service(org.apereo.cas.authentication.principal.Service) ProtocolAttributeEncoder(org.apereo.cas.authentication.ProtocolAttributeEncoder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with ProtocolAttributeEncoder

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

the class DefaultCasAttributeEncoderTests method checkNoPublicKeyDefined.

@Test
public void checkNoPublicKeyDefined() {
    final Service service = RegisteredServiceTestUtils.getService("testDefault");
    final ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, NoOpCipherExecutor.getInstance());
    final Map<String, Object> encoded = encoder.encodeAttributes(this.attributes, this.servicesManager.findServiceBy(service));
    assertEquals(encoded.size(), this.attributes.size() - 2);
}
Also used : Service(org.apereo.cas.authentication.principal.Service) ProtocolAttributeEncoder(org.apereo.cas.authentication.ProtocolAttributeEncoder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ProtocolAttributeEncoder

use of org.apereo.cas.authentication.ProtocolAttributeEncoder 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)

Aggregations

ProtocolAttributeEncoder (org.apereo.cas.authentication.ProtocolAttributeEncoder)3 Service (org.apereo.cas.authentication.principal.Service)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DefaultCasProtocolAttributeEncoder (org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder)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