本文整理了Java中com.jetdrone.vertx.yoke.YokeSecurity
类的一些代码示例,展示了YokeSecurity
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YokeSecurity
类的具体详情如下:
包路径:com.jetdrone.vertx.yoke.YokeSecurity
类名称:YokeSecurity
暂无
代码示例来源:origin: pmlopes/yoke
public JWT(final YokeSecurity security) {
Map<String, Crypto> tmp = new HashMap<>();
try {
tmp.put("HS256", new CryptoMac(security.getMac("HS256")));
} catch (RuntimeException e) {
// Algorithm not supported
}
try {
tmp.put("HS384", new CryptoMac(security.getMac("HS384")));
} catch (RuntimeException e) {
// Algorithm not supported
}
try {
tmp.put("HS512", new CryptoMac(security.getMac("HS512")));
} catch (RuntimeException e) {
// Algorithm not supported
}
try {
tmp.put("RS256", new CryptoSignature(security.getSignature("RS256")));
} catch (RuntimeException e) {
// Algorithm not supported
}
CRYPTO_MAP = Collections.unmodifiableMap(tmp);
}
代码示例来源:origin: pmlopes/yoke
/**
* Returns the original value is the signature is correct. Null otherwise.
*/
public static String unsign(@NotNull String val, @NotNull Mac mac) {
int idx = val.lastIndexOf('.');
if (idx == -1) {
return null;
}
String str = val.substring(0, idx);
if (val.equals(sign(str, mac))) {
return str;
}
return null;
}
代码示例来源:origin: pmlopes/yoke
public YokeCookie(@NotNull final Cookie nettyCookie, final Mac mac) {
this.nettyCookie = nettyCookie;
this.mac = mac;
// get the original value
value = nettyCookie.value();
// if the prefix is there then it is signed
if (value.startsWith("s:")) {
signed = true;
// if it is signed get the unsigned value
if (mac == null) {
// this is an error
value = null;
} else {
value = YokeSecurity.unsign(value.substring(2), mac);
}
}
}
代码示例来源:origin: pmlopes/yoke
app.secretSecurity("keyboard cat");
final Mac hmac = app.security().getMac("HmacSHA256");
代码示例来源:origin: pmlopes/yoke
public void sign() {
if (mac != null) {
nettyCookie.setValue("s:" + YokeSecurity.sign(value, mac));
signed = true;
} else {
signed = false;
}
}
内容来源于网络,如有侵权,请联系作者删除!