@Test public void parseAuthorizedKeys() throws Exception { InputStream is = getClass().getResourceAsStream("/keys/authorized_keys"); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); Assert.assertEquals(5, keys.size()); assertsRsaKey((RSAPublicKey)keys.get(0)); assertsDsaKey((DSAPublicKey)keys.get(1)); assertsEcdsaKey((ECPublicKey)keys.get(2)); assertsEcdsaKey384((ECPublicKey)keys.get(3)); assertsEcdsaKey521((ECPublicKey)keys.get(4)); }
@Test public void parsePubKeyEcdsa384() throws Exception { InputStream is = getClass().getResourceAsStream("/keys/ecdsa.key.pub.384"); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); assertsEcdsaKey384((ECPublicKey)keys.get(0)); }
@Test public void parsePubKeyEcdsa() throws Exception { InputStream is = getClass().getResourceAsStream("/keys/ecdsa.key.pub"); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); assertsEcdsaKey((ECPublicKey)keys.get(0)); }
@Test public void noSpaceInKey() throws Exception { String key = "no-space"; InputStream is = new ByteArrayInputStream(key.getBytes("UTF8")); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); Assert.assertTrue(keys.isEmpty()); }
@Test public void parsePubKeyDsa() throws Exception { InputStream is = getClass().getResourceAsStream("/keys/dsa.key.pub"); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); assertsDsaKey((DSAPublicKey)keys.get(0)); }
@Test public void parsePubKeyRsa() throws Exception { InputStream is = getClass().getResourceAsStream("/keys/rsa.key.pub"); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); assertsRsaKey((RSAPublicKey)keys.get(0)); }
@Test public void parsePubKeyEcdsa521() throws Exception { InputStream is = getClass().getResourceAsStream("/keys/ecdsa.key.pub.521"); List<PublicKey> keys = KeyParser.parsePublicKeys(is, new CommonsBase64Decoder()); assertsEcdsaKey521((ECPublicKey)keys.get(0)); }