equal
deleted
inserted
replaced
93 // null once provider is selected |
93 // null once provider is selected |
94 private Service firstService; |
94 private Service firstService; |
95 |
95 |
96 // remaining services to try in provider selection |
96 // remaining services to try in provider selection |
97 // null once provider is selected |
97 // null once provider is selected |
98 private Iterator serviceIterator; |
98 private Iterator<Service> serviceIterator; |
99 |
99 |
100 private final Object lock; |
100 private final Object lock; |
101 |
101 |
102 /** |
102 /** |
103 * Creates a MAC object. |
103 * Creates a MAC object. |
112 this.algorithm = algorithm; |
112 this.algorithm = algorithm; |
113 serviceIterator = null; |
113 serviceIterator = null; |
114 lock = null; |
114 lock = null; |
115 } |
115 } |
116 |
116 |
117 private Mac(Service s, Iterator t, String algorithm) { |
117 private Mac(Service s, Iterator<Service> t, String algorithm) { |
118 firstService = s; |
118 firstService = s; |
119 serviceIterator = t; |
119 serviceIterator = t; |
120 this.algorithm = algorithm; |
120 this.algorithm = algorithm; |
121 lock = new Object(); |
121 lock = new Object(); |
122 } |
122 } |
161 * |
161 * |
162 * @see java.security.Provider |
162 * @see java.security.Provider |
163 */ |
163 */ |
164 public static final Mac getInstance(String algorithm) |
164 public static final Mac getInstance(String algorithm) |
165 throws NoSuchAlgorithmException { |
165 throws NoSuchAlgorithmException { |
166 List services = GetInstance.getServices("Mac", algorithm); |
166 List<Service> services = GetInstance.getServices("Mac", algorithm); |
167 // make sure there is at least one service from a signed provider |
167 // make sure there is at least one service from a signed provider |
168 Iterator t = services.iterator(); |
168 Iterator<Service> t = services.iterator(); |
169 while (t.hasNext()) { |
169 while (t.hasNext()) { |
170 Service s = (Service)t.next(); |
170 Service s = t.next(); |
171 if (JceSecurity.canUseProvider(s.getProvider()) == false) { |
171 if (JceSecurity.canUseProvider(s.getProvider()) == false) { |
172 continue; |
172 continue; |
173 } |
173 } |
174 return new Mac(s, t, algorithm); |
174 return new Mac(s, t, algorithm); |
175 } |
175 } |
286 Service s; |
286 Service s; |
287 if (firstService != null) { |
287 if (firstService != null) { |
288 s = firstService; |
288 s = firstService; |
289 firstService = null; |
289 firstService = null; |
290 } else { |
290 } else { |
291 s = (Service)serviceIterator.next(); |
291 s = serviceIterator.next(); |
292 } |
292 } |
293 if (JceSecurity.canUseProvider(s.getProvider()) == false) { |
293 if (JceSecurity.canUseProvider(s.getProvider()) == false) { |
294 continue; |
294 continue; |
295 } |
295 } |
296 try { |
296 try { |
329 Service s; |
329 Service s; |
330 if (firstService != null) { |
330 if (firstService != null) { |
331 s = firstService; |
331 s = firstService; |
332 firstService = null; |
332 firstService = null; |
333 } else { |
333 } else { |
334 s = (Service)serviceIterator.next(); |
334 s = serviceIterator.next(); |
335 } |
335 } |
336 // if provider says it does not support this key, ignore it |
336 // if provider says it does not support this key, ignore it |
337 if (s.supportsParameter(key) == false) { |
337 if (s.supportsParameter(key) == false) { |
338 continue; |
338 continue; |
339 } |
339 } |