Example usage for java.security KeyRep.Type toString

List of usage examples for java.security KeyRep.Type toString

Introduction

In this page you can find the example usage for java.security KeyRep.Type toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:it.scoppelletti.programmerpower.security.spi.EncodedKeyFactory.java

@Override
protected KeySpec getKeySpec(String alg, KeyRep.Type keyType, Properties props, String prefix) {
    String name, value;/*from w w  w.  jav a2  s.co m*/
    byte[] data;
    KeySpec keySpec;

    name = Strings.concat(prefix, EncodedKeyFactory.PROP_DATA);
    value = props.getProperty(name);
    if (Strings.isNullOrEmpty(value)) {
        throw new ArgumentNullException(name);
    }

    data = Base64.decodeBase64(value);

    switch (keyType) {
    case PUBLIC:
        keySpec = new X509EncodedKeySpec(data);
        break;

    case PRIVATE:
        keySpec = new PKCS8EncodedKeySpec(data);
        break;

    default:
        throw new EnumConstantNotPresentException(KeyRep.Type.class, keyType.toString());
    }

    return keySpec;
}