当前位置: 首页>>代码示例>>Java>>正文


Java DecodedJWT.getSignature方法代码示例

本文整理汇总了Java中com.auth0.jwt.interfaces.DecodedJWT.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java DecodedJWT.getSignature方法的具体用法?Java DecodedJWT.getSignature怎么用?Java DecodedJWT.getSignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.auth0.jwt.interfaces.DecodedJWT的用法示例。


在下文中一共展示了DecodedJWT.getSignature方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verify

import com.auth0.jwt.interfaces.DecodedJWT; //导入方法依赖的package包/类
@Override
public void verify(DecodedJWT jwt, EncodeType encodeType) throws Exception {
    byte[] signatureBytes = null;
    String signature = jwt.getSignature();
    String urlDecoded = null;
    switch (encodeType) {
        case Base16:
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = Hex.decodeHex(urlDecoded);
            break;
        case Base32:
            Base32 base32 = new Base32();
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = base32.decode(urlDecoded);
            break;
        case Base64:
            signatureBytes = Base64.decodeBase64(signature);
            break;
    }
    if (signatureBytes.length > 0) {
        throw new SignatureVerificationException(this);
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:24,代码来源:NoneAlgorithm.java

示例2: verify

import com.auth0.jwt.interfaces.DecodedJWT; //导入方法依赖的package包/类
@Override
public void verify(DecodedJWT jwt, EncodeType encodeType) throws Exception {
    byte[] contentBytes = String.format("%s.%s", jwt.getHeader(), jwt.getPayload()).getBytes(StandardCharsets.UTF_8);
    byte[] signatureBytes = null;
    String signature = jwt.getSignature();
    String urlDecoded = null;
    switch (encodeType) {
        case Base16:
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = Hex.decodeHex(urlDecoded);
            break;
        case Base32:
            Base32 base32 = new Base32();
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = base32.decode(urlDecoded);
            break;
        case Base64:
            signatureBytes = Base64.decodeBase64(signature);
            break;
    }

    try {
        ECPublicKey publicKey = keyProvider.getPublicKeyById(jwt.getKeyId());
        if (publicKey == null) {
            throw new IllegalStateException("The given Public Key is null.");
        }
        boolean valid = crypto.verifySignatureFor(getDescription(), publicKey, contentBytes, JOSEToDER(signatureBytes));

        if (!valid) {
            throw new SignatureVerificationException(this);
        }
    } catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException | IllegalStateException e) {
        throw new SignatureVerificationException(this, e);
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:36,代码来源:ECDSAAlgorithm.java

示例3: verify

import com.auth0.jwt.interfaces.DecodedJWT; //导入方法依赖的package包/类
@Override
public void verify(DecodedJWT jwt, EncodeType encodeType) throws Exception {
    byte[] contentBytes = String.format("%s.%s", jwt.getHeader(), jwt.getPayload()).getBytes(StandardCharsets.UTF_8);
    byte[] signatureBytes = null;
    String signature = jwt.getSignature();
    String urlDecoded = null;
    switch (encodeType) {
        case Base16:
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = Hex.decodeHex(urlDecoded);
            break;
        case Base32:
            Base32 base32 = new Base32();
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = base32.decode(urlDecoded);
            break;
        case Base64:
            signatureBytes = Base64.decodeBase64(signature);
            break;
    }

    try {
        boolean valid = crypto.verifySignatureFor(getDescription(), secret, contentBytes, signatureBytes);
        if (!valid) {
            throw new SignatureVerificationException(this);
        }
    } catch (IllegalStateException | InvalidKeyException | NoSuchAlgorithmException e) {
        throw new SignatureVerificationException(this, e);
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:31,代码来源:HMACAlgorithm.java

示例4: verify

import com.auth0.jwt.interfaces.DecodedJWT; //导入方法依赖的package包/类
@Override
public void verify(DecodedJWT jwt, EncodeType encodeType) throws Exception {
    byte[] contentBytes = String.format("%s.%s", jwt.getHeader(), jwt.getPayload()).getBytes(StandardCharsets.UTF_8);
    byte[] signatureBytes = null;
    String signature = jwt.getSignature();
    String urlDecoded = null;
    switch (encodeType) {
        case Base16:
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = Hex.decodeHex(urlDecoded);
            break;
        case Base32:
            Base32 base32 = new Base32();
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = base32.decode(urlDecoded);
            break;
        case Base64:
            signatureBytes = Base64.decodeBase64(signature);
            break;
    }

    try {
        RSAPublicKey publicKey = keyProvider.getPublicKeyById(jwt.getKeyId());
        if (publicKey == null) {
            throw new IllegalStateException("The given Public Key is null.");
        }
        boolean valid = crypto.verifySignatureFor(getDescription(), publicKey, contentBytes, signatureBytes);
        if (!valid) {
            throw new SignatureVerificationException(this);
        }
    } catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException | IllegalStateException e) {
        throw new SignatureVerificationException(this, e);
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:35,代码来源:RSAAlgorithm.java

示例5: main

import com.auth0.jwt.interfaces.DecodedJWT; //导入方法依赖的package包/类
public static void main(String[] args) throws UnsupportedEncodingException {


        DecodedJWT jwt = verifyJWT(createJWT());
        String header = jwt.getHeader();
        String payload = jwt.getPayload();
        String signature = jwt.getSignature();

        String jti = jwt.getClaim("jti").asString();
        String issuer = jwt.getIssuer();
    }
 
开发者ID:daishicheng,项目名称:outcomes,代码行数:12,代码来源:JWTUtil.java


注:本文中的com.auth0.jwt.interfaces.DecodedJWT.getSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。