jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
changeset 10694 cf59e2badd14
parent 1337 e8d6cef36199
child 18780 f47b920867e7
equal deleted inserted replaced
10693:6e9ebed2e783 10694:cf59e2badd14
    69       super(doc, algorithmURI);
    69       super(doc, algorithmURI);
    70 
    70 
    71       this.algorithm = messageDigest;
    71       this.algorithm = messageDigest;
    72    }
    72    }
    73 
    73 
    74    static ThreadLocal instances=new ThreadLocal() {
    74    static ThreadLocal<Map<String, MessageDigest>> instances=new
    75            protected Object initialValue() {
    75        ThreadLocal<Map<String, MessageDigest>>() {
    76                    return new HashMap();
    76            protected Map<String, MessageDigest> initialValue() {
       
    77                return new HashMap<String, MessageDigest>();
    77            };
    78            };
    78    };
    79    };
    79 
    80 
    80    /**
    81    /**
    81     * Factory method for constructing a message digest algorithm by name.
    82     * Factory method for constructing a message digest algorithm by name.
    90           MessageDigest md = getDigestInstance(algorithmURI);
    91           MessageDigest md = getDigestInstance(algorithmURI);
    91       return new MessageDigestAlgorithm(doc, md, algorithmURI);
    92       return new MessageDigestAlgorithm(doc, md, algorithmURI);
    92    }
    93    }
    93 
    94 
    94 private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
    95 private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
    95         MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI);
    96         MessageDigest result= instances.get().get(algorithmURI);
    96         if (result!=null)
    97         if (result!=null)
    97                 return result;
    98                 return result;
    98     String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
    99     String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
    99 
   100 
   100           if (algorithmID == null) {
   101           if (algorithmID == null) {
   119         Object[] exArgs = { algorithmID,
   120         Object[] exArgs = { algorithmID,
   120                                                 ex.getLocalizedMessage() };
   121                                                 ex.getLocalizedMessage() };
   121 
   122 
   122         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
   123         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
   123         }
   124         }
   124       ((Map)instances.get()).put(algorithmURI, md);
   125         instances.get().put(algorithmURI, md);
   125         return md;
   126         return md;
   126 }
   127 }
   127 
   128 
   128    /**
   129    /**
   129     * Returns the actual {@link java.security.MessageDigest} algorithm object
   130     * Returns the actual {@link java.security.MessageDigest} algorithm object