/ 3 years, 10 months ago | Download | Plaintext | Odpowiedz |

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
--- PolicyNodeImpl.java	2010-11-15 02:11:25.000000000 +0100
+++ PolicyNodeImpl-Android.java	2010-11-15 02:07:02.000000000 +0100
@@ -1,12 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 
-package sun.security.provider.certpath;
+package org.apache.harmony.security.tests.support.cert;
 
 import java.security.cert.PolicyNode;
 import java.util.*;
 
-final class PolicyNodeImpl
-    implements PolicyNode
-{
+public class PolicyNodeImpl implements PolicyNode {
 
     private static final String ANY_POLICY = "2.5.29.32.0";
     private PolicyNodeImpl mParent;
@@ -19,91 +33,81 @@
     private int mDepth;
     private boolean isImmutable;
 
-    PolicyNodeImpl(PolicyNodeImpl policynodeimpl, String s, Set set, boolean flag, Set set1, boolean flag1)
-    {
+    public PolicyNodeImpl(PolicyNodeImpl policynodeimpl, String s, Set set, 
+                   boolean flag, Set set1, boolean flag1) {
         isImmutable = false;
         mParent = policynodeimpl;
         mChildren = new HashSet();
-        if(s != null)
+        if(s != null) {
             mValidPolicy = s;
-        else
+        } else {
             mValidPolicy = "";
-        if(set != null)
+        }
+        if(set != null) {
             mQualifierSet = new HashSet(set);
-        else
+        } else {
             mQualifierSet = new HashSet();
+        }
         mCriticalityIndicator = flag;
-        if(set1 != null)
+        if(set1 != null) {
             mExpectedPolicySet = new HashSet(set1);
-        else
+        } else {
             mExpectedPolicySet = new HashSet();
+        }
         mOriginalExpectedPolicySet = !flag1;
-        if(mParent != null)
-        {
+        if(mParent != null) {
             mDepth = mParent.getDepth() + 1;
             mParent.addChild(this);
-        } else
-        {
+        } else {
             mDepth = 0;
         }
     }
 
-    PolicyNodeImpl(PolicyNodeImpl policynodeimpl, PolicyNodeImpl policynodeimpl1)
-    {
+    PolicyNodeImpl(PolicyNodeImpl policynodeimpl, 
+                   PolicyNodeImpl policynodeimpl1) {
         this(policynodeimpl, policynodeimpl1.mValidPolicy, ((Set) (policynodeimpl1.mQualifierSet)), policynodeimpl1.mCriticalityIndicator, ((Set) (policynodeimpl1.mExpectedPolicySet)), false);
     }
 
-    public PolicyNode getParent()
-    {
+    public PolicyNode getParent() {
         return mParent;
     }
 
-    public Iterator getChildren()
-    {
+    public Iterator getChildren() {
         return Collections.unmodifiableSet(mChildren).iterator();
     }
 
-    public int getDepth()
-    {
+    public int getDepth() {
         return mDepth;
     }
 
-    public String getValidPolicy()
-    {
+    public String getValidPolicy() {
         return mValidPolicy;
     }
 
-    public Set getPolicyQualifiers()
-    {
+    public Set getPolicyQualifiers() {
         return Collections.unmodifiableSet(mQualifierSet);
     }
 
-    public Set getExpectedPolicies()
-    {
+    public Set getExpectedPolicies() {
         return Collections.unmodifiableSet(mExpectedPolicySet);
     }
 
-    public boolean isCritical()
-    {
+    public boolean isCritical() {
         return mCriticalityIndicator;
     }
 
-    public String toString()
-    {
+    public String toString() {
         StringBuffer stringbuffer = new StringBuffer(asString());
         for(Iterator iterator = getChildren(); iterator.hasNext(); stringbuffer.append((PolicyNodeImpl)iterator.next()));
         return stringbuffer.toString();
     }
 
-    boolean isImmutable()
-    {
+    boolean isImmutable() {
         return isImmutable;
     }
 
-    void setImmutable()
-    {
-        if(isImmutable)
-            return;
+    void setImmutable() {
+        if(isImmutable)  return;
         PolicyNodeImpl policynodeimpl;
         for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.setImmutable())
             policynodeimpl = (PolicyNodeImpl)iterator.next();
@@ -111,41 +115,33 @@
         isImmutable = true;
     }
 
-    private void addChild(PolicyNodeImpl policynodeimpl)
-    {
-        if(isImmutable)
-        {
+    private void addChild(PolicyNodeImpl policynodeimpl) {
+        if(isImmutable) {
             throw new IllegalStateException("PolicyNode is immutable");
-        } else
-        {
+        } else {
             mChildren.add(policynodeimpl);
             return;
         }
     }
 
-    void addExpectedPolicy(String s)
-    {
+    void addExpectedPolicy(String s) {
         if(isImmutable)
             throw new IllegalStateException("PolicyNode is immutable");
-        if(mOriginalExpectedPolicySet)
-        {
+        if(mOriginalExpectedPolicySet) {
             mExpectedPolicySet.clear();
             mOriginalExpectedPolicySet = false;
         }
         mExpectedPolicySet.add(s);
     }
 
-    void prune(int i)
-    {
+    void prune(int i) {
         if(isImmutable)
             throw new IllegalStateException("PolicyNode is immutable");
         if(mChildren.size() == 0)
             return;
         Iterator iterator = mChildren.iterator();
-        do
-        {
-            if(!iterator.hasNext())
-                break;
+        do {
+            if(!iterator.hasNext())  break;
             PolicyNodeImpl policynodeimpl = (PolicyNodeImpl)iterator.next();
             policynodeimpl.prune(i);
             if(policynodeimpl.mChildren.size() == 0 && i > mDepth + 1)
@@ -153,25 +149,20 @@
         } while(true);
     }
 
-    void deleteChild(PolicyNode policynode)
-    {
-        if(isImmutable)
-        {
+    void deleteChild(PolicyNode policynode) {
+        if(isImmutable) {
             throw new IllegalStateException("PolicyNode is immutable");
-        } else
-        {
+        } else {
             mChildren.remove(policynode);
             return;
         }
     }
 
-    PolicyNodeImpl copyTree()
-    {
+    PolicyNodeImpl copyTree() {
         return copyTree(null);
     }
 
-    private PolicyNodeImpl copyTree(PolicyNodeImpl policynodeimpl)
-    {
+    private PolicyNodeImpl copyTree(PolicyNodeImpl policynodeimpl) {
         PolicyNodeImpl policynodeimpl1 = new PolicyNodeImpl(policynodeimpl, this);
         PolicyNodeImpl policynodeimpl2;
         for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl2.copyTree(policynodeimpl1))
@@ -180,80 +171,67 @@
         return policynodeimpl1;
     }
 
-    Set getPolicyNodes(int i)
-    {
+    Set getPolicyNodes(int i) {
         HashSet hashset = new HashSet();
         getPolicyNodes(i, ((Set) (hashset)));
         return hashset;
     }
 
-    private void getPolicyNodes(int i, Set set)
-    {
-        if(mDepth == i)
-        {
+    private void getPolicyNodes(int i, Set set) {
+        if(mDepth == i) {
             set.add(this);
-        } else
-        {
+        } else {
             PolicyNodeImpl policynodeimpl;
             for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.getPolicyNodes(i, set))
                 policynodeimpl = (PolicyNodeImpl)iterator.next();
-
         }
     }
 
-    Set getPolicyNodesExpected(int i, String s, boolean flag)
-    {
+    Set getPolicyNodesExpected(int i, String s, boolean flag) {
         if(s.equals("2.5.29.32.0"))
             return getPolicyNodes(i);
         else
             return getPolicyNodesExpectedHelper(i, s, flag);
     }
 
-    private Set getPolicyNodesExpectedHelper(int i, String s, boolean flag)
-    {
+    private Set getPolicyNodesExpectedHelper(int i, String s, boolean flag) {
         HashSet hashset = new HashSet();
-        if(mDepth < i)
-        {
+        if(mDepth < i) {
             PolicyNodeImpl policynodeimpl;
             for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesExpectedHelper(i, s, flag)))
                 policynodeimpl = (PolicyNodeImpl)iterator.next();
 
-        } else
-        if(flag)
-        {
+        } else if(flag) {
             if(mExpectedPolicySet.contains("2.5.29.32.0"))
                 hashset.add(this);
-        } else
-        if(mExpectedPolicySet.contains(s))
+        } else if(mExpectedPolicySet.contains(s)) {
             hashset.add(this);
+        }
         return hashset;
     }
 
-    Set getPolicyNodesValid(int i, String s)
-    {
+    Set getPolicyNodesValid(int i, String s) {
         HashSet hashset = new HashSet();
-        if(mDepth < i)
-        {
+        if(mDepth < i) {
             PolicyNodeImpl policynodeimpl;
             for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesValid(i, s)))
                 policynodeimpl = (PolicyNodeImpl)iterator.next();
 
-        } else
-        if(mValidPolicy.equals(s))
+        } else if(mValidPolicy.equals(s)) {
             hashset.add(this);
+        }
         return hashset;
     }
 
-    private static String policyToString(String s)
-    {
-        if(s.equals("2.5.29.32.0"))
+    private static String policyToString(String s) {
+        if(s.equals("2.5.29.32.0")) {
             return "anyPolicy";
-        else
+        } else {
             return s;
     }
+    }
 
-    String asString()
-    {
+    String asString() {
         if(mParent == null)
             return "anyPolicy  ROOT\n";
         StringBuffer stringbuffer = new StringBuffer();
@@ -265,8 +243,7 @@
         stringbuffer.append("  CRIT: ");
         stringbuffer.append(isCritical());
         stringbuffer.append("  EP: ");
-        for(Iterator iterator = getExpectedPolicies().iterator(); iterator.hasNext(); stringbuffer.append(" "))
-        {
+        for(Iterator iterator = getExpectedPolicies().iterator(); iterator.hasNext(); stringbuffer.append(" ")) {
             String s = (String)iterator.next();
             stringbuffer.append(policyToString(s));
         }