Source Code Cross Referenced for IdentityUserBean.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » identity » ui » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » jboss portal 2.6.4 » org.jboss.portal.core.identity.ui.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.core.identity.ui.common;
023:
024:        import java.util.ArrayList;
025:        import java.util.HashMap;
026:        import java.util.HashSet;
027:        import java.util.Iterator;
028:        import java.util.List;
029:        import java.util.Map;
030:        import java.util.ResourceBundle;
031:        import java.util.Set;
032:
033:        import javax.faces.context.FacesContext;
034:
035:        import org.jboss.logging.Logger;
036:        import org.jboss.portal.core.identity.services.IdentityConstants;
037:        import org.jboss.portal.core.identity.services.metadata.UIComponentConfiguration;
038:        import org.jboss.portal.core.identity.ui.IdentityUIUser;
039:        import org.jboss.portal.identity.IdentityException;
040:        import org.jboss.portal.identity.NoSuchUserException;
041:        import org.jboss.portal.identity.User;
042:        import org.jboss.portal.identity.UserModule;
043:        import org.jboss.portal.identity.UserProfileModule;
044:
045:        /**
046:         * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
047:         * @version $Revision$
048:         */
049:        public class IdentityUserBean {
050:
051:            /** The identity user module */
052:            private UserModule userModule;
053:
054:            /** The user profile module */
055:            private UserProfileModule userProfileModule;
056:
057:            /** The core-identity meta data service */
058:            private MetaDataServiceBean metaDataService;
059:
060:            /** the logger */
061:            private static final Logger log = Logger
062:                    .getLogger(IdentityUserBean.class);
063:
064:            public UserModule getUserModule() {
065:                return userModule;
066:            }
067:
068:            public void setUserModule(UserModule userModule) {
069:                this .userModule = userModule;
070:            }
071:
072:            public UserProfileModule getUserProfileModule() {
073:                return userProfileModule;
074:            }
075:
076:            public void setUserProfileModule(UserProfileModule userProfileModule) {
077:                this .userProfileModule = userProfileModule;
078:            }
079:
080:            public MetaDataServiceBean getMetaDataService() {
081:                return metaDataService;
082:            }
083:
084:            public void setMetaDataService(MetaDataServiceBean metaDataService) {
085:                this .metaDataService = metaDataService;
086:            }
087:
088:            /*
089:             * converts the dynamic attribute Map to a map concerning the identity service - UserProfileModule 
090:             */
091:            public Map getProfileMap(Map attributeMap) {
092:                Map profileMap = new HashMap();
093:                Set attributeSet = attributeMap.keySet();
094:                Iterator i = attributeSet.iterator();
095:
096:                while (i.hasNext()) {
097:                    String key = (String) i.next();
098:                    Object value = attributeMap.get(key);
099:                    UIComponentConfiguration uiComponent = (UIComponentConfiguration) this .metaDataService
100:                            .getValue(key).getObject();
101:                    if (uiComponent != null) {
102:                        profileMap.put(uiComponent.getPropertyRef(), value);
103:                    }
104:                }
105:                return profileMap;
106:            }
107:
108:            public void updateProfile(User user, Map attributeMap) {
109:                Map profileMap = this .getProfileMap(attributeMap);
110:                Iterator i = profileMap.keySet().iterator();
111:
112:                while (i.hasNext()) {
113:                    String key = (String) i.next();
114:                    Object value = profileMap.get(key);
115:                    try {
116:                        this .userProfileModule.setProperty(user, key, value);
117:                    } catch (Exception e) {
118:                        log.error("updateProfile failed", e);
119:                    }
120:                }
121:            }
122:
123:            public User findUserByUserName(String username)
124:                    throws IllegalArgumentException, NoSuchUserException,
125:                    IdentityException {
126:                return userModule.findUserByUserName(username);
127:            }
128:
129:            public List findUsersFilteredByUserName(String filter, int offset,
130:                    int limit) throws IllegalArgumentException,
131:                    IdentityException {
132:                Set users = new HashSet();
133:                List list = new ArrayList();
134:
135:                users = userModule.findUsersFilteredByUserName(filter, offset,
136:                        limit);
137:
138:                Iterator i = users.iterator();
139:
140:                while (i.hasNext()) {
141:                    User u = (User) i.next();
142:                    list.add(new IdentityUIUser(u.getUserName()));
143:                }
144:                return list;
145:            }
146:
147:            public void updatePassword(String username, String password)
148:                    throws IllegalArgumentException, IdentityException,
149:                    IdentityException {
150:                User user = userModule.findUserByUserName(username);
151:                user.updatePassword(password);
152:            }
153:
154:            public Object getLocalizedValue(String propertyName, Object value) {
155:                UIComponentConfiguration uiComponent = (UIComponentConfiguration) this .metaDataService
156:                        .getValue(propertyName).getObject();
157:                if (uiComponent.getValues() != null && value instanceof  String
158:                        && uiComponent.getValues().size() > 0) {
159:                    try {
160:                        ResourceBundle bundle = ResourceBundle.getBundle(
161:                                "conf.bundles.Identity", FacesContext
162:                                        .getCurrentInstance().getViewRoot()
163:                                        .getLocale());
164:                        return bundle
165:                                .getString(IdentityConstants.DYNAMIC_VALUE_PREFIX
166:                                        + ((String) value).toUpperCase());
167:                    } catch (Exception e) {
168:                        return value;
169:                    }
170:                }
171:                return value;
172:            }
173:
174:            public Class getPropertyType(String propertyName)
175:                    throws IdentityException, ClassNotFoundException {
176:                UIComponentConfiguration uiComponent = (UIComponentConfiguration) this .metaDataService
177:                        .getValue(propertyName).getObject();
178:                return uiComponent.getPropertyClass();
179:            }
180:
181:            public Object getUserProperty(String username, String propertyName)
182:                    throws IllegalArgumentException, NoSuchUserException,
183:                    IdentityException {
184:                User user = this .findUserByUserName(username);
185:                UIComponentConfiguration uiComponent = (UIComponentConfiguration) this.metaDataService
186:                        .getValue(propertyName).getObject();
187:                return this.userProfileModule.getProperty(user, uiComponent
188:                        .getPropertyRef());
189:            }
190:        }
ww___w__.j__a_va___2___s___.__co__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.