Example usage for java.security UnrecoverableKeyException printStackTrace

List of usage examples for java.security UnrecoverableKeyException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:Main.java

private static KeyManager[] prepareKeyManager(InputStream bksFile, String password) {
    try {//from  w w w.java  2s . c o  m
        if (bksFile != null && password != null) {
            KeyStore e = KeyStore.getInstance("BKS");
            e.load(bksFile, password.toCharArray());
            KeyManagerFactory keyManagerFactory = KeyManagerFactory
                    .getInstance(KeyManagerFactory.getDefaultAlgorithm());
            keyManagerFactory.init(e, password.toCharArray());
            return keyManagerFactory.getKeyManagers();
        }

        return null;
    } catch (KeyStoreException var4) {
        var4.printStackTrace();
    } catch (NoSuchAlgorithmException var5) {
        var5.printStackTrace();
    } catch (UnrecoverableKeyException var6) {
        var6.printStackTrace();
    } catch (CertificateException var7) {
        var7.printStackTrace();
    } catch (IOException var8) {
        var8.printStackTrace();
    } catch (Exception var9) {
        var9.printStackTrace();
    }

    return null;
}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?p//from   w  w  w  .j ava2 s  .  co  m
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getpByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("primep:") + "primep:".length(), pfx.indexOf("primeq:"));

    return modulus.trim().replace(" ", "");
}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?q/*w w w . j  a  v  a 2s. c o  m*/
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getqByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("primeq:") + "primeq:".length(), pfx.indexOf("primeexponentp:"));

    return modulus.trim().replace(" ", "");

}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?qInv/*from  w  w  w . java2s .c  o m*/
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getqInvByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("crtcoefficient:") + "crtcoefficient:".length(), pfx.length());

    return modulus.trim().replace(" ", "");

}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?N/*from  w  ww.j  a  va 2 s .c  o m*/
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getModulusByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("modulus:") + "modulus:".length(),
            pfx.indexOf("publicexponent:"));

    return modulus.trim().replace(" ", "");

}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?e//  w w  w .  ja  v  a  2  s  .c  om
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getPubExponentByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("publicexponent:") + "publicexponent:".length(),
            pfx.indexOf("privateexponent:"));

    return modulus.trim().replace(" ", "");

}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore??d//  ww  w.  ja v  a 2  s . co  m
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getPriExponentByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("privateexponent:") + "privateexponent:".length(),
            pfx.indexOf("primep:"));

    return modulus.trim().replace(" ", "");

}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?dp/*from   w w  w .j  ava 2 s.  co m*/
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getdpByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("primeexponentp:") + "primeexponentp:".length(),
            pfx.indexOf("primeexponentq:"));

    return modulus.trim().replace(" ", "");

}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

/**
 * ?KeyStore?dq/* w w  w  . jav a2 s.com*/
 * 
 * @param alias
 * @param pfxPath
 * @param password
 * @return
 */
public static String getdqByPfx(String alias, String pfxPath, String password) {

    String pfx = "";
    try {
        pfx = readPrivateKeyStr(alias, pfxPath, password);
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String modulus = pfx.substring(pfx.indexOf("primeexponentq:") + "primeexponentq:".length(),
            pfx.indexOf("crtcoefficient:"));

    return modulus.trim().replace(" ", "");

}

From source file:eu.nullbyte.android.urllib.Urllib.java

public Urllib(Context context, ClientCertificate clientCert, Certificate[] pins) {
    mContext = context;//from   ww  w  . ja  v  a  2 s .  c  om
    this.headers = new HashMap<String, String>();
    userAgent = createUserAgentString();
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, this.charset);
    params.setBooleanParameter("http.protocol.expect-continue", false);
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean trustSystemKeystore = prefs.getBoolean("debug_mode", false)
            && prefs.getBoolean("no_cert_pinning", false);
    try {
        mSSLSocketFactory = new CertPinningSSLSocketFactory(clientCert, pins);
        registry.register(new Scheme("https",
                pins != null && !trustSystemKeystore ? mSSLSocketFactory : SSLSocketFactory.getSocketFactory(),
                443));
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyManagementException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    }
    ClientConnectionManager manager = new ThreadSafeClientConnManager(params, registry);
    httpclient = new BankdroidHttpClient(manager, params);
    mHttpContext = new BasicHttpContext();

}