使用JWT&解密或解码Java的

时间:2017-05-22 19:30:49

标签: java authentication jwt

我正在尝试使用JWT解密令牌以获取少量用户信息。

String se="AEWG4RS5MmQL_ev-jgI8Zw==";
 String jwt="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjBpMW1WX2hfeVBqUXJlck9uS21mdTI4SW9MMCIsImtpZCI6IjBpMW1WX2hfeVBqUXJlck9uS21mdTI4SW9MMCJ9.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmNsb3VkLmNvbS9jb3JlIiwiYXVkIjoiQUVXRzRSUzVNbVFMX2V2LWpnSThadz09IiwiZXhwIjoxNDk1NDQ2MDAzLCJuYmYiOjE0OTU0NDU3MDMsImlhdCI6MTQ5NTQ0NTcwMywic2lkIjoiYjY0ZTU5MDZkNzczYzRiNzEyOWQ4MWY3ZmQ0NGI3ZDMiLCJzdWIiOiI5MTk4MzE2MTc2MDE5MTUzMDYxIiwiaWRwIjoiaWRzcnYiLCJlbWFpbCI6ImVsZWFyaW5ndGVzdEBtYWlsaW5hdG9yLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjoiVHJ1ZSIsIm5hbWUiOiJFbGVhcmluZ1Rlc3QgRWxlYXJpbmdUZXN0IiwiZ2l2ZW5fbmFtZSI6IkVsZWFyaW5nVGVzdCIsImZhbWlseV9uYW1lIjoiRWxlYXJpbmdUZXN0IiwiYXV0aF90aW1lIjoxNDk1NDQ1Njc3LCJjdHhfYXV0aF9hbGlhcyI6ImVsZWFyaW5ndGVzdEBtYWlsaW5hdG9yLmNvbSIsImN0eF9hdXRoX2FsaWFzX2NsYWltcyI6Ilt7XCJOYW1lXCI6XCJJVDpPcmdJZFwiLFwiVmFsdWVcIjpcIjUxMzY0ODcyXCJ9LHtcIk5hbWVcIjpcIklUOlBlcnNvbklkXCIsXCJWYWx1ZVwiOlwiMTQ0ODYyMzlcIn1dIiwiY3R4X3N5c3RlbV9hbGlhc2VzIjoiW10iLCJhbXIiOlsicGFzc3dvcmQiXX0.woWtiNFp8YkRLQUGdqscpBvgAo3nkjU_zfeeBhDFAdjyIQZy1soMK_xTWRyt6anQxyGAg32zeXsi45_ROR7JpYhpbQHT7EHVbXQ4XCGRFfnhZt3MmOwOetRzzXM5d_wShvFq8qIIlE9vWXMEOsbvv8E0GOoZzN5fDxxavlw9S-zk_lKuDTVL4jiikvxT9Iv5UABOubBReNNU9ayXBGps3KHUp2X3Kxy_9fhRsWUqOlreuG914pTHOF6kKRLrmc9UY5jJ9cA7SLilRhvpjMk-ULJQEi4eGL0bnbGX8rdIii3rZBdSwsYC8UaUtMOAP6KKJpIXR699D4F5Q9kw-71Pvg";
    Claims claims=null;
    try {
        claims = Jwts.parser()              
          .setSigningKey(se)
           .parseClaimsJws(jwt).getBody();
    } catch (UnsupportedJwtException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

但是当我尝试执行代码时,我收到以下错误

java.lang.IllegalArgumentException: Key bytes cannot be specified for RSA signatures.  Please specify a PublicKey or PrivateKey instance.
你可以帮我解决这个问题吗?

0 个答案:

没有答案