%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.userinfo.impl.MultiSourceUserInfoManagerImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.userinfo.impl; |
|
18 | ||
19 | import java.util.Collection; |
|
20 | import java.util.HashMap; |
|
21 | import java.util.Iterator; |
|
22 | import java.util.List; |
|
23 | import java.util.Map; |
|
24 | ||
25 | import javax.portlet.PortletRequest; |
|
26 | import javax.security.auth.Subject; |
|
27 | ||
28 | import org.apache.commons.logging.Log; |
|
29 | import org.apache.commons.logging.LogFactory; |
|
30 | import org.apache.jetspeed.components.portletregistry.PortletRegistry; |
|
31 | import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; |
|
32 | import org.apache.jetspeed.request.RequestContext; |
|
33 | import org.apache.jetspeed.userinfo.UserAttributeRetrievalException; |
|
34 | import org.apache.jetspeed.userinfo.UserAttributeSource; |
|
35 | import org.apache.jetspeed.userinfo.UserInfoManager; |
|
36 | import org.apache.jetspeed.userinfo.impl.AbstractUserInfoManagerImpl; |
|
37 | import org.apache.pluto.om.common.ObjectID; |
|
38 | ||
39 | /** |
|
40 | * Multisource User Information manager |
|
41 | * One or more sources are assembled in Spring configuration and setter injected |
|
42 | * |
|
43 | * @author <a href="mailto:KeithGarry.Boyce@bcbsma.com">Keith Garry Boyce </a> |
|
44 | * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a> |
|
45 | * @version $Id: $ |
|
46 | */ |
|
47 | 0 | public class MultiSourceUserInfoManagerImpl extends AbstractUserInfoManagerImpl |
48 | implements UserInfoManager |
|
49 | { |
|
50 | ||
51 | /** Logger */ |
|
52 | 0 | private static final Log log = LogFactory |
53 | 0 | .getLog(MultiSourceUserInfoManagerImpl.class); |
54 | ||
55 | private List sources; |
|
56 | ||
57 | private PortletRegistry portletRegistry; |
|
58 | ||
59 | /* |
|
60 | * (non-Javadoc) |
|
61 | * |
|
62 | * @see org.apache.jetspeed.userinfo.UserInfoManager#getUserInfoMap(org.apache.pluto.om.common.ObjectID, |
|
63 | * org.apache.jetspeed.request.RequestContext) |
|
64 | */ |
|
65 | public Map getUserInfoMap(ObjectID oid, RequestContext context) |
|
66 | { |
|
67 | ||
68 | try |
|
69 | { |
|
70 | 0 | Map userInfoMap = new HashMap(); |
71 | 0 | Subject subject = context.getSubject(); |
72 | 0 | MutablePortletApplication pa = portletRegistry |
73 | .getPortletApplication(oid); |
|
74 | //System.out.println("*** PA = " + pa); |
|
75 | 0 | if (null == pa) |
76 | { |
|
77 | 0 | log.debug(PortletRequest.USER_INFO + " is set to null"); |
78 | 0 | return null; |
79 | } |
|
80 | 0 | Collection userAttributes = pa.getUserAttributes(); |
81 | 0 | Collection userAttributeRefs = pa.getUserAttributeRefs(); |
82 | 0 | Collection linkedUserAttributes = mapLinkedUserAttributes( |
83 | userAttributes, userAttributeRefs); |
|
84 | 0 | for (Iterator iter = sources.iterator(); iter.hasNext();) |
85 | { |
|
86 | 0 | UserAttributeSource source = (UserAttributeSource) iter.next(); |
87 | Map sourceMap; |
|
88 | ||
89 | 0 | sourceMap = source.getUserAttributeMap(subject, |
90 | linkedUserAttributes, context); |
|
91 | 0 | userInfoMap.putAll(sourceMap); |
92 | 0 | } |
93 | 0 | return userInfoMap; |
94 | 0 | } catch (UserAttributeRetrievalException e) |
95 | { |
|
96 | // Until external api is changed return |
|
97 | 0 | e.printStackTrace(); |
98 | 0 | return null; |
99 | } |
|
100 | } |
|
101 | ||
102 | /** |
|
103 | * @param sources |
|
104 | * The sources to set. |
|
105 | */ |
|
106 | public void setSources(List sources) |
|
107 | { |
|
108 | 0 | this.sources = sources; |
109 | 0 | } |
110 | ||
111 | /** |
|
112 | * @param portletRegistry |
|
113 | * The portletRegistry to set. |
|
114 | */ |
|
115 | public void setPortletRegistry(PortletRegistry portletRegistry) |
|
116 | { |
|
117 | 0 | this.portletRegistry = portletRegistry; |
118 | 0 | } |
119 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |