Source Code Cross Referenced for RemoteReflectionSecurityManager.java in  » J2EE » Sofia » com » salmonllc » remote » server » 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 » J2EE » Sofia » com.salmonllc.remote.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.salmonllc.remote.server;
002:
003:        import com.salmonllc.remote.Reflect;
004:
005:        import java.util.Vector;
006:
007:        /**
008:         * Created by IntelliJ IDEA.
009:         * User: Fred Cahill
010:         * Date: Sep 29, 2004
011:         * Time: 9:27:06 AM
012:         * To change this template use Options | File Templates.
013:         */
014:        /*
015:         * This class is the default RemoteReflectionSecurityPolicy instance assigned to RemoteReflector servlet.
016:         */
017:        public class RemoteReflectionSecurityManager implements 
018:                RemoteReflectionSecurityPolicy {
019:
020:            private class ClassMethod {
021:                String _cls;
022:                String _method;
023:
024:                ClassMethod(String sClass, String sMethod) {
025:                    _cls = sClass;
026:                    _method = sMethod;
027:                }
028:
029:                public boolean equals(Object obj) {
030:                    if (obj != null && obj instanceof  ClassMethod) {
031:                        return (((ClassMethod) obj).getClassName().equals(_cls) && ((ClassMethod) obj)
032:                                .getMethod().equals(_method));
033:                    }
034:                    return false;
035:                }
036:
037:                public String getClassName() {
038:                    return _cls;
039:                }
040:
041:                public String getMethod() {
042:                    return _method;
043:                }
044:            }
045:
046:            private Vector vAllowedClasses = new Vector();
047:            private Vector vAllowedClassesMethods = new Vector();
048:
049:            /*
050:             * Checks to see if Instantiation is allowed for the passed class.
051:             * @param cl java.lang.Class The class to check to see if allowed to instantiate.
052:             * @return boolean indicates wheather the class is allowed to be instantiated by the RemoteReflector Servlet
053:             */
054:            public boolean isInstantiationAllowed(Class cl) {
055:                Class[] interfaces = cl.getInterfaces();
056:                if (interfaces != null) {
057:                    for (int i = 0; i < interfaces.length; i++) {
058:                        if (interfaces[i].getName().equals(
059:                                Reflect.class.getName()))
060:                            return true;
061:                        if (vAllowedClasses.contains(cl.getName()))
062:                            return true;
063:                    }
064:                }
065:                return false;
066:            }
067:
068:            /*
069:             * Checks to see if Instantiation is allowed for the passed class.
070:             * @param obj java.lang.Object The object for which you want to execute the method on.
071:             * @param sMethod java.lang.String The method you want to check if you are allowed to execute.
072:             * @return boolean indicates wheather the method is allowed to be executed on the passed object by the RemoteReflector Servlet
073:             */
074:            public boolean isMethodCallAllowed(Object obj, String sMethod) {
075:                if (obj instanceof  Reflect)
076:                    return true;
077:                if (vAllowedClassesMethods.contains(new ClassMethod(obj
078:                        .getClass().getName(), sMethod)))
079:                    return true;
080:                return false;
081:            }
082:
083:            /*
084:             * Specifies a class to allow instantiation of via RemoteReflector.
085:             * @param cl java.lang.Class The class to allow to instantiate.
086:             */
087:            public void allowInstantiation(Class cl) {
088:                if (!vAllowedClasses.contains(cl.getName()))
089:                    vAllowedClasses.addElement(cl.getName());
090:            }
091:
092:            /*
093:             * Specifies a class and method to allow execution of via RemoteReflector.
094:             * @param cl java.lang.Class The class to allow to execute specified method on.
095:             * @param sMethod java.lang.String The method to which to allow execution of.
096:             */
097:            public void allowMethodCall(Class cl, String sMethod) {
098:                ClassMethod cm = new ClassMethod(cl.getName(), sMethod);
099:                if (!vAllowedClassesMethods.contains(cm))
100:                    vAllowedClassesMethods.addElement(cm);
101:            }
102:
103:            /*
104:             * Removes the specified class from the allowed classes to be instantiated via RemoteReflector.
105:             * @param cl java.lang.Class The class to remove from allowed classes.
106:             */
107:            public void removeInstantiation(Class cl) {
108:                vAllowedClasses.removeElement(cl.getName());
109:            }
110:
111:            /*
112:             * Specifies a class and method to remove from allowed class/methods.
113:             * @param cl java.lang.Class The class to which the method belongs.
114:             * @param sMethod java.lang.String The method to remove from allowed.
115:             */
116:            public void removeMethodCall(Class cl, String sMethod) {
117:                vAllowedClassesMethods.removeElement(new ClassMethod(cl
118:                        .getName(), sMethod));
119:            }
120:
121:            /**
122:             * @return Returns the Vector of Allowed classes.
123:             */
124:            public Vector getAllowedClasses() {
125:                return vAllowedClasses;
126:            }
127:
128:            /**
129:             * @param Sets the Vector of allowed classes
130:             */
131:            public void setAllowedClasses(Vector allowedClasses) {
132:                vAllowedClasses = allowedClasses;
133:            }
134:
135:            /**
136:             * @return Returns the vector of Allowed Class Methods.
137:             */
138:            public Vector getAllowedClassesMethods() {
139:                return vAllowedClassesMethods;
140:            }
141:
142:            /**
143:             * @param allowedClassesMethods A vector of Allowed Class Methods to set.
144:             */
145:            public void setAllowedClassesMethods(Vector allowedClassesMethods) {
146:                vAllowedClassesMethods = allowedClassesMethods;
147:            }
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.