List of usage examples for java.util Vector equals
public synchronized boolean equals(Object o)
From source file:org.wso2.carbon.security.util.ServerCrypto.java
private String getAliasForX509Cert(String issuer, BigInteger serialNumber, boolean useSerialNumber, KeyStore ks) throws WSSecurityException { Vector issuerRDN = splitAndTrim(issuer); X509Certificate x509cert;/*from www .j av a 2 s . c om*/ Vector certRDN; Certificate cert; try { for (Enumeration e = ks.aliases(); e.hasMoreElements();) { String alias = (String) e.nextElement(); Certificate[] certs = this.getCertificates(alias); if (certs == null || certs.length == 0) { return null; } else { cert = certs[0]; } if (!(cert instanceof X509Certificate)) { continue; } x509cert = (X509Certificate) cert; if (useSerialNumber && x509cert.getSerialNumber().compareTo(serialNumber) == 0) { certRDN = splitAndTrim(x509cert.getIssuerDN().getName()); if (certRDN.equals(issuerRDN)) { return alias; } } } } catch (KeyStoreException e) { throw new WSSecurityException(WSSecurityException.FAILURE, "keystore"); } return null; }
From source file:org.wso2.carbon.webapp.ext.cxf.crypto.CXFServerCrypto.java
/** * @see org.apache.ws.security.components.crypto.Crypto#getAliasesForDN(String) *//*from w w w .j a v a2 s .c o m*/ public String[] getAliasesForDN(String subjectDN) throws WSSecurityException { // Store the aliases found Vector aliases = new Vector(); Certificate cert; // The DN to search the keystore for Vector subjectRDN = splitAndTrim(subjectDN); // Look at every certificate in the keystore try { for (Enumeration e = keystore.aliases(); e.hasMoreElements();) { String alias = (String) e.nextElement(); Certificate[] certs = this.getCertificates(alias); if (certs == null || certs.length == 0) { return null; } else { cert = certs[0]; } if (cert instanceof X509Certificate) { Vector foundRDN = splitAndTrim(((X509Certificate) cert).getSubjectDN().getName()); if (subjectRDN.equals(foundRDN)) { aliases.add(alias); } } } } catch (KeyStoreException e) { throw new WSSecurityException(WSSecurityException.FAILURE, "keystore"); } // Convert the vector into an array String[] result = new String[aliases.size()]; for (int i = 0; i < aliases.size(); i++) { result[i] = (String) aliases.elementAt(i); } return result; }