From Sexy Flamingo, 5 Years ago, written in Plain Text.
This paste is a reply to Untitled from Buff Monkey - go back
Embed
Viewing differences between Untitled and Re: Untitled
JWTHelper:
public String generateToken(String payload, Key key) {
        return builderFactory
                .createJwtBuilder()
                .setPayload(payload)
                .setHeaderParam("typ", "JWT")
                .setHeaderParam("alg", signatureAlgorithm.getValue())
                .signWith(key, signatureAlgorithm)
                .compact();
    }

Caller statement: OAuthService
String strPrivateKey = encryptionUtilities.aesDecrypt(toolConfiguration.getPlatformPrivateKey(),
                    aesSecretKey);
PrivateKey privateKey = encryptionUtilities.string2PrivateKey(strPrivateKey);
            long startTime = System.currentTimeMillis();
            String accessToken = jwtHelper.generateToken(payload, privateKey, tokenExpirationInMilliSeconds);
            LOGGER.info("Time spend in getOauthToken jwtHelper.generateToken {}", System.currentTimeMillis() - startTime);


EncryptionUtil.java
public PrivateKey string2PrivateKey(String privateKeyString) {
        long startTime = System.currentTimeMillis();
        try {
            KeyFactory kf = KeyFactory.getInstance(ServiceConstants.RSA);
            PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKeyString));
            PrivateKey privateKey = kf.generatePrivate(keySpecPKCS8);
            LOGGER.info("Time spend in string2PrivateKey {}", System.currentTimeMillis() - startTime);
            return privateKey;
        } catch (IllegalArgumentException | InvalidKeySpecException | NoSuchAlgorithmException e) {
            LOGGER.error(e.getMessage(), e);
            return null;
        }
    }

Replies to Re: Untitled rss

Title Name Language When
Re: Re: Untitled Speedy Butterfly text 5 Years ago.