CAS 返回多个信息为空
CAS client 端使用Filter 获得server端传回的信息,如果多个信息使用:
assertion.getPrincipal().getAttributes()来获得一个Map,但是有的时候Map中没有数据为null;
<bean id="serviceRegistryDao" p:id="1" p:description="test" p:serviceId="http://192.168.104.101:8080/*" p:enabled="true" p:ssoEnabled="true" p:anonymousAccess="false"> <property name="allowedAttributes" value="key1,key2,key3"/> </bean></list></property>,其中最重要的配置为:<property name="allowedAttributes" value="key1,key2,key3"/>
// 获得deployerConfigContext.xml中serviceRegistryDao配置的registeredServices final RegisteredService registeredService = this.servicesManager .findServiceBy(service);
/** * 从principal.getAttributes()获得map后,获取registeredService的allowedAttributes属性, * 可以对应的key存入返回客户端信息的中map中 */ for (final String attribute : registeredService .getAllowedAttributes()) { final Object value = principal.getAttributes().get( attribute); if (value != null) { attributes.put(attribute, value); } } final Principal modifiedPrincipal = new SimplePrincipal( principalId, attributes); final MutableAuthentication mutableAuthentication = new MutableAuthentication( modifiedPrincipal);;