Package org.apache.cxf.xkms.crypto

Examples of org.apache.cxf.xkms.crypto.CryptoProviderException


            new WSPasswordCallback(userName, usage)
        };
        try {
            handler.handle(cb);
        } catch (Exception e) {
            throw new CryptoProviderException("Cannot get password from callback: " + e, e);
        }

        // get the password
        return cb[0].getPassword();
    }
View Full Code Here


                                    SecurityConstants.SIGNATURE_PROPERTIES);
        try {
            Crypto defaultCrypto = CryptoFactory.getInstance(keystoreProps);
            return new XkmsCryptoProvider(xkmsConsumer, defaultCrypto);
        } catch (WSSecurityException e) {
            throw new CryptoProviderException("Cannot instantiate crypto factory: "
                                              + e.getMessage(), e);
        }
    }
View Full Code Here

    public Crypto create(String keystorePropsPath) {
        try {
            Properties keystoreProps = new Properties();
            InputStream is = this.getClass().getResourceAsStream(keystorePropsPath);
            if (is == null) {
                throw new CryptoProviderException("Cannot load security properties: "
                    + keystorePropsPath);
            }
            keystoreProps.load(is);
            Crypto defaultCrypto = CryptoFactory.getInstance(keystoreProps);
            return new XkmsCryptoProvider(xkmsConsumer, defaultCrypto);
        } catch (WSSecurityException e) {
            throw new CryptoProviderException("Cannot instantiate crypto factory: "
                + e.getMessage(), e);
        } catch (IOException e) {
            throw new CryptoProviderException("Cannot load security properties: "
                + e.getMessage(), e);
        }
    }
View Full Code Here

                LOG.fine("Certificate has already been validated by the XKMS service");
                return;
            }
        }
        if (certs == null || certs[0] == null || !xkmsInvoker.validateCertificate(certs[0])) {
            throw new CryptoProviderException("The given certificate is not valid");
        }
       
        // Validate Cached token
        if (cachedToken != null) {
            cachedToken.setXkmsValidated(true);
View Full Code Here

        storeCertificateInCache(certs[0], null, true);
    }

    @Override
    public void verifyTrust(PublicKey publicKey) throws WSSecurityException {
        throw new CryptoProviderException("PublicKeys cannot be verified");
    }
View Full Code Here

                LOG.fine("Certificate has already been validated by the XKMS service");
                return;
            }
        }
        if (certs == null || certs[0] == null || !xkmsInvoker.validateCertificate(certs[0])) {
            throw new CryptoProviderException("The given certificate is not valid");
        }
       
        // Validate Cached token
        if (cachedToken != null) {
            cachedToken.setXkmsValidated(true);
View Full Code Here

        storeCertificateInCache(certs[0], null, true);
    }

    @Override
    public void verifyTrust(PublicKey publicKey) throws WSSecurityException {
        throw new CryptoProviderException("PublicKeys cannot be verified");
    }
View Full Code Here

    }

    public static Properties loadKeystoreProperties(Message message, String propKey) {
        Object o = message.getContextualProperty(propKey);
        if (o == null) {
            throw new CryptoProviderException("Keystore properties path is not defined");
        }

        Properties properties = null;
        if (o instanceof Properties) {
            properties = (Properties)o;
        } else if (o instanceof String) {
            ResourceManager rm = message.getExchange().get(Bus.class)
                .getExtension(ResourceManager.class);
            URL url = rm.resolveResource((String)o, URL.class);
            try {
                if (url == null) {
                    url = ClassLoaderUtils.getResource((String)o, CryptoProviderUtils.class);
                }
                if (url == null) {
                    try {
                        url = new URL((String)o);
                    } catch (Exception ex) {
                        // ignore
                    }
                }
                if (url != null) {
                    InputStream ins = url.openStream();
                    properties = new Properties();
                    properties.load(ins);
                    ins.close();
                } else {
                    throw new CryptoProviderException("Keystore properties url is not resolved: "
                                                      + o);
                }
            } catch (IOException e) {
                throw new CryptoProviderException("Cannot load keystore properties: "
                                                  + e.getMessage(), e);
            }
        } else if (o instanceof URL) {
            properties = new Properties();
            try {
                InputStream ins = ((URL)o).openStream();
                properties.load(ins);
                ins.close();
            } catch (IOException e) {
                throw new CryptoProviderException("Cannot load keystore properties: "
                                                  + e.getMessage(), e);
            }
        }
        if (properties == null) {
            throw new CryptoProviderException("Cannot load keystore properties: " + o);
        }

        return properties;
    }
View Full Code Here

        if (keystoreProps.containsKey(Merlin.KEYSTORE_ALIAS)) {
            keystoreAlias = keystoreProps.getProperty(Merlin.KEYSTORE_ALIAS);
        }

        if (keystoreAlias == null) {
            throw new CryptoProviderException("Alias is not found in keystore properties file: "
                                              + Merlin.KEYSTORE_ALIAS);
        }

        return keystoreAlias;
    }
View Full Code Here

    public static String getCallbackPwdFromMessage(Message message, String userName, Usage usage) {
        // Then try to get the password from the given callback handler
        CallbackHandler handler = getCallbackHandler(message);
        if (handler == null) {
            throw new CryptoProviderException("No callback handler and no password available");
        }

        return getCallbackPwd(userName, usage, handler);
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.xkms.crypto.CryptoProviderException

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.