01: /*
02: * PublicKeyCertSelector.java
03: *
04: * Created on March 1, 2007, 5:03 PM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package com.sun.xml.wss.impl.misc;
11:
12: import java.security.cert.CertSelector;
13: import java.security.cert.Certificate;
14: import com.sun.xml.wss.logging.LogDomainConstants;
15:
16: import com.sun.xml.wss.XWSSecurityException;
17: import java.security.PublicKey;
18: import java.security.cert.X509Certificate;
19:
20: /**
21: *
22: * @author Kumar Jayanti
23: */
24: public class PublicKeyCertSelector implements CertSelector {
25:
26: PublicKey key = null;
27:
28: /** Creates a new instance of PublicKeyCertSelector */
29: public PublicKeyCertSelector(PublicKey pk) {
30: this .key = pk;
31: }
32:
33: public boolean match(Certificate cert) {
34: if (cert instanceof X509Certificate) {
35: X509Certificate x509Cert = (X509Certificate) cert;
36: if (key.equals(x509Cert.getPublicKey())) {
37: return true;
38: }
39: }
40: return false;
41: }
42:
43: public Object clone() {
44: return new PublicKeyCertSelector(key);
45: }
46: }
|