use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class PasswordDeserializerTest method shouldReturnTheEncryptedPasswordSentByUserIfValid.
@Test
public void shouldReturnTheEncryptedPasswordSentByUserIfValid() throws InvalidCipherTextException {
String encryptedPassword = new GoCipher().encrypt("password");
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig();
PasswordDeserializer passwordDeserializer = new PasswordDeserializer();
String encrypted = passwordDeserializer.deserialize(null, encryptedPassword, svnMaterialConfig);
assertThat(encrypted, is(encryptedPassword));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class MagicalGoConfigXmlLoader method fromXmlPartial.
public <T> T fromXmlPartial(InputStream inputStream, Class<T> o) throws Exception {
Document document = new SAXBuilder().build(inputStream);
Element element = document.getRootElement();
return classParser(element, o, configCache, new GoCipher(), registry, new ConfigReferenceElements()).parse();
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class GoConfigClassLoader method parseCollection.
@SuppressWarnings("unchecked")
private void parseCollection(Collection collection) {
ConfigCollection collectionAnnotation = annotationFor(aClass, ConfigCollection.class);
Class<?> elementType = collectionAnnotation.value();
for (Element childElement : (List<Element>) e.getChildren()) {
if (isInCollection(childElement, elementType)) {
Class<?> collectionType = findConcreteType(childElement, elementType);
collection.add(classParser(childElement, collectionType, configCache, new GoCipher(), registry, configReferenceElements).parse());
}
}
int minimumSize = collectionAnnotation.minimum();
bombIf(collection.size() < minimumSize, "Required at least " + minimumSize + " subelements to '" + e.getName() + "'. " + "Found " + collection.size() + ".");
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class GoConfigSubtagLoader method parse.
public Object parse() {
Class<?> type = findTypeOfField();
if (type == null) {
return null;
}
ConfigTag tag = GoConfigClassLoader.configTag(type, configCache);
if (configUtil.optionalAndMissingTag(e, tag, findSubTag(field).optional())) {
return null;
}
return GoConfigClassLoader.classParser(configUtil.getChild(e, tag), type, configCache, new GoCipher(), registry, configReferenceElements).parse();
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class EnvironmentVariableConfig method deserialize.
public void deserialize(String name, String value, boolean isSecure, String encryptedValue) throws InvalidCipherTextException {
setName(name);
setIsSecure(isSecure);
if (!isSecure && encryptedValue != null) {
errors().add(ENCRYPTEDVALUE, "You may specify encrypted value only when option 'secure' is true.");
}
if (value != null && encryptedValue != null) {
addError("value", "You may only specify `value` or `encrypted_value`, not both!");
addError(ENCRYPTEDVALUE, "You may only specify `value` or `encrypted_value`, not both!");
}
if (encryptedValue != null) {
setEncryptedValue(new EncryptedVariableValueConfig(encryptedValue));
}
if (isSecure) {
if (value != null) {
setEncryptedValue(new EncryptedVariableValueConfig(new GoCipher().encrypt(value)));
}
} else {
setValue(new VariableValueConfig(value));
}
}
Aggregations