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 classCrypto.B64ToHexclassCrypto.B64ToIntclassCrypto.CodeChallengeComputes an RFC 7636 code challenge.classCrypto.CreateKeyclassCrypto.DecryptclassCrypto.DoJWTVerifyclassCrypto.EncryptclassCrypto.ExportKeysclassCrypto.FromJWTclassCrypto.GetPublicKeyGet the public part of a keyclassCrypto.HexToB64classCrypto.HexToIntprotected classCrypto.IdentityEncryptDecryptclassCrypto.IdentityJWTprotected classCrypto.IdentitySymmetricDeorEncryptclassCrypto.ImportKeyclassCrypto.IntToBase64classCrypto.IntToHexclassCrypto.KeyTypeclassCrypto.ProcessB64ToHexclassCrypto.ProcessB64ToIntprotected classCrypto.ProcessHexToIntprotected classCrypto.ProcessIntToB64protected classCrypto.ProcessIntToHexclassCrypto.ReadCertclassCrypto.ReadOIDclassCrypto.ToJWTclassCrypto.VerifyJWT
-
Field Summary
Fields Modifier and Type Field Description static StringAES_TYPEstatic StringB64_TO_HEXstatic StringCODE_CHALLENGEstatic StringCREATE_KEY_NAMEstatic StringDECRYPT_NAMEEncrypt or decrypt a stem.static StringEC_TYPEstatic StringENCRYPT_NAMEstatic StringEXPORT_NAMEstatic StringFROM_BASE64static StringFROM_JWTstatic StringGET_PUBLIC_KEY_NAMEstatic StringHEX_TO_B64static StringHEX_TO_INTstatic StringIMPORT_NAMEstatic StringINT_TO_HEXstatic StringJWKS_TYPEstatic StringJWT_ALGORITHMstatic StringJWT_ALGORITHM_NONEstatic StringJWT_DEFAULT_TYPEstatic StringJWT_KEY_IDstatic StringJWT_TYPEstatic StringKEY_TYPES_STEM_NAMEstatic StringPKCS_1_TYPEstatic StringPKCS_8_PUBLIC_TYPEstatic StringPKCS_8_TYPEstatic StringREAD_CERTstatic StringREAD_OIDstatic StringRSA_TYPEstatic StringSIGN_JWTstatic StringTO_BASE64static StringVERIFY_JWTstatic StringX509_TYPE
-
Constructor Summary
Constructors Constructor Description Crypto()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTypeHelp(List<String> dd)voiddeserializeFromJSON(net.sf.json.JSONObject json)protected ObjectexportJWKS(QDLValue[] qdlValues, State state)Does the actual work of exporting a JWKS set.protected ObjectexportPKCS(QDLValue[] qdlValues, State state)Does the actual work or exporting various PKCS files.static com.nimbusds.jose.jwk.JWKgetJwk(PublicKey publicKey)edu.uiuc.ncsa.security.util.jwk.JWKUtil2getJwkUtil()protected edu.uiuc.ncsa.security.util.jwk.JSONWebKeygetKeys(QDLStem keys)QDLStemgetKeyTypes()static StringgetRandomID()static StringgetRandomID(int byteCount)Creates a random id as an (upper case) hex number.ObjectimportJWKS(QDLValue[] qdlValues, State state)ObjectimportPKCS(QDLValue[] qdlValues, State state)protected booleanisAES(QDLStem key)Tests if a given stem that is a key is an AES i.e., symmetric key.protected booleanisEC(QDLStem key)protected booleanisRSA(QDLStem key)protected booleanisSingleKey(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.ObjectsDeOrEnCrypt(QDLValue[] objects, boolean isEncrypt, String name)net.sf.json.JSONObjectserializeToJSON()Send back a serialization of internal state for this object.static QDLStemwebKeyToStem(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
-
HEX_TO_INT
public static final String HEX_TO_INT
- See Also:
- Constant Field Values
-
INT_TO_HEX
public static final String INT_TO_HEX
- See Also:
- Constant Field Values
-
TO_BASE64
public static String TO_BASE64
-
FROM_BASE64
public static String FROM_BASE64
-
B64_TO_HEX
public static String B64_TO_HEX
-
HEX_TO_B64
public static String HEX_TO_B64
-
CODE_CHALLENGE
public static String CODE_CHALLENGE
-
-
Method Detail
-
getJwkUtil
public edu.uiuc.ncsa.security.util.jwk.JWKUtil2 getJwkUtil()
-
importPKCS
public Object importPKCS(QDLValue[] qdlValues, State state) throws Throwable
- Throws:
Throwable
-
importJWKS
public Object importJWKS(QDLValue[] qdlValues, State state) throws Throwable
- Throws:
Throwable
-
exportJWKS
protected Object exportJWKS(QDLValue[] qdlValues, State state) throws Throwable
Does the actual work of exporting a JWKS set.- Parameters:
qdlValues-state-- Returns:
- Throws:
Throwable
-
exportPKCS
protected Object exportPKCS(QDLValue[] qdlValues, State state) throws Throwable
Does the actual work or exporting various PKCS files.- Parameters:
qdlValues-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:QDLMetaModuleSend 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:
serializeToJSONin interfaceQDLMetaModule- Returns:
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject json)
- Specified by:
deserializeFromJSONin 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)
-
-