@Test public void isLocked() { KeyData keyData = new KeyData(); keyData.setPublicKey("PUBLIC_KEY"); KeyDataConfig keyDataConfig = new KeyDataConfig(mock(PrivateKeyData.class), PrivateKeyType.LOCKED); keyData.setConfig(keyDataConfig); assertThat(KeyDataUtil.isLocked(keyData)).isTrue(); keyData.setConfig(null); assertThat(KeyDataUtil.isLocked(keyData)).isFalse(); keyData.setConfig(new KeyDataConfig()); assertThat(KeyDataUtil.isLocked(keyData)).isFalse(); }
public static boolean isLocked(KeyData keyData) { if (isFileSystem(keyData)) { final KeyDataConfig keyDataConfig = JaxbUtil.unmarshal( IOCallback.execute(() -> Files.newInputStream(keyData.getPrivateKeyPath())), KeyDataConfig.class); return keyDataConfig.getType() == PrivateKeyType.LOCKED; } if (Objects.isNull(keyData.getConfig())) { return false; } return keyData.getConfig().getType() == PrivateKeyType.LOCKED; }
KeyDataUtil { public static boolean isLocked(KeyData keyData) { if (isFileSystem(keyData)) { final KeyDataConfig keyDataConfig = JaxbUtil.unmarshal( IOCallback.execute(() -> Files.newInputStream(keyData.getPrivateKeyPath())), KeyDataConfig.class); return keyDataConfig.getType() == PrivateKeyType.LOCKED; } if (Objects.isNull(keyData.getConfig())) { return false; } return keyData.getConfig().getType() == PrivateKeyType.LOCKED; } }
KeyDataUtil { public static boolean isLocked(KeyData keyData) { if (isFileSystem(keyData)) { final KeyDataConfig keyDataConfig = JaxbUtil.unmarshal( IOCallback.execute(() -> Files.newInputStream(keyData.getPrivateKeyPath())), KeyDataConfig.class); return keyDataConfig.getType() == PrivateKeyType.LOCKED; } if (Objects.isNull(keyData.getConfig())) { return false; } return keyData.getConfig().getType() == PrivateKeyType.LOCKED; } private  KeyDataUtil(); }
KeyDataUtil { public static boolean isLocked(KeyData keyData) { if (isFileSystem(keyData)) { final KeyDataConfig keyDataConfig = JaxbUtil.unmarshal( IOCallback.execute(() -> Files.newInputStream(keyData.getPrivateKeyPath())), KeyDataConfig.class); return keyDataConfig.getType() == PrivateKeyType.LOCKED; } if (Objects.isNull(keyData.getConfig())) { return false; } return keyData.getConfig().getType() == PrivateKeyType.LOCKED; } private  KeyDataUtil(); static Class<? extends ConfigKeyPair> getKeyPairTypeFor(KeyData keyData); static boolean isLocked(KeyData keyData); static boolean isDirect(KeyData keyData); static boolean isInline(KeyData keyData); static boolean isAzure(KeyData keyData); static boolean isHashicorp(KeyData keyData); static boolean isAws(KeyData keyData); static boolean isFileSystem(KeyData keyData); static boolean isUnsupported(KeyData keyData); static ConfigKeyPair unmarshal(final KeyData keyData, final KeyEncryptor keyEncryptor); static KeyData marshal(final ConfigKeyPair keyPair); }
KeyDataUtil { public static boolean isLocked(KeyData keyData) { if (isFileSystem(keyData)) { final KeyDataConfig keyDataConfig = JaxbUtil.unmarshal( IOCallback.execute(() -> Files.newInputStream(keyData.getPrivateKeyPath())), KeyDataConfig.class); return keyDataConfig.getType() == PrivateKeyType.LOCKED; } if (Objects.isNull(keyData.getConfig())) { return false; } return keyData.getConfig().getType() == PrivateKeyType.LOCKED; } private  KeyDataUtil(); static Class<? extends ConfigKeyPair> getKeyPairTypeFor(KeyData keyData); static boolean isLocked(KeyData keyData); static boolean isDirect(KeyData keyData); static boolean isInline(KeyData keyData); static boolean isAzure(KeyData keyData); static boolean isHashicorp(KeyData keyData); static boolean isAws(KeyData keyData); static boolean isFileSystem(KeyData keyData); static boolean isUnsupported(KeyData keyData); static ConfigKeyPair unmarshal(final KeyData keyData, final KeyEncryptor keyEncryptor); static KeyData marshal(final ConfigKeyPair keyPair);  }