Package java.security.cert

Examples of java.security.cert.CertSelector


     * CertStoreSpi
     */
    public void testCertStoreSpi01() throws InvalidAlgorithmParameterException,
            CertStoreException {
        CertStoreSpi certStoreSpi = null;
        CertSelector certSelector = new tmpCertSelector();//new
                                                          // X509CertSelector();
        CRLSelector crlSelector = new tmpCRLSelector();//new X509CRLSelector();
        try {
            certStoreSpi = new MyCertStoreSpi(null);
            fail("InvalidAlgorithmParameterException must be thrown");
View Full Code Here


            log.log(Level.SEVERE, LogStringsMessages.WSS_1526_FAILEDTO_GETCERTIFICATE(), e);
            throw new RuntimeException(e);
        }
        //now search in CertStore if present
        if (this.certStore != null) {
            CertSelector selector = null;
            /* if (this.certSelectorClass != null) {
            HashMap props = new HashMap();
            props.putAll(runtimeProps);
            props.put(XWSSConstants.SUBJECTKEYIDENTIFIER, ski);
            selector = XWSSUtil.getCertSelector(certSelectorClass, props);
View Full Code Here

            if (getTrustStore(runtimeProps) == null && getCertStore(runtimeProps) == null) {
                return null;
            }
            //now search in CertStore if present
            if (this.certStore != null) {
                CertSelector selector = null;
                /*if (this.certSelectorClass != null) {
                Map props = new HashMap();
                props.putAll(runtimeProps);
                props.put(XWSSConstants.ISSUERNAME, issuerName);
                props.put(XWSSConstants.ISSUERSERIAL, serialNumber);
View Full Code Here

            currentAlias = peerEntityAlias;
        } else {
            //try to locate in certstore using user supplied CertSelector
            getCertStore(context);
            if (certStore != null) {
                CertSelector selector = null;
                if (this.certSelectorClass != null) {
                    selector = XWSSUtil.getCertSelector(certSelectorClass, context);
                }
                if (selector != null) {
                    Collection certs = null;
                    try {
                        certs = certStore.getCertificates(selector);
                    } catch (CertStoreException ex) {
                        log.log(Level.SEVERE, LogStringsMessages.WSS_1526_FAILEDTO_GETCERTIFICATE(), ex);
                        throw new RuntimeException(ex);
                    }
                    if (certs.size() > 0) {
                        req.setX509Certificate((X509Certificate) certs.iterator().next());
                        return;
                    }
                }
            }

            if (getTrustStore(context) != null) {
                if (this.truststoreCertSelectorClass != null) {
                    CertSelector selector = XWSSUtil.getCertSelector(this.truststoreCertSelectorClass, context);
                    if (selector != null) {
                        Enumeration aliases = null;
                        try {
                            aliases = trustStore.aliases();
                        } catch (KeyStoreException ex) {
                            log.log(Level.SEVERE, LogStringsMessages.WSS_1526_FAILEDTO_GETCERTIFICATE(), ex);
                            throw new RuntimeException(ex);
                        }
                        while (aliases.hasMoreElements()) {
                            String currAlias = (String) aliases.nextElement();
                            Certificate thisCertificate = null;
                            try {
                                thisCertificate = trustStore.getCertificate(currAlias);
                            } catch (KeyStoreException ex) {
                                log.log(Level.SEVERE, LogStringsMessages.WSS_1526_FAILEDTO_GETCERTIFICATE(), ex);
                                throw new RuntimeException(ex);
                            }
                            if ((thisCertificate instanceof X509Certificate) && selector.match(thisCertificate)) {
                                req.setX509Certificate((X509Certificate) thisCertificate);
                                return;
                            }
                        }
                    }
View Full Code Here

            log.log(Level.SEVERE, LogStringsMessages.WSS_1526_FAILEDTO_GETCERTIFICATE(), e);
            throw new RuntimeException(e);
        }
        //now search in CertStore if present
        if (this.certStore != null) {
            CertSelector selector = null;
            /*if (this.certSelectorClass != null) {
            Map props = new HashMap();
            props.putAll(runtimeProps);
            props.put(XWSSConstants.THUMBPRINT, ski);
            selector = XWSSUtil.getCertSelector(certSelectorClass, props);
View Full Code Here

        } catch (Exception e) {
            log.log(Level.SEVERE, LogStringsMessages.WSS_1526_FAILEDTO_GETCERTIFICATE(), e);
            throw new RuntimeException(e);
        }
        if (certStore != null) {
            CertSelector selector = null;
            /*if (this.certSelectorClass != null) {
            Map props = new HashMap();
            props.putAll(runtimeProps);
            props.put(XWSSConstants.PUBLICKEY, pk);
            selector = XWSSUtil.getCertSelector(certSelectorClass, props);
View Full Code Here

        }
        // if not found, look in CertStore followed by TrustStore
        CertStore certStore = csCallback.getCertStore();
        if (certStore != null) {
            CertSelector selector = null;
            /*if (this.certSelectorClass != null) {
                HashMap props = new HashMap();
                props.putAll(context);
                props.put(XWSSConstants.SUBJECTKEYIDENTIFIER, keyIdMatch);
                selector = XWSSUtil.getCertSelector(certSelectorClass, props);
View Full Code Here

        }
        // if not found, look in CertStore followed by TrustStore
        CertStore certStore = csCallback.getCertStore();
        if (certStore != null) {
            CertSelector selector = null;
            /*if (this.certSelectorClass != null) {
                HashMap props = new HashMap();
                props.putAll(context);
                props.put(XWSSConstants.ISSUERNAME,issuerName);
                props.put(XWSSConstants.ISSUERSERIAL,serialNumber);
View Full Code Here

        }
         // if not found, look in CertStore followed by TrustStore
        CertStore certStore = csCallback.getCertStore();
        if (certStore != null) {
            CertSelector selector = null;
            /*if (this.certSelectorClass != null) {
                HashMap props = new HashMap();
                props.putAll(context);
                props.put(XWSSConstants.THUMBPRINT,keyIdMatch);
                selector = XWSSUtil.getCertSelector(certSelectorClass, props);
View Full Code Here

                        log.log(Level.SEVERE,LogStringsMessages.WSS_0221_CANNOT_LOCATE_CERT(alias), new Object[] {alias});
                        throw new XWSSecurityException(ex);
                    }
                   
                    if (csCallback.getCertStore() != null) {
                        CertSelector selector = XWSSUtil.getCertSelector(certSelectorClass, context);
                        if (selector != null) {
                            Collection certs = null;
                            try {
                                certs = csCallback.getCertStore().getCertificates(selector);
                            } catch (CertStoreException ex) {
                                log.log(Level.SEVERE, LogStringsMessages.WSS_0813_FAILEDTO_GETCERTIFICATE(), ex);
                                throw new RuntimeException(ex);
                            }
                            if (certs.size() > 0) {
                                cert = (X509Certificate)certs.iterator().next();
                            }
                        }
                    }
                }
               
                if (cert == null && this.truststoreCertSelectorClass != null) {
                   
                    TrustStoreCallback tsCallback = new TrustStoreCallback();
                    Callback[] _callbacks = null;
                    if (this.useXWSSCallbacks) {
                        RuntimeProperties props = new RuntimeProperties(context);
                        _callbacks = new Callback[]{props, tsCallback};
                    } else {
                        _callbacks = new Callback[]{tsCallback};
                    }
                    try {
                        _handler.handle(_callbacks);
                    } catch (IOException ex) {
                        log.log(Level.SEVERE,LogStringsMessages.WSS_0221_CANNOT_LOCATE_CERT(alias), new Object[] {alias});
                        throw new XWSSecurityException(ex);
                    } catch (UnsupportedCallbackException ex) {
                        log.log(Level.SEVERE,LogStringsMessages.WSS_0221_CANNOT_LOCATE_CERT(alias), new Object[] {alias});
                        throw new XWSSecurityException(ex);
                    }
                   
                    KeyStore trustStore = tsCallback.getTrustStore();
                   
                    if (trustStore != null) {
                        if (this.truststoreCertSelectorClass != null) {
                            CertSelector selector = XWSSUtil.getCertSelector(truststoreCertSelectorClass, context);
                            if (selector != null) {
                                Enumeration aliases=null;
                                try {
                                    aliases = trustStore.aliases();
                                } catch (KeyStoreException ex) {
                                    log.log(Level.SEVERE, LogStringsMessages.WSS_0813_FAILEDTO_GETCERTIFICATE(), ex);
                                    throw new RuntimeException(ex);
                                }
                                while (aliases.hasMoreElements()) {
                                    String currAlias = (String) aliases.nextElement();
                                    Certificate thisCertificate = null;
                                    try {
                                        thisCertificate = trustStore.getCertificate(currAlias);
                                    } catch (KeyStoreException ex) {
                                        log.log(Level.SEVERE, LogStringsMessages.WSS_0813_FAILEDTO_GETCERTIFICATE(), ex);
                                        throw new RuntimeException(ex);
                                    }
                                    if ((thisCertificate instanceof X509Certificate)
                                    && selector.match(thisCertificate)) {
                                        return (X509Certificate)thisCertificate;
                                    }
                                }
                            }
                        }
View Full Code Here

TOP

Related Classes of java.security.cert.CertSelector

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.