Package java.security.cert

Examples of java.security.cert.Certificate


        try {
            CertificateFactory cf = CertificateFactory.getInstance("X.509",
                    keyStoreProvider);

            is = new FileInputStream(certfile);
            Certificate cert = cf.generateCertificate(is);

            keystore.setCertificateEntry(alias, cert);

            saveKeyStore();
        } finally {
View Full Code Here


                                       boolean useSerialNumber)
            throws WSSecurityException {
        Vector issuerRDN = splitAndTrim(issuer);
        X509Certificate x509cert = null;
        Vector certRDN = null;
        Certificate cert = null;

        try {
            for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
                String alias = (String) e.nextElement();
                Certificate[] certs = keystore.getCertificateChain(alias);
View Full Code Here

     * @throws org.apache.ws.security.WSSecurityException
     *          if problems during keystore handling or wrong certificate (no SKI data)
     */

    public String getAliasForX509Cert(byte[] skiBytes) throws WSSecurityException {
        Certificate cert = null;
        boolean found = false;

        try {
            for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
                String alias = (String) e.nextElement();
View Full Code Here

        Certificate[] certs = null;
        try {
            certs = keystore.getCertificateChain(alias);
            if (certs == null || certs.length == 0) {
                // no cert chain, so lets check if getCertificate gives us a  result.
                Certificate cert = keystore.getCertificate(alias);
                if (cert == null) {
                    return null;
                }
                certs = new Certificate[]{cert};
            }
View Full Code Here

     * @throws org.apache.ws.security.WSSecurityException
     *          if problems during keystore handling or wrong certificate
     */

    public String getAliasForX509CertThumb(byte[] thumb) throws WSSecurityException {
        Certificate cert = null;
        MessageDigest sha = null;

        try {
            sha = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e1) {
            throw new WSSecurityException(
                    0,
                    "noSHA1availabe");
        }
        try {
            for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
                String alias = (String) e.nextElement();
                Certificate[] certs = keystore.getCertificateChain(alias);
                if (certs == null || certs.length == 0) {
                    // no cert chain, so lets check if getCertificate gives us a  result.
                    cert = keystore.getCertificate(alias);
                    if (cert == null) {
                        return null;
                    }
                } else {
                    cert = certs[0];
                }
                if (!(cert instanceof X509Certificate)) {
                    continue;
                }
                sha.reset();
                try {
                    sha.update(cert.getEncoded());
                } catch (CertificateEncodingException e1) {
                    throw new WSSecurityException(
                            WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
                            "encodeError");
                }
View Full Code Here

    public String[] getAliasesForDN(String subjectDN) throws WSSecurityException {

        // Store the aliases found
        Vector aliases = new Vector();

        Certificate cert = null;

        // The DN to search the keystore for
        Vector subjectRDN = splitAndTrim(subjectDN);

        // Look at every certificate in the keystore
View Full Code Here

     * @throws KeyStoreException
     */
    public Certificate getCertificate(String alias, char[] storePassword) throws KeystoreIsLocked, KeyNotFoundException, KeystoreException {
        ensureLoaded(storePassword);
        try {
            Certificate cert = keystore.getCertificate(alias);
            if (cert == null) {
                throw new KeyNotFoundException("Keystore '"+keystoreName+"' does not contain a certificate with alias'"+alias+"'.");
            }
            return cert;
        } catch (KeyStoreException e) {
View Full Code Here

       
        // Read the certificate from disk and generate a java.security.cert.Certificate
        try {
            FileInputStream fin = new FileInputStream(certFile);
            CertificateFactory certFac = CertificateFactory.getInstance("X.509");
            Certificate cert = certFac.generateCertificate(fin);
            fin.close();
            return cert;
        } catch (Exception e) {
            throw new CertificateStoreException("Error while retrieving certificate.", e);
        }
View Full Code Here

    public Certificate getCACertificate() throws CertificateStoreException {
        FileInputStream fin = null;
        try {
            fin = new FileInputStream(new File(storeDir, CA_CERT_FILE));
            CertificateFactory certFac = CertificateFactory.getInstance("X.509");
            Certificate cert = certFac.generateCertificate(fin);
            fin.close();
            return cert;
        } catch (Exception e) {
            throw new CertificateStoreException("Exception in getting CA certificate", e);
        }
View Full Code Here

        if(alias == null && request.getParameterMap().containsKey("alias")) {
            // Happens with an alias ""
            alias = "";
        }
        KeystoreData data = ((KeystoreData) request.getPortletSession(true).getAttribute(KEYSTORE_DATA_PREFIX + id));
        Certificate cert;
        try {
            cert = data.getCertificate(alias);
        } catch (KeystoreException e) {
            throw new PortletException(e);
        }
View Full Code Here

TOP

Related Classes of java.security.cert.Certificate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.