Advertisement
Guest User

Decompiled Sun PolicyNodeImpl

a guest
Oct 28th, 2010
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 7.83 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3) fieldsfirst nonlb
  4. // Source File Name:   PolicyNodeImpl.java
  5.  
  6. package sun.security.provider.certpath;
  7.  
  8. import java.security.cert.PolicyNode;
  9. import java.util.*;
  10.  
  11. final class PolicyNodeImpl
  12.     implements PolicyNode {
  13.  
  14.     private static final String ANY_POLICY = "2.5.29.32.0";
  15.     private PolicyNodeImpl mParent;
  16.     private HashSet mChildren;
  17.     private String mValidPolicy;
  18.     private HashSet mQualifierSet;
  19.     private boolean mCriticalityIndicator;
  20.     private HashSet mExpectedPolicySet;
  21.     private boolean mOriginalExpectedPolicySet;
  22.     private int mDepth;
  23.     private boolean isImmutable;
  24.  
  25.     PolicyNodeImpl(PolicyNodeImpl policynodeimpl, String s, Set set, boolean flag, Set set1, boolean flag1) {
  26.         isImmutable = false;
  27.         mParent = policynodeimpl;
  28.         mChildren = new HashSet();
  29.         if(s != null)
  30.             mValidPolicy = s;
  31.         else
  32.             mValidPolicy = "";
  33.         if(set != null)
  34.             mQualifierSet = new HashSet(set);
  35.         else
  36.             mQualifierSet = new HashSet();
  37.         mCriticalityIndicator = flag;
  38.         if(set1 != null)
  39.             mExpectedPolicySet = new HashSet(set1);
  40.         else
  41.             mExpectedPolicySet = new HashSet();
  42.         mOriginalExpectedPolicySet = !flag1;
  43.         if(mParent != null) {
  44.             mDepth = mParent.getDepth() + 1;
  45.             mParent.addChild(this);
  46.         } else {
  47.             mDepth = 0;
  48.         }
  49.     }
  50.  
  51.     PolicyNodeImpl(PolicyNodeImpl policynodeimpl, PolicyNodeImpl policynodeimpl1) {
  52.         this(policynodeimpl, policynodeimpl1.mValidPolicy, ((Set) (policynodeimpl1.mQualifierSet)), policynodeimpl1.mCriticalityIndicator, ((Set) (policynodeimpl1.mExpectedPolicySet)), false);
  53.     }
  54.  
  55.     public PolicyNode getParent() {
  56.         return mParent;
  57.     }
  58.  
  59.     public Iterator getChildren() {
  60.         return Collections.unmodifiableSet(mChildren).iterator();
  61.     }
  62.  
  63.     public int getDepth() {
  64.         return mDepth;
  65.     }
  66.  
  67.     public String getValidPolicy() {
  68.         return mValidPolicy;
  69.     }
  70.  
  71.     public Set getPolicyQualifiers() {
  72.         return Collections.unmodifiableSet(mQualifierSet);
  73.     }
  74.  
  75.     public Set getExpectedPolicies() {
  76.         return Collections.unmodifiableSet(mExpectedPolicySet);
  77.     }
  78.  
  79.     public boolean isCritical() {
  80.         return mCriticalityIndicator;
  81.     }
  82.  
  83.     public String toString() {
  84.         StringBuffer stringbuffer = new StringBuffer(asString());
  85.         for(Iterator iterator = getChildren(); iterator.hasNext(); stringbuffer.append((PolicyNodeImpl)iterator.next()));
  86.         return stringbuffer.toString();
  87.     }
  88.  
  89.     boolean isImmutable() {
  90.         return isImmutable;
  91.     }
  92.  
  93.     void setImmutable() {
  94.         if(isImmutable)
  95.             return;
  96.         PolicyNodeImpl policynodeimpl;
  97.         for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.setImmutable())
  98.             policynodeimpl = (PolicyNodeImpl)iterator.next();
  99.  
  100.         isImmutable = true;
  101.     }
  102.  
  103.     private void addChild(PolicyNodeImpl policynodeimpl) {
  104.         if(isImmutable) {
  105.             throw new IllegalStateException("PolicyNode is immutable");
  106.         } else {
  107.             mChildren.add(policynodeimpl);
  108.             return;
  109.         }
  110.     }
  111.  
  112.     void addExpectedPolicy(String s) {
  113.         if(isImmutable)
  114.             throw new IllegalStateException("PolicyNode is immutable");
  115.         if(mOriginalExpectedPolicySet) {
  116.             mExpectedPolicySet.clear();
  117.             mOriginalExpectedPolicySet = false;
  118.         }
  119.         mExpectedPolicySet.add(s);
  120.     }
  121.  
  122.     void prune(int i) {
  123.         if(isImmutable)
  124.             throw new IllegalStateException("PolicyNode is immutable");
  125.         if(mChildren.size() == 0)
  126.             return;
  127.         Iterator iterator = mChildren.iterator();
  128.         do {
  129.             if(!iterator.hasNext())
  130.                 break;
  131.             PolicyNodeImpl policynodeimpl = (PolicyNodeImpl)iterator.next();
  132.             policynodeimpl.prune(i);
  133.             if(policynodeimpl.mChildren.size() == 0 && i > mDepth + 1)
  134.                 iterator.remove();
  135.         } while(true);
  136.     }
  137.  
  138.     void deleteChild(PolicyNode policynode) {
  139.         if(isImmutable) {
  140.             throw new IllegalStateException("PolicyNode is immutable");
  141.         } else {
  142.             mChildren.remove(policynode);
  143.             return;
  144.         }
  145.     }
  146.  
  147.     PolicyNodeImpl copyTree() {
  148.         return copyTree(null);
  149.     }
  150.  
  151.     private PolicyNodeImpl copyTree(PolicyNodeImpl policynodeimpl) {
  152.         PolicyNodeImpl policynodeimpl1 = new PolicyNodeImpl(policynodeimpl, this);
  153.         PolicyNodeImpl policynodeimpl2;
  154.         for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl2.copyTree(policynodeimpl1))
  155.             policynodeimpl2 = (PolicyNodeImpl)iterator.next();
  156.  
  157.         return policynodeimpl1;
  158.     }
  159.  
  160.     Set getPolicyNodes(int i) {
  161.         HashSet hashset = new HashSet();
  162.         getPolicyNodes(i, ((Set) (hashset)));
  163.         return hashset;
  164.     }
  165.  
  166.     private void getPolicyNodes(int i, Set set) {
  167.         if(mDepth == i) {
  168.             set.add(this);
  169.         } else {
  170.             PolicyNodeImpl policynodeimpl;
  171.             for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.getPolicyNodes(i, set))
  172.                 policynodeimpl = (PolicyNodeImpl)iterator.next();
  173.  
  174.         }
  175.     }
  176.  
  177.     Set getPolicyNodesExpected(int i, String s, boolean flag) {
  178.         if(s.equals("2.5.29.32.0"))
  179.             return getPolicyNodes(i);
  180.         else
  181.             return getPolicyNodesExpectedHelper(i, s, flag);
  182.     }
  183.  
  184.     private Set getPolicyNodesExpectedHelper(int i, String s, boolean flag) {
  185.         HashSet hashset = new HashSet();
  186.         if(mDepth < i) {
  187.             PolicyNodeImpl policynodeimpl;
  188.             for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesExpectedHelper(i, s, flag)))
  189.                 policynodeimpl = (PolicyNodeImpl)iterator.next();
  190.  
  191.         } else
  192.         if(flag) {
  193.             if(mExpectedPolicySet.contains("2.5.29.32.0"))
  194.                 hashset.add(this);
  195.         } else
  196.         if(mExpectedPolicySet.contains(s))
  197.             hashset.add(this);
  198.         return hashset;
  199.     }
  200.  
  201.     Set getPolicyNodesValid(int i, String s) {
  202.         HashSet hashset = new HashSet();
  203.         if(mDepth < i) {
  204.             PolicyNodeImpl policynodeimpl;
  205.             for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesValid(i, s)))
  206.                 policynodeimpl = (PolicyNodeImpl)iterator.next();
  207.  
  208.         } else
  209.         if(mValidPolicy.equals(s))
  210.             hashset.add(this);
  211.         return hashset;
  212.     }
  213.  
  214.     private static String policyToString(String s) {
  215.         if(s.equals("2.5.29.32.0"))
  216.             return "anyPolicy";
  217.         else
  218.             return s;
  219.     }
  220.  
  221.     String asString() {
  222.         if(mParent == null)
  223.             return "anyPolicy  ROOT\n";
  224.         StringBuffer stringbuffer = new StringBuffer();
  225.         int i = 0;
  226.         for(int j = getDepth(); i < j; i++)
  227.             stringbuffer.append("  ");
  228.  
  229.         stringbuffer.append(policyToString(getValidPolicy()));
  230.         stringbuffer.append("  CRIT: ");
  231.         stringbuffer.append(isCritical());
  232.         stringbuffer.append("  EP: ");
  233.         for(Iterator iterator = getExpectedPolicies().iterator(); iterator.hasNext(); stringbuffer.append(" ")) {
  234.             String s = (String)iterator.next();
  235.             stringbuffer.append(policyToString(s));
  236.         }
  237.  
  238.         stringbuffer.append(" (");
  239.         stringbuffer.append(getDepth());
  240.         stringbuffer.append(")\n");
  241.         return stringbuffer.toString();
  242.     }
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement