### Question:
AuthorizedKeysDecoder { public PublicKey decodePublicKey(String keyLine) throws Exception { bytes = null; pos = 0; for (String part : keyLine.split(" ")) { if (part.startsWith("AAAA")) { bytes = Base64.decodeBase64(part); break; } } if (bytes == null) { throw new IllegalArgumentException("no Base64 part to decode"); } String type = decodeType(); if (type.equals("ssh-rsa")) { BigInteger e = decodeBigInt(); BigInteger m = decodeBigInt(); RSAPublicKeySpec spec = new RSAPublicKeySpec(m, e); return KeyFactory.getInstance("RSA").generatePublic(spec); } else if (type.equals("ssh-dss")) { BigInteger p = decodeBigInt(); BigInteger q = decodeBigInt(); BigInteger g = decodeBigInt(); BigInteger y = decodeBigInt(); DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g); return KeyFactory.getInstance("DSA").generatePublic(spec); } else { throw new IllegalArgumentException("unknown type " + type); } }  PublicKey decodePublicKey(String keyLine);  }### Answer:
@Test public void testDecodePublicKey_dsa() throws Exception { String encoded = FilesUtils.readStream(getClass().getClassLoader() .getResourceAsStream("keys/dsa@localhost.pub")); PublicKey pk = decoder.decodePublicKey(encoded); assertThat(pk).isNotNull(); assertThat(pk.getAlgorithm()).isEqualTo("DSA"); assertThat(pk.getFormat()).isEqualTo("X.509"); assertThat(pk.getEncoded()).hasSize(443); }
@Test public void testDecodePublicKey_rsa() throws Exception { String encoded = FilesUtils.readStream(getClass().getClassLoader() .getResourceAsStream("keys/rsa@localhost.pub")); PublicKey pk = decoder.decodePublicKey(encoded); assertThat(pk).isNotNull(); assertThat(pk.getAlgorithm()).isEqualTo("RSA"); assertThat(pk.getFormat()).isEqualTo("X.509"); assertThat(pk.getEncoded()).hasSize(292); }