Top Inners Constructors Methods
org.keycloak.common.util

public Class KeystoreUtil

extends Object
Class Inheritance
Imports
org.keycloak.common.constants.GenericConstants, org.keycloak.common.crypto.CryptoIntegration, java.io.File, .FileInputStream, .InputStream, java.security.KeyPair, .KeyStore, .PrivateKey, .PublicKey, java.util.Arrays, .List, .Optional

Author
Bill Burke
Version
$Revision: 1 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

format as specified above
getKeystoreType
(String
The preferred format - usually the one from the configuration. When present, it should be preferred over anything else
preferredType
,
String
Path of the file. We can try to detect keystore type from that (EG. my-keystore.pkcs12 will return "pkcs12") in case that preferredType is not defined
path
,
String
Default format as last fallback when none of the above can be used. Should be non-null
defaultType
)

Try to return supported keystore type

public static KeyPair
loadKeyPairFromKeystore(String keystoreFile, String storePassword, String keyPassword, String keyAlias, KeystoreUtil.KeystoreFormat format)

public static KeyStore
loadKeyStore(String filename, String password)

public static KeyStore
loadKeyStore(String filename, String password, String preferedType)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

KeystoreUtilback to summary
public KeystoreUtil()

Method Detail

getKeystoreTypeback to summary
public static String getKeystoreType(String preferredType, String path, String defaultType)

Try to return supported keystore type

Parameters
preferredType:String

The preferred format - usually the one from the configuration. When present, it should be preferred over anything else

path:String

Path of the file. We can try to detect keystore type from that (EG. my-keystore.pkcs12 will return "pkcs12") in case that preferredType is not defined

defaultType:String

Default format as last fallback when none of the above can be used. Should be non-null

Returns:String

format as specified above

loadKeyPairFromKeystoreback to summary
public static KeyPair loadKeyPairFromKeystore(String keystoreFile, String storePassword, String keyPassword, String keyAlias, KeystoreUtil.KeystoreFormat format)
loadKeyStoreback to summary
public static KeyStore loadKeyStore(String filename, String password) throws Exception
loadKeyStoreback to summary
public static KeyStore loadKeyStore(String filename, String password, String preferedType) throws Exception
org.keycloak.common.util back to summary

public final Enum KeystoreUtil.KeystoreFormat

extends Enum<KeystoreUtil.KeystoreFormat>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final KeystoreUtil.KeystoreFormat
private final List<String>
public static final KeystoreUtil.KeystoreFormat
public static final KeystoreUtil.KeystoreFormat

Constructor Summary

AccessConstructor and Description
private
KeystoreFormat(String... extensions)

Method Summary

Modifier and TypeMethod and Description
public List<String>
public String
public static KeystoreUtil.KeystoreFormat
public static KeystoreUtil.KeystoreFormat[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BCFKSback to summary
public static final KeystoreUtil.KeystoreFormat BCFKS
fileExtensionsback to summary
private final List<String> fileExtensions
JKSback to summary
public static final KeystoreUtil.KeystoreFormat JKS
PKCS12back to summary
public static final KeystoreUtil.KeystoreFormat PKCS12

Constructor Detail

KeystoreFormatback to summary
private KeystoreFormat(String... extensions)

Method Detail

getFileExtensionsback to summary
public List<String> getFileExtensions()
getPrimaryExtensionback to summary
public String getPrimaryExtension()
valueOfback to summary
public static KeystoreUtil.KeystoreFormat valueOf(String name)
valuesback to summary
public static KeystoreUtil.KeystoreFormat[] values()