Source Code Cross Referenced for BaseProtectable.java in  » Portal » stringbeans-3.5 » com » nabhinc » portal » model » 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 » stringbeans 3.5 » com.nabhinc.portal.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2006 Nabh Information Systems, Inc. 
003:         * 
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:        package com.nabhinc.portal.model;
020:
021:        import javax.servlet.ServletException;
022:        import javax.servlet.http.HttpServletRequest;
023:        import javax.xml.bind.Unmarshaller;
024:        import javax.xml.bind.annotation.XmlElement;
025:        import javax.xml.bind.annotation.XmlTransient;
026:
027:        import com.nabhinc.condition.Condition;
028:        import com.nabhinc.condition.ConditionFactory;
029:        import com.nabhinc.condition.ConditionHolder;
030:        import com.nabhinc.core.Group;
031:        import com.nabhinc.core.Constants;
032:        import com.nabhinc.util.EncryptionUtil;
033:        import com.nabhinc.util.StringUtil;
034:
035:        /**
036:         *
037:         *
038:         * @author Padmanabh Dabke
039:         * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
040:         */
041:        public abstract class BaseProtectable implements  Protectable, Group {
042:
043:            @XmlElement(name="password")
044:            private String bpPassword = null;
045:
046:            @XmlTransient
047:            private Condition bpViewPermission = null;
048:
049:            @XmlTransient
050:            private Condition bpEditPermission = ConditionFactory.OWNER_CONDITION;
051:
052:            @XmlTransient
053:            private Condition bpDeletePermission = ConditionFactory.OWNER_CONDITION;
054:
055:            @XmlTransient
056:            private Condition bpAdminPermission = ConditionFactory.OWNER_CONDITION;
057:
058:            @XmlTransient
059:            private Condition bpCreatePsitePermission = ConditionFactory.OWNER_CONDITION;
060:
061:            @XmlElement(name="view-condition")
062:            private ConditionHolder bpViewPermHolder = null;
063:
064:            @XmlElement(name="edit-condition")
065:            private ConditionHolder bpEditPermHolder = null;
066:
067:            @XmlElement(name="delete-condition")
068:            private ConditionHolder bpDeletePermHolder = null;
069:
070:            @XmlElement(name="admin-condition")
071:            private ConditionHolder bpAdminPermHolder = null;
072:
073:            @XmlElement(name="create-psite-condition")
074:            private ConditionHolder bpCreatePsitePermHolder = null;
075:
076:            private transient boolean bpViewLoginRequired = false;
077:
078:            private transient boolean bpEditLoginRequired = false;
079:
080:            private transient boolean bpDeleteLoginRequired = false;
081:
082:            private transient boolean bpAdminLoginRequired = false;
083:
084:            private transient boolean bpCreatePsiteLoginRequired = false;
085:
086:            public abstract String getOwnerName();
087:
088:            @XmlTransient
089:            public String getPassword() {
090:                return bpPassword;
091:            }
092:
093:            public void setPassword(String p) {
094:                if (StringUtil.isNotNullOrEmpty(p))
095:                    p = EncryptionUtil.encrypt(p, "MD5");
096:                else
097:                    p = null;
098:                this .bpPassword = p;
099:            }
100:
101:            public boolean checkPassword(String password) {
102:                if (this .bpPassword == null) {
103:                    return true;
104:                } else {
105:                    if (EncryptionUtil.encrypt(password, "MD5").equals(
106:                            this .bpPassword))
107:                        return true;
108:                    else
109:                        return false;
110:                }
111:            }
112:
113:            public boolean isPasswordProtected() {
114:                return this .bpPassword != null;
115:            }
116:
117:            @XmlTransient
118:            public Condition getEditPermission() {
119:                return bpEditPermission;
120:            }
121:
122:            public void setEditPermission(Condition bpEditPermission) {
123:                this .bpEditPermission = bpEditPermission;
124:                this .bpEditPermHolder = new ConditionHolder(bpEditPermission);
125:                if (bpEditPermission == null)
126:                    bpEditLoginRequired = false;
127:                else
128:                    bpEditLoginRequired = bpEditPermission.requiresLogin();
129:            }
130:
131:            @XmlTransient
132:            public Condition getAdminPermission() {
133:                return bpAdminPermission;
134:            }
135:
136:            public void setAdminPermission(Condition bpAdminPermission) {
137:                this .bpAdminPermission = bpAdminPermission;
138:                this .bpAdminPermHolder = new ConditionHolder(bpAdminPermission);
139:                if (bpAdminPermission == null)
140:                    bpAdminLoginRequired = false;
141:                else
142:                    bpAdminLoginRequired = bpAdminPermission.requiresLogin();
143:            }
144:
145:            @XmlTransient
146:            public Condition getViewPermission() {
147:                return bpViewPermission;
148:            }
149:
150:            public void setViewPermission(Condition bpViewPermission) {
151:                this .bpViewPermission = bpViewPermission;
152:                this .bpViewPermHolder = new ConditionHolder(bpViewPermission);
153:                if (bpViewPermission == null)
154:                    bpViewLoginRequired = false;
155:                else
156:                    bpViewLoginRequired = bpViewPermission.requiresLogin();
157:            }
158:
159:            @XmlTransient
160:            public Condition getDeletePermission() {
161:                return bpDeletePermission;
162:            }
163:
164:            public void setDeletePermission(Condition bpDeletePermission) {
165:                this .bpDeletePermission = bpDeletePermission;
166:                this .bpDeletePermHolder = new ConditionHolder(
167:                        bpDeletePermission);
168:            }
169:
170:            @XmlTransient
171:            public Condition getCreatePsitePermission() {
172:                return bpCreatePsitePermission;
173:            }
174:
175:            public void setCreatePsitePermission(
176:                    Condition bpCreatePsitePermission) {
177:                this .bpCreatePsitePermission = bpCreatePsitePermission;
178:                this .bpCreatePsitePermHolder = new ConditionHolder(
179:                        bpCreatePsitePermission);
180:                if (bpCreatePsitePermission == null)
181:                    bpCreatePsiteLoginRequired = false;
182:                else
183:                    bpCreatePsiteLoginRequired = bpCreatePsitePermission
184:                            .requiresLogin();
185:            }
186:
187:            public boolean isEditable(HttpServletRequest request)
188:                    throws ServletException {
189:                if (request.isUserInRole(Constants.ADMIN_ROLE)
190:                        || getOwnerName().equals(request.getRemoteUser()))
191:                    return true;
192:                if (this .bpEditPermission == null)
193:                    return true;
194:                return this .bpEditPermission.isSatisfied(request, this );
195:            }
196:
197:            public boolean isAdminable(HttpServletRequest request)
198:                    throws ServletException {
199:                if (request.isUserInRole(Constants.ADMIN_ROLE)
200:                        || getOwnerName().equals(request.getRemoteUser()))
201:                    return true;
202:                if (this .bpAdminPermission == null)
203:                    return true;
204:                return this .bpAdminPermission.isSatisfied(request, this );
205:            }
206:
207:            public boolean isViewable(HttpServletRequest request)
208:                    throws ServletException {
209:                if (request.isUserInRole(Constants.ADMIN_ROLE)
210:                        || getOwnerName().equals(request.getRemoteUser()))
211:                    return true;
212:                if (this .bpViewPermission == null)
213:                    return true;
214:                return this .bpViewPermission.isSatisfied(request, this );
215:            }
216:
217:            public boolean isDeletable(HttpServletRequest request)
218:                    throws ServletException {
219:                if (request.isUserInRole(Constants.ADMIN_ROLE)
220:                        || getOwnerName().equals(request.getRemoteUser()))
221:                    return true;
222:                if (this .bpDeletePermission == null)
223:                    return true;
224:                return this .bpDeletePermission.isSatisfied(request, this );
225:            }
226:
227:            public boolean isPsiteCreatable(HttpServletRequest request)
228:                    throws ServletException {
229:                if (request.isUserInRole(Constants.ADMIN_ROLE))
230:                    return true;
231:                if (this .bpCreatePsitePermission == null)
232:                    return true;
233:                return this .bpCreatePsitePermission.isSatisfied(request, this );
234:            }
235:
236:            public void afterUnmarshal(Unmarshaller um, Object parent) {
237:
238:                if (bpViewPermHolder != null)
239:                    bpViewPermission = bpViewPermHolder.condition;
240:                if (bpEditPermHolder != null)
241:                    bpEditPermission = bpEditPermHolder.condition;
242:                if (bpDeletePermHolder != null)
243:                    bpDeletePermission = bpDeletePermHolder.condition;
244:                if (bpAdminPermHolder != null)
245:                    bpAdminPermission = bpAdminPermHolder.condition;
246:                if (bpCreatePsitePermHolder != null)
247:                    bpCreatePsitePermission = bpCreatePsitePermHolder.condition;
248:
249:                if (bpViewPermission != null)
250:                    bpViewLoginRequired = bpViewPermission.requiresLogin();
251:                if (bpEditPermission != null)
252:                    bpEditLoginRequired = bpEditPermission.requiresLogin();
253:                if (bpDeletePermission != null)
254:                    bpDeleteLoginRequired = bpDeletePermission.requiresLogin();
255:                if (bpAdminPermission != null)
256:                    bpAdminLoginRequired = bpAdminPermission.requiresLogin();
257:                if (bpCreatePsitePermission != null)
258:                    bpCreatePsiteLoginRequired = bpCreatePsitePermission
259:                            .requiresLogin();
260:            }
261:
262:            public boolean requiresLoginForView() {
263:                return bpViewLoginRequired;
264:            }
265:
266:            public boolean requiresLoginForEdit() {
267:                return bpEditLoginRequired;
268:            }
269:
270:            public boolean requiresLoginForDelete() {
271:                return bpDeleteLoginRequired;
272:            }
273:
274:            public boolean requiresLoginForAdmin() {
275:                return bpAdminLoginRequired;
276:            }
277:
278:            public boolean requiresLoginForCreatePsite() {
279:                return bpCreatePsiteLoginRequired;
280:            }
281:
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.