Package org.apache.wss4j.common.ext

Examples of org.apache.wss4j.common.ext.WSSecurityException


        MessageDigest sha = null;
       
        try {
            sha = MessageDigest.getInstance("SHA1");
        } catch (NoSuchAlgorithmException e) {
            throw new WSSecurityException(
                WSSecurityException.ErrorCode.FAILURE, "decoding.general", e
            );
        }
        Certificate[] certs = null;
        if (keystore != null) {
View Full Code Here


                if (cert instanceof X509Certificate) {
                    X509Certificate x509cert = (X509Certificate) cert;
                    try {
                        sha.update(x509cert.getEncoded());
                    } catch (CertificateEncodingException ex) {
                        throw new WSSecurityException(
                            WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, "encodeError",
                            ex
                        );
                    }
                    byte[] data = sha.digest();

                    if (Arrays.equals(data, thumbprint)) {
                        return certs;
                    }
                }
            }
        } catch (KeyStoreException e) {
            throw new WSSecurityException(
                WSSecurityException.ErrorCode.FAILURE, "keystore", e
            );
        }
        return new Certificate[]{};
    }
View Full Code Here

                        return certs;
                    }
                }
            }
        } catch (KeyStoreException e) {
            throw new WSSecurityException(
                WSSecurityException.ErrorCode.FAILURE, "keystore", e
            );
        }
        return new Certificate[]{};
    }
View Full Code Here

            if (certs == null) {
                return null;
            }
        } catch (KeyStoreException e) {
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "keystore", e);
        }

        X509Certificate[] x509certs = new X509Certificate[certs.length];
        for (int i = 0; i < certs.length; i++) {
            x509certs[i] = (X509Certificate) certs[i];
View Full Code Here

                        return certs;
                    }
                }
            }
        } catch (KeyStoreException e) {
            throw new WSSecurityException(
                WSSecurityException.ErrorCode.FAILURE, "keystore", e
            );
        }
        return new Certificate[]{};
    }
View Full Code Here

                if (retrievedCert.equals(cert)) {
                    return alias;
                }
            }
        } catch (KeyStoreException e) {
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "keystore", e);
        }
        return null;
    }
View Full Code Here

            new WSPasswordCallback(identifier, WSPasswordCallback.DECRYPT);
        try {
            Callback[] callbacks = new Callback[]{pwCb};
            cb.handle(callbacks);
        } catch (IOException e) {
            throw new WSSecurityException(
                WSSecurityException.ErrorCode.FAILURE,
                "noPassword", e, identifier
            );
        } catch (UnsupportedCallbackException e) {
            throw new WSSecurityException(
                WSSecurityException.ErrorCode.FAILURE,
                "noPassword", e, identifier
            );
        }
View Full Code Here

    public static Crypto getInstance(Properties properties) throws WSSecurityException {
        if (properties == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Cannot load Crypto instance as properties object is null");
            }
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                    "empty", null, "Cannot load Crypto instance as properties object is null");
        }
        return getInstance(properties, Loader.getClassLoader(CryptoFactory.class), null);
    }
View Full Code Here

    ) throws WSSecurityException {
        if (properties == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Cannot load Crypto instance as properties object is null");
            }
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                    "empty", null, "Cannot load Crypto instance as properties object is null");
        }

        String cryptoClassName = properties.getProperty("org.apache.wss4j.crypto.provider");
        if (cryptoClassName == null) {
            cryptoClassName = properties.getProperty("org.apache.ws.security.crypto.provider");
        }
       
        Class<? extends Crypto> cryptoClass = null;
        if (cryptoClassName == null
            || cryptoClassName.equals("org.apache.wss4j.common.crypto.Merlin")
            || cryptoClassName.equals("org.apache.ws.security.components.crypto.Merlin")) {
            try {
                return new Merlin(properties, classLoader, passwordEncryptor);
            } catch (java.lang.Exception e) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Unable to instantiate Merlin", e);
                }
                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                                              "empty", e, "Cannot create Crypto class "
                                              + cryptoClassName);
            }
        } else {
            try {
                // instruct the class loader to load the crypto implementation
                cryptoClass = Loader.loadClass(cryptoClassName, Crypto.class);
            } catch (ClassNotFoundException ex) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(ex.getMessage(), ex);
                }
                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                        "empty", ex, cryptoClassName + " Not Found");
            }
        }
        return loadClass(cryptoClass, properties, classLoader);
    }
View Full Code Here

            return c.newInstance(map, loader);
        } catch (java.lang.Exception e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unable to instantiate: " + cryptoClass.getName(), e);
            }
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                    "empty", e, cryptoClass + " cannot create instance");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.wss4j.common.ext.WSSecurityException

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.