OpenID Connect jwk에 대해서

KeyPairGenerator keygen = KeyPairGenerator.getInstance(“RSA”); SecureRandom random = new SecureRandom(); keygen.initialize(1024, random); KeyPair keys = keygen.generateKeyPair(); PublicKey pubkey = keys.getPublic(); PrivateKey privkey = keys.getPrivate(); System.out.println(“PublicKey => “+(new String(Base64.encodeBase64(pubkey.getEncoded()))) ); System.out.println(“PrivateKey => “+(new String(Base64.encodeBase64(privkey.getEncoded()))) ); byte[] array = ((RSAPublicKey)pubkey).getModulus().toByteArray(); if (array[0] == 0) { byte[] tmp = new byte[array.length – 1]; System.arraycopy(array, 1, tmp, 0, tmp.length); array = tmp; } System.out.println(“n => “+ (new String(Base64.encodeBase64(array))) ); array = ((RSAPublicKey)pubkey).getPublicExponent().toByteArray(); if (array[0] == 0) { byte[] tmp = new byte[array.length – 1]; System.arraycopy(array, 1, tmp, 0, tmp.length); array = tmp; } System.out.println(“e => ” + (new String(Base64.encodeBase64(array))) ); ]]>

Related Posts