# PKCS8KeyFile (sshj 0.4.0 API)
Date: 2011-06-06

## net.schmizz.sshj.userauth.keyprovider
Class PKCS8KeyFile

    java.lang.Object
      net.schmizz.sshj.userauth.keyprovider.PKCS8KeyFile

All Implemented Interfaces:
  FileKeyProvider, KeyProvider

Direct Known Subclasses:
  OpenSSHKeyFile

    public class PKCS8KeyFile

extends Object
implements FileKeyProvider

Represents a PKCS8-encoded key file. This is the format used by OpenSSH and OpenSSL.

Nested Class Summary
`static class` `PKCS8KeyFile.Factory`

Nested classes/interfaces inherited from interface net.schmizz.sshj.userauth.keyprovider.FileKeyProvider
`FileKeyProvider.Format`

Field Summary
`protected KeyPair` `kp`
`protected org.slf4j.Logger` `log`
`protected char[]` `passphrase`
`protected PasswordFinder` `pwdf`
`protected PrivateKeyFileResource` `resource`
`protected KeyType` `type`

Constructor Summary
`PKCS8KeyFile()`

Method Summary
`PrivateKey` `getPrivate()`
`PublicKey` `getPublic()`
`KeyType` `getType()`
`void` `init(File location)`
`void` `init(File location, PasswordFinder pwdf)`
`protected org.bouncycastle.openssl.PasswordFinder` `makeBouncyPasswordFinder()`
`protected KeyPair` `readKeyPair()`
`String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### log

    protected final org.slf4j.Logger log

### pwdf

    protected PasswordFinder pwdf

### resource

    protected PrivateKeyFileResource resource

### kp

    protected KeyPair kp

### type

    protected KeyType type

### passphrase

    protected char[] passphrase

Constructor Detail

### PKCS8KeyFile

    public PKCS8KeyFile()

Method Detail

### getPrivate

    public PrivateKey getPrivate()
                          throws IOException

  Specified by:
    `getPrivate` in interface `KeyProvider`
  Returns:
    the private key.
  Throws:
    `IOException` - if there is an I/O error retrieving the private key

### getPublic

    public PublicKey getPublic()
                        throws IOException

  Specified by:
    `getPublic` in interface `KeyProvider`
  Returns:
    the public key.
  Throws:
    `IOException` - if there is an I/O error retrieving the public key

### getType

    public KeyType getType()
                    throws IOException

  Specified by:
    `getType` in interface `KeyProvider`
  Returns:
    the `KeyType`.
  Throws:
    `IOException` - if there is an I/O error retrieving the key type

### init

    public void init(File location)

  Specified by:
    `init` in interface `FileKeyProvider`

### init

    public void init(File location,
                     PasswordFinder pwdf)

  Specified by:
    `init` in interface `FileKeyProvider`

### makeBouncyPasswordFinder

    protected org.bouncycastle.openssl.PasswordFinder makeBouncyPasswordFinder()

### readKeyPair

    protected KeyPair readKeyPair()
                           throws IOException

  Throws:
    `IOException`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Copyright © 2009-2011. All Rights Reserved.