首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

CAS 回到多个信息为空

2012-07-16 
CAS 返回多个信息为空CAS client 端使用Filter 获得server端传回的信息,如果多个信息使用:assertion.getPr

CAS 返回多个信息为空
CAS client 端使用Filter 获得server端传回的信息,如果多个信息使用:

assertion.getPrincipal().getAttributes()
来获得一个Map,但是有的时候Map中没有数据为null;
解决方案:配置deployerConfigContext.xml中名称为serviceRegistryDao的bean,如下
<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"/>
这个属性决定了我们在client端获得map是否为null,如果不配置该属性则为null,该属性配置我们返回多个信息对应的key;
此处对应CAS SERVER端源码如下 CentralAuthenticationServiceImpl.java:
// 获得deployerConfigContext.xml中serviceRegistryDao配置的registeredServices        final RegisteredService registeredService = this.servicesManager            .findServiceBy(service);

allowwedAttributes配置对应的代码如下:
/**             * 从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);

希望对大家有所帮助

热点排行