本文整理汇总了Java中io.jsonwebtoken.impl.TextCodec类的典型用法代码示例。如果您正苦于以下问题:Java TextCodec类的具体用法?Java TextCodec怎么用?Java TextCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextCodec类属于io.jsonwebtoken.impl包,在下文中一共展示了TextCodec类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createJWT
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
/**
* Generates the JWT for the request.
*
* JWT is signed with the api secret, and contains the qid, apiKey and expiry time in the claims section.
*
* @return String JWT
*/
private String createJWT () {
// The JWT signature algorithm we will be using to sign the token (HMAC using SHA-256)
SignatureAlgorithm sa = SignatureAlgorithm.HS256;
// Add our claims
Map <String, Object> cm = new HashMap<String, Object>();
cm.put("key", this.apiKey);
cm.put("exp", System.currentTimeMillis() + 60000); // expiry date 1 minute from now
// set the claims
String jwt = Jwts.builder().setHeaderParam("typ", "JWT")
.setClaims(cm).signWith(sa, TextCodec.BASE64.encode(this.apiSecret)).compact();
//System.out.println("JWT TOKEN: " + jwt);
return jwt;
}
开发者ID:PassKitInc,项目名称:Java-SDK,代码行数:23,代码来源:PassKit.java
示例2: getNewCertificateRequest
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
@SuppressWarnings("serial")
protected String getNewCertificateRequest(final KeyPair userKey, final String nonce, final PKCS10CertificationRequest csr) throws IOException {
return Jwts.builder()
.setHeaderParam(NONCE_KEY, nonce)
.setHeaderParam(JwsHeader.JSON_WEB_KEY, JWKUtils.getWebKey(userKey.getPublic()))
.setClaims(new TreeMap<String, Object>(){{
put(RESOURCE_KEY, RESOURCE_NEW_CERT);
put(CSR_KEY, TextCodec.BASE64URL.encode(csr.getEncoded()));
}})
.signWith(getJWSSignatureAlgorithm(), userKey.getPrivate())
.compact();
}
开发者ID:zero11it,项目名称:acme-client,代码行数:13,代码来源:Acme.java
示例3: getWebKey
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
public static TreeMap<String, Object> getWebKey(PublicKey publicKey) {
TreeMap<String, Object> key = new TreeMap<>();
if (publicKey instanceof RSAPublicKey){
key.put("kty","RSA");
key.put("e", TextCodec.BASE64URL.encode(toIntegerBytes(((RSAPublicKey) publicKey).getPublicExponent())));
key.put("n", TextCodec.BASE64URL.encode(toIntegerBytes(((RSAPublicKey) publicKey).getModulus())));
return key;
}else{
throw new IllegalArgumentException();
}
}
开发者ID:zero11it,项目名称:acme-client,代码行数:12,代码来源:JWKUtils.java
示例4: getWebKeyThumbprintSHA256
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
public static String getWebKeyThumbprintSHA256(PublicKey publicKey){
try {
TreeMap<String, Object> webKey = JWKUtils.getWebKey(publicKey);
String webKeyJson = new ObjectMapper().writeValueAsString(webKey);
return TextCodec.BASE64URL.encode(SHA256(webKeyJson));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
开发者ID:zero11it,项目名称:acme-client,代码行数:10,代码来源:JWKUtils.java
示例5: createCredentialEntity
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
private PublicCredentials createCredentialEntity(String kuid, PublicKey key) {
return new PublicCredentials(kuid, TextCodec.BASE64.encode(key.getEncoded()));
}
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:4,代码来源:JwtServiceImpl.java
示例6: isValid
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
@Override
public boolean isValid(String jwtWithoutSignature, String base64UrlEncodedSignature) {
byte[] data = jwtWithoutSignature.getBytes(US_ASCII);
byte[] signature = TextCodec.BASE64URL.decode(base64UrlEncodedSignature);
return this.signatureValidator.isValid(data, signature);
}
开发者ID:jwtk,项目名称:jjwt,代码行数:10,代码来源:DefaultJwtSignatureValidator.java
示例7: sign
import io.jsonwebtoken.impl.TextCodec; //导入依赖的package包/类
@Override
public String sign(String jwtWithoutSignature) {
byte[] bytesToSign = jwtWithoutSignature.getBytes(US_ASCII);
byte[] signature = signer.sign(bytesToSign);
return TextCodec.BASE64URL.encode(signature);
}
开发者ID:jwtk,项目名称:jjwt,代码行数:10,代码来源:DefaultJwtSigner.java
注:本文中的io.jsonwebtoken.impl.TextCodec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论