jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
equal
deleted
inserted
replaced
43 static java.util.logging.Logger log = |
43 static java.util.logging.Logger log = |
44 java.util.logging.Logger.getLogger(JCEMapper.class.getName()); |
44 java.util.logging.Logger.getLogger(JCEMapper.class.getName()); |
45 |
45 |
46 |
46 |
47 |
47 |
48 private static Map uriToJCEName; |
48 private static Map<String, String> uriToJCEName; |
49 |
49 |
50 private static Map algorithmsMap; |
50 private static Map<String, Algorithm> algorithmsMap; |
51 |
51 |
52 private static String providerName = null; |
52 private static String providerName = null; |
53 /** |
53 /** |
54 * Method init |
54 * Method init |
55 * |
55 * |
61 loadAlgorithms((Element)mappingElement.getElementsByTagName("Algorithms").item(0)); |
61 loadAlgorithms((Element)mappingElement.getElementsByTagName("Algorithms").item(0)); |
62 } |
62 } |
63 |
63 |
64 static void loadAlgorithms( Element algorithmsEl) { |
64 static void loadAlgorithms( Element algorithmsEl) { |
65 Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm"); |
65 Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm"); |
66 uriToJCEName = new HashMap( algorithms.length * 2); |
66 uriToJCEName = new HashMap<String, String>( algorithms.length * 2); |
67 algorithmsMap = new HashMap( algorithms.length * 2); |
67 algorithmsMap = new HashMap<String, Algorithm>( algorithms.length * 2); |
68 for (int i = 0 ;i < algorithms.length ;i ++) { |
68 for (int i = 0 ;i < algorithms.length ;i ++) { |
69 Element el = algorithms[i]; |
69 Element el = algorithms[i]; |
70 String id = el.getAttribute("URI"); |
70 String id = el.getAttribute("URI"); |
71 String jceName = el.getAttribute("JCEName"); |
71 String jceName = el.getAttribute("JCEName"); |
72 uriToJCEName.put(id, jceName); |
72 uriToJCEName.put(id, jceName); |
74 } |
74 } |
75 |
75 |
76 } |
76 } |
77 |
77 |
78 static Algorithm getAlgorithmMapping(String algoURI) { |
78 static Algorithm getAlgorithmMapping(String algoURI) { |
79 return ((Algorithm)algorithmsMap.get(algoURI)); |
79 return algorithmsMap.get(algoURI); |
80 } |
80 } |
81 |
81 |
82 /** |
82 /** |
83 * Method translateURItoJCEID |
83 * Method translateURItoJCEID |
84 * |
84 * |
88 */ |
88 */ |
89 public static String translateURItoJCEID(String AlgorithmURI) { |
89 public static String translateURItoJCEID(String AlgorithmURI) { |
90 if (log.isLoggable(java.util.logging.Level.FINE)) |
90 if (log.isLoggable(java.util.logging.Level.FINE)) |
91 log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI); |
91 log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI); |
92 |
92 |
93 String jceName = (String) uriToJCEName.get(AlgorithmURI); |
93 String jceName = uriToJCEName.get(AlgorithmURI); |
94 return jceName; |
94 return jceName; |
95 } |
95 } |
96 |
96 |
97 /** |
97 /** |
98 * Method getAlgorithmClassFromURI |
98 * Method getAlgorithmClassFromURI |
104 */ |
104 */ |
105 public static String getAlgorithmClassFromURI(String AlgorithmURI) { |
105 public static String getAlgorithmClassFromURI(String AlgorithmURI) { |
106 if (log.isLoggable(java.util.logging.Level.FINE)) |
106 if (log.isLoggable(java.util.logging.Level.FINE)) |
107 log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI); |
107 log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI); |
108 |
108 |
109 return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass; |
109 return (algorithmsMap.get(AlgorithmURI)).algorithmClass; |
110 } |
110 } |
111 |
111 |
112 /** |
112 /** |
113 * Returns the keylength in bit for a particular algorithm. |
113 * Returns the keylength in bit for a particular algorithm. |
114 * |
114 * |
115 * @param AlgorithmURI |
115 * @param AlgorithmURI |
116 * @return The length of the key used in the alogrithm |
116 * @return The length of the key used in the alogrithm |
117 */ |
117 */ |
118 public static int getKeyLengthFromURI(String AlgorithmURI) { |
118 public static int getKeyLengthFromURI(String AlgorithmURI) { |
119 return Integer.parseInt(((Algorithm) algorithmsMap.get(AlgorithmURI)).keyLength); |
119 return Integer.parseInt((algorithmsMap.get(AlgorithmURI)).keyLength); |
120 } |
120 } |
121 |
121 |
122 /** |
122 /** |
123 * Method getJCEKeyAlgorithmFromURI |
123 * Method getJCEKeyAlgorithmFromURI |
124 * |
124 * |
126 * @return The KeyAlgorithm for the given URI. |
126 * @return The KeyAlgorithm for the given URI. |
127 * |
127 * |
128 */ |
128 */ |
129 public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) { |
129 public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) { |
130 |
130 |
131 return ((Algorithm) algorithmsMap.get(AlgorithmURI)).requiredKey; |
131 return (algorithmsMap.get(AlgorithmURI)).requiredKey; |
132 |
132 |
133 } |
133 } |
134 |
134 |
135 /** |
135 /** |
136 * Gets the default Provider for obtaining the security algorithms |
136 * Gets the default Provider for obtaining the security algorithms |