public String getCredentialsKey() { return key != null ? key : getProjectProperty(CredentialsPlugin.CREDENTIALS_KEY_PROPERTY); }
addCredentials.setDescription("Adds the credentials specified through the project properties 'credentialsKey' and 'credentialsValue'."); addCredentials.setGroup("Credentials"); addCredentials.setCredentialsEncryptor(credentialsEncryptor); addCredentials.setCredentialsPersistenceManager(credentialsPersistenceManager); addCredentials.getOutputs().upToDateWhen(AlwaysFalseSpec.INSTANCE); LOGGER.debug(String.format("Registered task '%s'", addCredentials.getName()));
@TaskAction void addCredentials() throws IOException { // get credentials key and value from the project properties String key = getCredentialsKey(); String value = getCredentialsValue(); char[] placeholderValue = new char[value.length()]; Arrays.fill(placeholderValue, '*'); LOGGER.debug(String.format("Add credentials with key: '%s', value: '%s'", key, new String(placeholderValue))); // read the current persisted credentials OrderedProperties credentials = credentialsPersistenceManager.readCredentials(); // encrypt value and update credentials String encryptedValue = credentialsEncryptor.encrypt(value); credentials.setProperty(key, encryptedValue); // persist the updated credentials credentialsPersistenceManager.storeCredentials(credentials); }
private String getProjectProperty(String key) { return (String) getProject().getProperties().get(key); }
addCredentials.setDescription("Adds the credentials specified through the project properties 'credentialsKey' and 'credentialsValue'."); addCredentials.setGroup("Credentials"); addCredentials.setCredentialsEncryptor(credentialsEncryptor); addCredentials.setCredentialsPersistenceManager(credentialsPersistenceManager); addCredentials.getOutputs().upToDateWhen(AlwaysFalseSpec.INSTANCE); LOGGER.debug(String.format("Registered task '%s'", addCredentials.getName()));
@TaskAction void addCredentials() { // get credentials key and value from the command line or project properties String key = getCredentialsKey(); if (key == null) { throw new IllegalArgumentException("Credentials key must not be null"); } String value = getCredentialsValue(); if (value == null) { throw new IllegalArgumentException("Credentials value must not be null"); } char[] placeholderValue = new char[value.length()]; Arrays.fill(placeholderValue, '*'); LOGGER.debug(String.format("Add credentials with key: '%s', value: '%s'", key, new String(placeholderValue))); // read the current persisted credentials OrderedProperties credentials = credentialsPersistenceManager.readCredentials(); // encrypt value and update credentials String encryptedValue = credentialsEncryptor.encrypt(value); credentials.setProperty(key, encryptedValue); // persist the updated credentials credentialsPersistenceManager.storeCredentials(credentials); }
private String getProjectProperty(String key) { return (String) getProject().getProperties().get(key); }
public String getCredentialsValue() { return value != null ? value : getProjectProperty(CredentialsPlugin.CREDENTIALS_VALUE_PROPERTY); }
@Internal("Do not annotate as @Input to avoid the value being stored in the task artifact cache") public String getCredentialsValue() { return value != null ? value : getProjectProperty(CredentialsPlugin.CREDENTIALS_VALUE_PROPERTY); }
@Internal("Do not annotate as @Input to avoid the key being stored in the task artifact cache") public String getCredentialsKey() { return key != null ? key : getProjectProperty(CredentialsPlugin.CREDENTIALS_KEY_PROPERTY); }