use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class PasswordCredentialVersion method rotate.
public void rotate() {
String decryptedPassword = this.getPassword();
StringGenerationParameters decryptedGenerationParameters = this.getGenerationParameters();
this.setPasswordAndGenerationParameters(decryptedPassword, decryptedGenerationParameters);
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class PasswordCredentialVersion method getGenerationParameters.
public StringGenerationParameters getGenerationParameters() {
String password = getPassword();
Assert.notNull(password, "Password length generation parameter cannot be restored without an existing password");
if (delegate.getEncryptedGenerationParameters() == null) {
return null;
}
String parameterJson = encryptor.decrypt(delegate.getEncryptedGenerationParameters());
if (parameterJson == null) {
return null;
}
try {
StringGenerationParameters passwordGenerationParameters = jsonObjectMapper.deserializeBackwardsCompatibleValue(parameterJson, StringGenerationParameters.class);
passwordGenerationParameters.setLength(password.length());
return passwordGenerationParameters;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class UserCredentialVersion method getGenerationParameters.
public StringGenerationParameters getGenerationParameters() {
String parameterJson = encryptor.decrypt(delegate.getEncryptedGenerationParameters());
String password = this.password == null ? getPassword() : this.password;
if (parameterJson == null) {
return null;
}
try {
StringGenerationParameters generationParameters = jsonObjectMapper.deserializeBackwardsCompatibleValue(parameterJson, StringGenerationParameters.class);
generationParameters.setLength(password.length());
return generationParameters;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class UserCredentialVersion method matchesGenerationParameters.
@Override
public boolean matchesGenerationParameters(GenerationParameters generationParameters) {
final StringGenerationParameters existingGenerationParameters = getGenerationParameters();
final StringGenerationParameters newGenerationParameters = (StringGenerationParameters) generationParameters;
final boolean lengthsMatch = newGenerationParameters.getLength() == existingGenerationParameters.getLength();
final boolean usernamesMatch = getUsername().equals(newGenerationParameters.getUsername()) || existingGenerationParameters.getUsername() == newGenerationParameters.getUsername();
final boolean passwordGenerationParamsMatch = existingGenerationParameters.passwordOptionsEqual(newGenerationParameters);
return lengthsMatch && usernamesMatch && passwordGenerationParamsMatch;
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class UserCredentialVersion method rotate.
@Override
public void rotate() {
String decryptedPassword = getPassword();
StringGenerationParameters decryptedGenerationParameters = getGenerationParameters();
setPassword(decryptedPassword);
setGenerationParameters(decryptedGenerationParameters);
}
Aggregations