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