Source Code Cross Referenced for ProviderConfigurationPermission.java in  » Security » Bouncy-Castle » org » bouncycastle » jce » 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 » Security » Bouncy Castle » org.bouncycastle.jce 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.jce;
002:
003:        import org.bouncycastle.util.Strings;
004:
005:        import java.security.BasicPermission;
006:        import java.security.Permission;
007:        import java.util.StringTokenizer;
008:
009:        /**
010:         * A permission class to define what can be done with the ConfigurableProvider interface.
011:         * <p>
012:         * Available permissions are "threadLocalEcImplicitlyCa" and "ecImplicitlyCa" which allow the setting
013:         * of the thread local and global ecImplicitlyCa parameters respectively.
014:         * </p>
015:         * <p>
016:         * Examples:
017:         * <ul>
018:         * <li>ProviderConfigurationPermission("BC"); // enable all permissions</li>
019:         * <li>ProviderConfigurationPermission("BC", "threadLocalEcImplicitlyCa"); // enable thread local only</li>
020:         * <li>ProviderConfigurationPermission("BC", "ecImplicitlyCa"); // enable global setting only</li>
021:         * <li>ProviderConfigurationPermission("BC", "threadLocalEcImplicitlyCa, ecImplicitlyCa"); // enable both explicitly</li>
022:         * </ul>
023:         * <p>
024:         * Note: permission checks are only enforced if a security manager is present.
025:         * </p>
026:         */
027:        public class ProviderConfigurationPermission extends BasicPermission {
028:            private static final int THREAD_LOCAL_EC_IMPLICITLY_CA = 0x01;
029:
030:            private static final int EC_IMPLICITLY_CA = 0x02;
031:            private static final int ALL = THREAD_LOCAL_EC_IMPLICITLY_CA
032:                    | EC_IMPLICITLY_CA;
033:
034:            private static final String THREAD_LOCAL_EC_IMPLICITLY_CA_STR = "threadlocalecimplicitlyca";
035:            private static final String EC_IMPLICITLY_CA_STR = "ecimplicitlyca";
036:            private static final String ALL_STR = "all";
037:
038:            private final String actions;
039:            private final int permissionMask;
040:
041:            public ProviderConfigurationPermission(String name) {
042:                super (name);
043:                this .actions = "all";
044:                this .permissionMask = ALL;
045:            }
046:
047:            public ProviderConfigurationPermission(String name, String actions) {
048:                super (name, actions);
049:                this .actions = actions;
050:                this .permissionMask = calculateMask(actions);
051:            }
052:
053:            private int calculateMask(String actions) {
054:                StringTokenizer tok = new StringTokenizer(Strings
055:                        .toLowerCase(actions), " ,");
056:                int mask = 0;
057:
058:                while (tok.hasMoreTokens()) {
059:                    String s = tok.nextToken();
060:
061:                    if (s.equals(THREAD_LOCAL_EC_IMPLICITLY_CA_STR)) {
062:                        mask |= THREAD_LOCAL_EC_IMPLICITLY_CA;
063:                    } else if (s.equals(EC_IMPLICITLY_CA_STR)) {
064:                        mask |= EC_IMPLICITLY_CA;
065:                    } else if (s.equals(ALL_STR)) {
066:                        mask |= ALL;
067:                    }
068:                }
069:
070:                if (mask == 0) {
071:                    throw new IllegalArgumentException(
072:                            "unknown permissions passed to mask");
073:                }
074:
075:                return mask;
076:            }
077:
078:            public String getActions() {
079:                return actions;
080:            }
081:
082:            public boolean implies(Permission permission) {
083:                if (!(permission instanceof  ProviderConfigurationPermission)) {
084:                    return false;
085:                }
086:
087:                if (!this .getName().equals(permission.getName())) {
088:                    return false;
089:                }
090:
091:                ProviderConfigurationPermission other = (ProviderConfigurationPermission) permission;
092:
093:                return (this .permissionMask & other.permissionMask) == other.permissionMask;
094:            }
095:
096:            public boolean equals(Object obj) {
097:                if (obj == this ) {
098:                    return true;
099:                }
100:
101:                if (obj instanceof  ProviderConfigurationPermission) {
102:                    ProviderConfigurationPermission other = (ProviderConfigurationPermission) obj;
103:
104:                    return this .permissionMask == other.permissionMask
105:                            && this .getName().equals(other.getName());
106:                }
107:
108:                return false;
109:            }
110:
111:            public int hashCode() {
112:                return this.getName().hashCode() + this.permissionMask;
113:            }
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.