/** * Assert that none of the strings in the list are encrypted */ public static void notEncrypted(List<String> strings) { for (String string : strings) { notEncrypted(string); } }
/** * Assert that none of the strings are encrypted * * @deprecated use notEncrypted instead * @see notEncrypted */ @Deprecated public static void decrypted(List<String> strings) { notEncrypted(strings); }
/** * Assert that <code>text</code> is not encrypted * * @deprecated use notEncrypted instead * @see notEncrypted */ @Deprecated public static void decrypted(String text) { notEncrypted(text); }
public static String wrap(String text) { Assert.noBlanks(text); Assert.notEncrypted(text); return MAGIC_PREFIX + text; }
private void validate(EncContext ctx, boolean required, Optional<String> password) { Assert.notNull(ctx.getTextEncryptor(), "'textEncryptor' cannot be null"); Assert.notNull(ctx.getStrength(), "'strength' cannot be null"); if (required) { Assert.isTrue(ctx.getTextEncryptor().isPresent()); } if (password.isPresent()) { Assert.noBlanks(password.get()); Assert.notEncrypted(password.get()); Assert.notConcealed(password.get()); } }
@Override public String encrypt(String text) { if (EncUtils.isEncrypted(text)) { return text; // It's already encrypted, just return it } Assert.notEncrypted(text); String encryptedText = encryptor.encrypt(text); return EncUtils.wrap(encryptedText); }
private static void validate(ChannelContext ctx) { checkNotBlank(ctx.hostname, "hostname"); checkNotBlank(ctx.encoding, "encoding"); Assert.noNulls(ctx.getUsername(), ctx.getConnectTimeout(), ctx.getOptions(), ctx.getKnownHosts(), ctx.getConfig(), ctx.getPrivateKeyFiles(), ctx.getPrivateKeys()); Assert.isPort(ctx.getPort()); Assert.positive(ctx.getWaitForClosedSleepMillis()); Assert.notEncrypted(ctx.getPrivateKeys()); if (ctx.isUseConfigFile()) { Assert.exists(ctx.getConfig()); Assert.isTrue(ctx.getConfig().canRead(), "[" + ctx.getConfig() + "] exists but is not readable"); } if (ctx.getConnectTimeout().isPresent()) { Assert.positive(ctx.getConnectTimeout().get()); } }