public String deserialize(String password, String encryptedPassword, AbstractMaterialConfig materialConfig) { if (isNotBlank(password) && isNotBlank(encryptedPassword)) { materialConfig.addError(PASSWORD, "You may only specify `password` or `encrypted_password`, not both!"); materialConfig.addError(ScmMaterialConfig.ENCRYPTED_PASSWORD, "You may only specify `password` or `encrypted_password`, not both!"); } if (isNotBlank(password)) { try { return goCipher.encrypt(password); } catch (CryptoException e) { materialConfig.addError(PASSWORD, "Could not encrypt the password. This usually happens when the cipher text is invalid"); } } else if (isNotBlank(encryptedPassword)) { try { goCipher.decrypt(encryptedPassword); } catch (Exception e) { materialConfig.addError(ENCRYPTED_PASSWORD, "Encrypted value for password is invalid. This usually happens when the cipher text is invalid."); } return goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword); } return null; } }
@Override public void validateNameUniqueness(Map<CaseInsensitiveString, AbstractMaterialConfig> map) { if (StringUtils.isBlank(scmId)) { return; } if (map.containsKey(new CaseInsensitiveString(scmId))) { AbstractMaterialConfig material = map.get(new CaseInsensitiveString(scmId)); material.addError(SCM_ID, "Duplicate SCM material detected!"); addError(SCM_ID, "Duplicate SCM material detected!"); } else { map.put(new CaseInsensitiveString(scmId), this); } }
@Override public void validateNameUniqueness(Map<CaseInsensitiveString, AbstractMaterialConfig> map) { if (StringUtils.isBlank(packageId)) { return; } if (map.containsKey(new CaseInsensitiveString(packageId))) { AbstractMaterialConfig material = map.get(new CaseInsensitiveString(packageId)); material.addError(PACKAGE_ID, "Duplicate package material detected!"); addError(PACKAGE_ID, "Duplicate package material detected!"); } else { map.put(new CaseInsensitiveString(packageId), this); } } }