• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.crypto;
2 
3 import java.security.Permission;
4 import java.util.HashSet;
5 import java.util.Set;
6 
7 /**
8  * Permissions that need to be configured if a SecurityManager is used.
9  */
10 public class CryptoServicesPermission
11     extends Permission
12 {
13     /**
14      * Enable the setting of global configuration properties. This permission implies THREAD_LOCAL_CONFIG
15      */
16     public static final String GLOBAL_CONFIG = "globalConfig";
17 
18     /**
19      * Enable the setting of thread local configuration properties.
20      */
21     public static final String THREAD_LOCAL_CONFIG = "threadLocalConfig";
22 
23     /**
24      * Enable the setting of the default SecureRandom.
25      */
26     public static final String DEFAULT_RANDOM = "defaultRandomConfig";
27 
28     /**
29      * Enable the setting of the constraints.
30      */
31     public static final String CONSTRAINTS = "constraints";
32 
33     private final Set<String> actions = new HashSet<String>();
34 
CryptoServicesPermission(String name)35     public CryptoServicesPermission(String name)
36     {
37         super(name);
38 
39         this.actions.add(name);
40     }
41 
implies(Permission permission)42     public boolean implies(Permission permission)
43     {
44         if (permission instanceof CryptoServicesPermission)
45         {
46             CryptoServicesPermission other = (CryptoServicesPermission)permission;
47 
48             if (this.getName().equals(other.getName()))
49             {
50                 return true;
51             }
52 
53             if (this.actions.containsAll(other.actions))
54             {
55                 return true;
56             }
57         }
58 
59         return false;
60     }
61 
equals(Object obj)62     public boolean equals(Object obj)
63     {
64         if (obj instanceof CryptoServicesPermission)
65         {
66             CryptoServicesPermission other = (CryptoServicesPermission)obj;
67 
68             if (this.actions.equals(other.actions))
69             {
70                 return true;
71             }
72         }
73 
74         return false;
75     }
76 
hashCode()77     public int hashCode()
78     {
79         return actions.hashCode();
80     }
81 
getActions()82     public String getActions()
83     {
84         return actions.toString();
85     }
86 }
87