Example usage for java.security.interfaces RSAPrivateKey getAlgorithm

List of usage examples for java.security.interfaces RSAPrivateKey getAlgorithm

Introduction

In this page you can find the example usage for java.security.interfaces RSAPrivateKey getAlgorithm.

Prototype

public String getAlgorithm();

Source Link

Document

Returns the standard algorithm name for this key.

Usage

From source file:com.kuzumeji.platform.standard.SecurityServiceTest.java

@Test
public void testKeyPair() {
    // RSA???/*from  w  w w  .  j a v a  2 s  . c  om*/
    final KeyPair keyPair = testee.generateKeyPair();
    final RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
    final RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
    LOG.debug("?->{}", dumpKeyPair(publicKey));
    LOG.debug("?->{}", dumpKeyPair(privateKey));
    // RSA???/
    testee.saveKeyPair("testee", keyPair);
    final KeyPair keyPair2 = testee.loadKeyPair("testee");
    assertThat(keyPair2.getPublic().getAlgorithm(), is(publicKey.getAlgorithm()));
    assertThat(keyPair2.getPublic().getFormat(), is(publicKey.getFormat()));
    assertThat(keyPair2.getPublic().getEncoded(), is(publicKey.getEncoded()));
    assertThat(keyPair2.getPrivate().getAlgorithm(), is(privateKey.getAlgorithm()));
    assertThat(keyPair2.getPrivate().getFormat(), is(privateKey.getFormat()));
    assertThat(keyPair2.getPrivate().getEncoded(), is(privateKey.getEncoded()));
    // ???(??)
    final File file = testee.savePublicKeyFile(publicKey);
    LOG.debug("? : {}", file.getPath());
}