public class LTI13Util extends Object
| Constructor and Description |
|---|
LTI13Util() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addCustomToLaunch(Properties ltiProps,
Properties custom) |
static String |
base64Encode(byte[] input) |
static String |
breakKeyIntoLines(String rawkey) |
static boolean |
checkLTI11Transition(LaunchJWT lj,
String key,
String secret)
Check the OAuth signature for an LTI 1.3 Launch JWT
See: https://www.imsglobal.org/spec/lti/v1p3/migr#lti-1-1-migration-claim
|
static String |
compute_HMAC_SHA256(String message,
String secret)
Compute the HMAC256 of a string (part of LTI 1.1 Transition)
See: https://www.imsglobal.org/spec/lti/v1p3/migr#lti-1-1-migration-claim
Based on:
https://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-different-languages/#php
https://stackoverflow.com/questions/7124735/hmac-sha256-algorithm-for-signature-calculation
|
static KeyPair |
generateKeyPair() |
static Map<String,String> |
generateKeys() |
static Double |
getDoubleNull(Object key) |
static int |
getInt(Object o) |
static String |
getKeyB64(Key key) |
static Long |
getLong(Object key) |
static Long |
getLongKey(Object key) |
static Long |
getLongNull(Object key) |
static String |
getLTI11TransitionBase(LaunchJWT lj)
Compute the base string for a Launch JWT
See: https://www.imsglobal.org/spec/lti/v1p3/migr#lti-1-1-migration-claim
|
static String |
getPrivateB64(Key key) |
static String |
getPrivateB64(KeyPair kp) |
static String |
getPrivateEncoded(Key key) |
static String |
getPrivateEncoded(KeyPair kp) |
static String |
getPrivateEncoded(String keyStr) |
static String |
getPublicB64(KeyPair kp) |
static String |
getPublicEncoded(Key key) |
static String |
getPublicEncoded(KeyPair kp) |
static String |
getPublicEncoded(String keyStr) |
static String |
getStringNull(Object value) |
static void |
return400(javax.servlet.http.HttpServletResponse response,
String error) |
static void |
return400(javax.servlet.http.HttpServletResponse response,
String error,
String detail) |
static void |
setProperty(Properties props,
String key,
String value) |
static String |
sha256(String input) |
static String |
signLTI11Transition(LaunchJWT lj,
String secret)
Compute the OAuth signature for an LTI 1.3 Launch JWT
See: https://www.imsglobal.org/spec/lti/v1p3/migr#lti-1-1-migration-claim
|
static Key |
string2PrivateKey(String keyString) |
static Key |
string2PublicKey(String keyString) |
static KeyPair |
strings2KeyPair(String pubKeyStr,
String privKeyStr) |
static String |
stripPKCS8(String input) |
static void |
substituteCustom(Properties custom,
Properties lti2subst) |
static String |
timeStamp(String token)
timeStamp - Add a time-stamp to the beginning of a string
|
static boolean |
timeStampCheck(String token,
int seconds)
timeStampCheck - Check a time-stamp at the beginning of a string
|
static boolean |
timeStampCheckSign(String token,
String secret,
int seconds)
timeStampCheckSign - check to see if a token has not expired and is signed
|
static String |
timeStampSign(String token,
String secret)
timeStampSign - Take a one-time token and add a timestamp
timestamp:token:signature
|
static String |
toNull(String str) |
public static Map<String,String> generateKeys() throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static String base64Encode(byte[] input)
public static KeyPair generateKeyPair()
public static String getLTI11TransitionBase(LaunchJWT lj)
lj - The Launch JSON Web Token with the LTI 1.1 transition datapublic static String signLTI11Transition(LaunchJWT lj, String secret)
lj - The Launch JSON Web Token with the LTI 11 transition datasecret - The OAuth secretpublic static boolean checkLTI11Transition(LaunchJWT lj, String key, String secret)
lj - The Launch JSON Web Token with the LTI 11 transition datakey - The OAuth keysecret - The OAuth secretpublic static String compute_HMAC_SHA256(String message, String secret)
object - $message The message to signstring - $secret The secret used to sign the messagepublic static void return400(javax.servlet.http.HttpServletResponse response,
String error,
String detail)
public static void return400(javax.servlet.http.HttpServletResponse response,
String error)
public static void substituteCustom(Properties custom, Properties lti2subst)
public static void addCustomToLaunch(Properties ltiProps, Properties custom)
public static void setProperty(Properties props, String key, String value)
public static String timeStamp(String token)
public static boolean timeStampCheck(String token, int seconds)
public static String timeStampSign(String token, String secret)
public static boolean timeStampCheckSign(String token, String secret, int seconds)
public static int getInt(Object o)
Copyright 2015- Charles R. Severance and licensed CC-BY Attribution 4.0