50 |
50 |
51 public SecurityPolicyPermission( |
51 public SecurityPolicyPermission( |
52 String name, |
52 String name, |
53 String target, |
53 String target, |
54 String actionList, |
54 String actionList, |
|
55 int type, |
55 SecurityPolicyPermissionSettings settings) |
56 SecurityPolicyPermissionSettings settings) |
56 { |
57 { |
57 this.name = name; |
58 this.name = name; |
58 this.target = target; |
59 this.target = target; |
59 this.actionList = actionList; |
60 this.actionList = actionList; |
60 this.type = USER_TYPE; |
61 this.type = type; |
61 this.settings = settings; |
62 this.settings = settings; |
|
63 } |
|
64 |
|
65 public SecurityPolicyPermission( |
|
66 String name, |
|
67 String target, |
|
68 String actionList, |
|
69 SecurityPolicyPermissionSettings settings) |
|
70 { |
|
71 this(name, target, actionList, USER_TYPE, settings); |
62 } |
72 } |
63 |
73 |
64 public SecurityPolicyPermission( |
74 public SecurityPolicyPermission( |
65 String name, |
75 String name, |
66 String target, |
76 String target, |
67 String actionList, |
77 String actionList, |
68 int type) |
78 int type) |
69 { |
79 { |
70 this.name = name; |
80 this(name, target, actionList, type, null); |
71 this.target = target; |
|
72 this.actionList = actionList; |
|
73 // Check type |
|
74 this.type = type; |
|
75 } |
81 } |
76 |
82 |
77 public int getType() |
83 public int getType() |
78 { |
84 { |
79 return type; |
85 return type; |
143 oStream.write(settings.getBytes()); |
149 oStream.write(settings.getBytes()); |
144 } |
150 } |
145 return oStream.toByteArray(); |
151 return oStream.toByteArray(); |
146 } |
152 } |
147 |
153 |
148 public static SecurityPolicyPermission getFromBytes(byte[] buf) |
154 public static SecurityPolicyPermission getFromBytes(byte[] buf, boolean activeSettings) |
149 { |
155 { |
150 int type = buf[SecurityPolicy.index]; |
156 int type = buf[SecurityPolicy.index]; |
151 SecurityPolicy.index++; |
157 SecurityPolicy.index++; |
152 int nameLen = buf[SecurityPolicy.index]; |
158 int nameLen = buf[SecurityPolicy.index]; |
153 SecurityPolicy.index++; |
159 SecurityPolicy.index++; |
154 String name = new String(buf, SecurityPolicy.index, nameLen); |
160 String name = new String(buf, SecurityPolicy.index, nameLen); |
155 SecurityPolicy.index += nameLen; |
161 SecurityPolicy.index += nameLen; |
156 String target = readString(buf); |
162 String target = readString(buf); |
157 String actionList = readString(buf); |
163 String actionList = readString(buf); |
158 if (type == USER_TYPE) |
164 if (type == USER_TYPE || type == USER_ASSIGNED_TYPE) |
159 { |
165 { |
160 return new SecurityPolicyPermission(name, target, actionList, |
166 return new SecurityPolicyPermission( |
161 SecurityPolicyPermissionSettings.getFromBytes(buf)); |
167 name, target, actionList, type, |
|
168 SecurityPolicyPermissionSettings.getFromBytes( |
|
169 buf, activeSettings)); |
162 } |
170 } |
163 return new SecurityPolicyPermission(name, target, actionList, type); |
171 return new SecurityPolicyPermission(name, target, actionList, type); |
164 } |
172 } |
165 |
173 |
166 private void writeString(String str, ByteArrayOutputStream oStream) throws IOException |
174 private void writeString(String str, ByteArrayOutputStream oStream) throws IOException |