@Test public void testParseAuthorizedKey() { try { AuthorizedKeys.AuthorizedKey authorizedKey = AuthorizedKeys.parseAuthorizedKey(TEST_AUTHORIZED_KEY); assertNotNull("authorizedKey should not be null", authorizedKey); assertEquals("authorizedKey format should be", "ssh-rsa", authorizedKey.getFormat()); assertEquals( "authorizedKey encodedKey should be", "AAAAB3NzaC1yc2EAAAADAQABAAAAgQC+Fz0pqK+XoCcukPhnPD+M1zb+FImbh5Lu3pkfW5DM67B6Hr9Q28LuWgNTfLqUn9o01W0TYzXDxtKG9psGuQ0wFJmqYJNbP6eRB3gimcr+C/eyy7N/evs8E36iMi7Si1piPd7QJ5l3D/tThI5cAACHYN0uqwphpXt4Lw2OZxIAQw==", authorizedKey.getEncodedKey() ); assertEquals("authorizedKey comment should be", "dummy@nowhere", authorizedKey.getComment()); File rsaPubKeyFile = KeyTestUtil.getPublicKeyAsFile("b1024", "id_rsa"); List<AuthorizedKeys.AuthorizedKey> authorizedKeys = AuthorizedKeys.parseAuthorizedKeys(rsaPubKeyFile); assertEquals("rsaPubKeyFile should only contain one pubkey", 1, authorizedKeys.size()); } catch (Exception e) { FailUtil.sprintFail(e); } }
static AuthorizedKey parseAuthorizedKey(String authorizedKeyString) { if (authorizedKeyString != null) { Matcher matcher = AUTHORIZED_KEY_PATTERN.matcher(authorizedKeyString); if (matcher.find()) { String format = matcher.group(GROUP_FORMAT); String encodedKey = matcher.group(GROUP_KEY); String comment = matcher.group(GROUP_COMMENT); return new AuthorizedKey(format, encodedKey, comment); } } return null; }
AuthorizedKeys { static AuthorizedKey parseAuthorizedKey(String authorizedKeyString) { if (authorizedKeyString != null) { Matcher matcher = AUTHORIZED_KEY_PATTERN.matcher(authorizedKeyString); if (matcher.find()) { String format = matcher.group(GROUP_FORMAT); String encodedKey = matcher.group(GROUP_KEY); String comment = matcher.group(GROUP_COMMENT); return new AuthorizedKey(format, encodedKey, comment); } } return null; } }
AuthorizedKeys { static AuthorizedKey parseAuthorizedKey(String authorizedKeyString) { if (authorizedKeyString != null) { Matcher matcher = AUTHORIZED_KEY_PATTERN.matcher(authorizedKeyString); if (matcher.find()) { String format = matcher.group(GROUP_FORMAT); String encodedKey = matcher.group(GROUP_KEY); String comment = matcher.group(GROUP_COMMENT); return new AuthorizedKey(format, encodedKey, comment); } } return null; }  }
AuthorizedKeys { static AuthorizedKey parseAuthorizedKey(String authorizedKeyString) { if (authorizedKeyString != null) { Matcher matcher = AUTHORIZED_KEY_PATTERN.matcher(authorizedKeyString); if (matcher.find()) { String format = matcher.group(GROUP_FORMAT); String encodedKey = matcher.group(GROUP_KEY); String comment = matcher.group(GROUP_COMMENT); return new AuthorizedKey(format, encodedKey, comment); } } return null; }  static Keychain defaultKeychain(); static Keychain newKeychain(File authorizedKeysFile); }
AuthorizedKeys { static AuthorizedKey parseAuthorizedKey(String authorizedKeyString) { if (authorizedKeyString != null) { Matcher matcher = AUTHORIZED_KEY_PATTERN.matcher(authorizedKeyString); if (matcher.find()) { String format = matcher.group(GROUP_FORMAT); String encodedKey = matcher.group(GROUP_KEY); String comment = matcher.group(GROUP_COMMENT); return new AuthorizedKey(format, encodedKey, comment); } } return null; }  static Keychain defaultKeychain(); static Keychain newKeychain(File authorizedKeysFile);  }