Example usage for javax.crypto SecretKey toString

List of usage examples for javax.crypto SecretKey toString

Introduction

In this page you can find the example usage for javax.crypto SecretKey toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:tests.unit.configuration.ConfigurationTestCase.java

/**
 * @see junit.framework.TestCase#setUp()
 *//*from w  ww  .  j  av a2  s  .  c o  m*/
@Override
protected void setUp() throws Exception {
    super.setUp();

    try {
        FileUtils.moveFile(new File(CryptoHelper.getKeystorePath() + File.separator + KEYSTORE_NAME),
                new File(CryptoHelper.getKeystorePath() + File.separator + KEYSTORE_NAME + ".orig"));
    } catch (Exception exc) {
        exc.printStackTrace();
        fail();
    }

    try {
        KeyStoreID keySid = new KeyStoreID("TEMP", KeyStoreUtils.DEFAULT_KEYSTORE_TYPE, "", "",
                KeyStoreUtils.DEFAULT_KEYSTORE_PROVIDER);
        KeyID keyid = new KeyID("TEMP", keySid, "");
        keySid.setKeyStoreName(KEYSTORE_NAME);
        keySid.setKeyStorePwd(KEY_STORE_PWD);
        keyid.setKeyAlias(ALIAS_KEY_NAME);
        keyid.setKeyPwd(ALIAS_KEY_PWD);
        SecretKey secretKey = CryptoUtils.generateSecretKey(CryptoUtils.TRIPLE_DES_TYPE,
                KEY_STORE_PWD.getBytes());
        System.out.println("***************************************");
        System.out.println("Registering SecretKey: " + secretKey.getAlgorithm() + " " + secretKey.getFormat()
                + " " + secretKey.toString());
        System.out.println("In: " + keyid);

        KeyStoreUtils.writeKey(CryptoHelper.getKeystorePath(), keyid, secretKey, null);

        CryptoHelper.resetCache();
    } catch (Exception exc) {
        exc.printStackTrace();
        throw exc;
    }
}