Example usage for java.security NoSuchAlgorithmException printStackTrace

List of usage examples for java.security NoSuchAlgorithmException printStackTrace

Introduction

In this page you can find the example usage for java.security NoSuchAlgorithmException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.jahia.tools.maven.plugins.LegalArtifactAggregator.java

private static Client getRestClient(String targetUrl) {

    if (clients.containsKey(targetUrl)) {
        return clients.get(targetUrl);
    }/*from  w  w  w  .j av  a 2s  .co  m*/

    Client client = null;
    if (targetUrl != null) {
        if (targetUrl.startsWith("https://")) {
            try {
                // Create a trust manager that does not validate certificate chains
                TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
                    public X509Certificate[] getAcceptedIssuers() {
                        return null;
                    }

                    public void checkClientTrusted(X509Certificate[] certs, String authType) {
                    }

                    public void checkServerTrusted(X509Certificate[] certs, String authType) {
                    }
                } };
                // Create all-trusting host name verifier
                HostnameVerifier allHostsValid = new HostnameVerifier() {
                    public boolean verify(String hostname, SSLSession session) {
                        return true;
                    }
                };
                SSLContext sslContext = SSLContext.getInstance("SSL");
                sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
                client = ClientBuilder.newBuilder().sslContext(sslContext).hostnameVerifier(allHostsValid)
                        .build();
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            } catch (KeyManagementException e) {
                e.printStackTrace();
            }
        } else {
            client = ClientBuilder.newClient();

        }
    }
    if (client == null) {
        return null;
    }

    client.property(ClientProperties.CONNECT_TIMEOUT, 1000);
    client.property(ClientProperties.READ_TIMEOUT, 3000);
    /*
    HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(contextServerSettings.getContextServerUsername(), contextServerSettings.getContextServerPassword());
    client.register(feature);
    */
    clients.put(targetUrl, client);
    return client;
}

From source file:com.sos.VirtualFileSystem.FTPS.SOSVfsFtpS.java

@Override
protected FTPSClient Client() {
    if (objFTPClient == null) {
        try {/*w  w w. j ava2s.  co  m*/
            String strProtocol = objConnection2Options.FtpS_protocol.Value();
            objFTPClient = new FTPSClient(strProtocol);
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new JobSchedulerException("can not create FTPS-Client");
        }
        FTPClientConfig conf = new FTPClientConfig();
        //         conf.setServerLanguageCode("fr");
        //         objFTPClient.configure(conf);
        /**
         * This listener is to write all commands and response from commands to system.out
         *
         */
        objProtocolCommandListener = new SOSFtpClientLogger(HostID(""));
        // TODO create a hidden debug-option to activate this listener
        if (objConnection2Options != null) {
            if (objConnection2Options.ProtocolCommandListener.isTrue()) {
                objFTPClient.addProtocolCommandListener(objProtocolCommandListener);
            }
        }

        String strAddFTPProtocol = System.getenv("AddFTPProtocol");
        if (strAddFTPProtocol != null && strAddFTPProtocol.equalsIgnoreCase("true")) {
            objFTPClient.addProtocolCommandListener(objProtocolCommandListener);
        }

    }
    return objFTPClient;
}

From source file:com.floreantpos.ui.dialog.LicenseDialog.java

private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {

    try {//from   w  w  w . ja va  2 s  .c om

        AppConfig.setMachineId(idTF.getText());

        MessageDigest md = MessageDigest.getInstance("SHA");

        md.update(idTF.getText().getBytes("UTF-8"));

        String key = new String(md.digest(), "UTF-8");

        Base64 base64 = new Base64(true);

        key = base64.encodeAsString(key.getBytes("UTF-8")).trim().toUpperCase();

        key = key.replaceAll("_", "").replaceAll("-", "");

        if (key.equalsIgnoreCase(keyTF.getText())) {
            AppConfig.setLicenceKey(key);
            System.exit(0);
        } else {
            MessageDialog.showError("License Key tidak valid");
        }

    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

}

From source file:mvm.rya.mongodb.dao.SimpleMongoDBNamespaceManager.java

@Override
public void addNamespace(String prefix, String namespace) throws RyaDAOException {
    String id = prefix;//from   w w w.jav  a 2 s  . c o m
    byte[] bytes = id.getBytes();
    try {
        MessageDigest digest = MessageDigest.getInstance("SHA-1");
        bytes = digest.digest(bytes);
    } catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    BasicDBObject doc = new BasicDBObject(ID, new String(Hex.encodeHex(bytes))).append(PREFIX, prefix)
            .append(NAMESPACE, namespace);
    nsColl.insert(doc);

}

From source file:org.apache.rya.mongodb.dao.SimpleMongoDBNamespaceManager.java

@Override
public void addNamespace(final String prefix, final String namespace) throws RyaDAOException {
    final String id = prefix;
    byte[] bytes = id.getBytes(StandardCharsets.UTF_8);
    try {/*  w  ww.  j a  v a2s.  c om*/
        final MessageDigest digest = MessageDigest.getInstance("SHA-1");
        bytes = digest.digest(bytes);
    } catch (final NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    final BasicDBObject doc = new BasicDBObject(ID, new String(Hex.encodeHex(bytes))).append(PREFIX, prefix)
            .append(NAMESPACE, namespace);
    nsColl.insert(doc);

}

From source file:org.iavante.sling.commons.services.impl.EncryptionServiceImpl.java

/**
 * Initialize log and Key_Pair/*w  w  w .jav a2  s  .  c  o  m*/
 */
private void initialize() {
    log = LoggerFactory.getLogger(getClass());
    if (log.isInfoEnabled())
        log.info("Encryption Object: " + this.toString());
    try {
        makeKey();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (NoSuchProviderException e) {
        e.printStackTrace();
    }
}

From source file:org.mitre.jwt.signer.impl.HmacSigner.java

private void initializeMac() {
    if (mac == null) {
        try {// www.ja  v  a2  s .c  om
            mac = Mac.getInstance(getAlgorithm().getStandardName());
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:edu.csueb.cs6320.utils.UserService.java

public boolean isValidPassword(String email, String password) {
    EntityManager em = Persistence.createEntityManagerFactory("TestPU").createEntityManager();

    User u = (User) em.createQuery("SELECT u FROM User u WHERE u.email = :inEmail")
            .setParameter("inEmail", email).setMaxResults(1).getSingleResult();

    if (u == null) {
        return false;
    }//from   w  ww .  j  ava 2  s .co  m

    try {
        return Auth.isCorrectPassword(password, u.getSalt(), u.getSaltedHashedPassword());
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:edu.csueb.cs6320.utils.UserService.java

public boolean createUser(User user, String newPassword) {

    String salt = Auth.getSalt();
    user.setSalt(salt);//w  w w .j a  va  2s.c  o m
    try {
        user.setSaltedHashedPassword(Auth.hashPassword(newPassword, salt));
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return false;
    }

    EntityManager em = Persistence.createEntityManagerFactory("TestPU").createEntityManager();
    em.getTransaction().begin();
    em.persist(user);
    em.getTransaction().commit();
    return true;
}

From source file:edu.umass.cs.reconfiguration.ActiveReplica.java

static MessageDigest initMD() {
    try {// w  w  w.j av  a2 s .c  o m
        return MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return null;
}