Package org.qdl_lang.extensions.crypto
Class Crypto
- java.lang.Object
-
- org.qdl_lang.extensions.crypto.Crypto
-
- All Implemented Interfaces:
Serializable
,QDLMetaModule
public class Crypto extends Object implements QDLMetaModule
Created by Jeff Gaynor
on 8/16/22 at 1:34 PM- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Crypto.CreateKey
class
Crypto.Decrypt
class
Crypto.DoJWTVerify
class
Crypto.Encrypt
class
Crypto.ExportKeys
class
Crypto.FromJWT
class
Crypto.GetPublicKey
Get the public part of a keyclass
Crypto.ImportKey
class
Crypto.KeyType
protected class
Crypto.ProcessEncryptDecrypt
class
Crypto.ProcessJWT
protected class
Crypto.ProcessSymmetricDeorEncrypt
class
Crypto.ReadCert
class
Crypto.ReadOID
class
Crypto.ToJWT
class
Crypto.VerifyJWT
-
Field Summary
Fields Modifier and Type Field Description static String
AES_TYPE
static String
CREATE_KEY_NAME
static String
DECRYPT_NAME
Encrypt or decrypt a stem.static String
EC_TYPE
static String
ENCRYPT_NAME
static String
EXPORT_NAME
static String
FROM_JWT
static String
GET_PUBLIC_KEY_NAME
static String
IMPORT_NAME
static String
JWKS_TYPE
static String
JWT_ALGORITHM
static String
JWT_ALGORITHM_NONE
static String
JWT_DEFAULT_TYPE
static String
JWT_KEY_ID
static String
JWT_TYPE
static String
KEY_TYPES_STEM_NAME
static String
PKCS_1_TYPE
static String
PKCS_8_PUBLIC_TYPE
static String
PKCS_8_TYPE
static String
READ_CERT
static String
READ_OID
static String
RSA_TYPE
static String
SIGN_JWT
static String
VERIFY_JWT
static String
X509_TYPE
-
Constructor Summary
Constructors Constructor Description Crypto()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addTypeHelp(List<String> dd)
void
deserializeFromJSON(net.sf.json.JSONObject json)
protected Object
exportJWKS(Object[] objects, State state)
Does the actual work of exporting a JWKS set.protected Object
exportPKCS(Object[] objects, State state)
Does the actual work or exporting various PKCS files.static com.nimbusds.jose.jwk.JWK
getJwk(PublicKey publicKey)
edu.uiuc.ncsa.security.util.jwk.JWKUtil2
getJwkUtil()
protected edu.uiuc.ncsa.security.util.jwk.JSONWebKey
getKeys(QDLStem keys)
QDLStem
getKeyTypes()
static String
getRandomID()
static String
getRandomID(int byteCount)
Creates a random id as an (upper case) hex number.Object
importJWKS(Object[] objects, State state)
Object
importPKCS(Object[] objects, State state)
protected boolean
isAES(QDLStem key)
Tests if a given stem that is a key is an AES i.e., symmetric key.protected boolean
isEC(QDLStem key)
protected boolean
isRSA(QDLStem key)
protected boolean
isSingleKey(QDLStem stem)
Is the stem a single key or a stem of keys? This is a simple-minded test and just checks if a required value for the keyis at the top level.Object
sDeOrEnCrypt(Object[] objects, boolean isEncrypt, String name)
net.sf.json.JSONObject
serializeToJSON()
Send back a serialization of internal state for this object.static QDLStem
webKeyToStem(edu.uiuc.ncsa.security.util.jwk.JSONWebKey jsonWebKey)
-
-
-
Field Detail
-
CREATE_KEY_NAME
public static final String CREATE_KEY_NAME
- See Also:
- Constant Field Values
-
IMPORT_NAME
public static final String IMPORT_NAME
- See Also:
- Constant Field Values
-
EXPORT_NAME
public static final String EXPORT_NAME
- See Also:
- Constant Field Values
-
JWKS_TYPE
public static final String JWKS_TYPE
- See Also:
- Constant Field Values
-
PKCS_1_TYPE
public static final String PKCS_1_TYPE
- See Also:
- Constant Field Values
-
PKCS_8_TYPE
public static final String PKCS_8_TYPE
- See Also:
- Constant Field Values
-
PKCS_8_PUBLIC_TYPE
public static final String PKCS_8_PUBLIC_TYPE
- See Also:
- Constant Field Values
-
X509_TYPE
public static final String X509_TYPE
- See Also:
- Constant Field Values
-
RSA_TYPE
public static final String RSA_TYPE
- See Also:
- Constant Field Values
-
EC_TYPE
public static final String EC_TYPE
- See Also:
- Constant Field Values
-
AES_TYPE
public static final String AES_TYPE
- See Also:
- Constant Field Values
-
KEY_TYPES_STEM_NAME
public static String KEY_TYPES_STEM_NAME
-
GET_PUBLIC_KEY_NAME
public static final String GET_PUBLIC_KEY_NAME
- See Also:
- Constant Field Values
-
ENCRYPT_NAME
public static final String ENCRYPT_NAME
- See Also:
- Constant Field Values
-
DECRYPT_NAME
public static final String DECRYPT_NAME
Encrypt or decrypt a stem. This will skip anything that is not a string or stem and will do the correct recursion to get everything in the stem- See Also:
- Constant Field Values
-
READ_CERT
public static String READ_CERT
-
READ_OID
public static final String READ_OID
- See Also:
- Constant Field Values
-
SIGN_JWT
public static String SIGN_JWT
-
JWT_TYPE
public static String JWT_TYPE
-
JWT_KEY_ID
public static String JWT_KEY_ID
-
JWT_ALGORITHM
public static String JWT_ALGORITHM
-
JWT_DEFAULT_TYPE
public static String JWT_DEFAULT_TYPE
-
JWT_ALGORITHM_NONE
public static String JWT_ALGORITHM_NONE
-
FROM_JWT
public static String FROM_JWT
-
VERIFY_JWT
public static String VERIFY_JWT
-
-
Method Detail
-
getJwkUtil
public edu.uiuc.ncsa.security.util.jwk.JWKUtil2 getJwkUtil()
-
importPKCS
public Object importPKCS(Object[] objects, State state) throws Throwable
- Throws:
Throwable
-
importJWKS
public Object importJWKS(Object[] objects, State state) throws Throwable
- Throws:
Throwable
-
exportJWKS
protected Object exportJWKS(Object[] objects, State state) throws Throwable
Does the actual work of exporting a JWKS set.- Parameters:
objects
-state
-- Returns:
- Throws:
Throwable
-
exportPKCS
protected Object exportPKCS(Object[] objects, State state) throws Throwable
Does the actual work or exporting various PKCS files.- Parameters:
objects
-state
-- Returns:
- Throws:
Throwable
-
getKeyTypes
public QDLStem getKeyTypes()
-
getJwk
public static com.nimbusds.jose.jwk.JWK getJwk(PublicKey publicKey)
-
getKeys
protected edu.uiuc.ncsa.security.util.jwk.JSONWebKey getKeys(QDLStem keys)
-
webKeyToStem
public static QDLStem webKeyToStem(edu.uiuc.ncsa.security.util.jwk.JSONWebKey jsonWebKey)
-
isSingleKey
protected boolean isSingleKey(QDLStem stem)
Is the stem a single key or a stem of keys? This is a simple-minded test and just checks if a required value for the keyis at the top level.- Parameters:
stem
-- Returns:
-
getRandomID
public static String getRandomID()
-
getRandomID
public static String getRandomID(int byteCount)
Creates a random id as an (upper case) hex number.- Parameters:
byteCount
-- Returns:
-
serializeToJSON
public net.sf.json.JSONObject serializeToJSON()
Description copied from interface:QDLMetaModule
Send back a serialization of internal state for this object. This allows for the state you choose to be serialized and then reloaded.NOTE
There is no canonical form for this. Set it how you will and deserialize it accordingly.- Specified by:
serializeToJSON
in interfaceQDLMetaModule
- Returns:
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject json)
- Specified by:
deserializeFromJSON
in interfaceQDLMetaModule
-
isAES
protected boolean isAES(QDLStem key)
Tests if a given stem that is a key is an AES i.e., symmetric key.- Parameters:
key
-- Returns:
-
isEC
protected boolean isEC(QDLStem key)
-
isRSA
protected boolean isRSA(QDLStem key)
-
-