/** * Attempts to treat the given string first as a cipher text, and if it doesn't work, * treat the given string as the unencrypted secret value. * * <p> * Useful for recovering a value from a form field. */ @Nonnull public static Secret fromString(@CheckForNull String data) { data = Util.fixNull(data); Secret s = decrypt(data); if(s==null) s=new Secret(data); return s; }
return Jenkins.ANONYMOUS; Secret oldSecret = Secret.decrypt(val); if (oldSecret != null) { LOGGER.log(Level.FINE, "Ignoring insecure stored CLI authentication for {0}", oldSecret.getPlainText());
/** * Writes {@code config.xml} to the specified output stream. * The user must have at least {@link #EXTENDED_READ}. * If he lacks {@link #CONFIGURE}, then any {@link Secret}s detected will be masked out. */ @Restricted(NoExternalUse.class) public void writeConfigDotXml(OutputStream os) throws IOException { checkPermission(EXTENDED_READ); XmlFile configFile = getConfigFile(); if (hasPermission(CONFIGURE)) { IOUtils.copy(configFile.getFile(), os); } else { String encoding = configFile.sniffEncoding(); String xml = FileUtils.readFileToString(configFile.getFile(), encoding); Matcher matcher = SECRET_PATTERN.matcher(xml); StringBuffer cleanXml = new StringBuffer(); while (matcher.find()) { if (Secret.decrypt(matcher.group(1)) != null) { matcher.appendReplacement(cleanXml, ">********<"); } } matcher.appendTail(cleanXml); org.apache.commons.io.IOUtils.write(cleanXml.toString(), os, encoding); } }
Matcher matcher = AbstractItem.SECRET_PATTERN.matcher(srcConfigFile.asString()); while (matcher.find()) { if (Secret.decrypt(matcher.group(1)) != null) {
/** * Attempts to treat the given string first as a cipher text, and if it doesn't work, * treat the given string as the unencrypted secret value. * * <p> * Useful for recovering a value from a form field. */ @Nonnull public static Secret fromString(@CheckForNull String data) { data = Util.fixNull(data); Secret s = decrypt(data); if(s==null) s=new Secret(data); return s; }
/** * Attempts to treat the given string first as a cipher text, and if it doesn't work, * treat the given string as the unencrypted secret value. * * <p> * Useful for recovering a value from a form field. * * @return never null */ public static Secret fromString(String data) { data = Util.fixNull(data); Secret s = decrypt(data); if(s==null) s=new Secret(data); return s; }
/** * Attempts to treat the given string first as a cipher text, and if it doesn't work, * treat the given string as the unencrypted secret value. * * <p> * Useful for recovering a value from a form field. * * @return never null */ public static Secret fromString(String data) { data = Util.fixNull(data); Secret s = decrypt(data); if(s==null) s=new Secret(data); return s; }
/** * Attempts to treat the given string first as a cipher text, and if it * doesn't work, treat the given string as the unencrypted secret value. * * <p> Useful for recovering a value from a form field. * * @return never null */ public static Secret fromString(String data) { data = Util.fixNull(data); Secret s = decrypt(data); if (s == null) { s = new Secret(data); } return s; }
/** * Attempts to treat the given string first as a cipher text, and if it doesn't work, * treat the given string as the unencrypted secret value. * * <p> * Useful for recovering a value from a form field. * * @return never null */ public static Secret fromString(String data) { data = Util.fixNull(data); Secret s = decrypt(data); if(s==null) s=new Secret(data); return s; }
/** * Writes {@code config.xml} to the specified output stream. * The user must have at least {@link #EXTENDED_READ}. * If he lacks {@link #CONFIGURE}, then any {@link Secret}s detected will be masked out. */ @Restricted(NoExternalUse.class) public void writeConfigDotXml(OutputStream os) throws IOException { checkPermission(EXTENDED_READ); XmlFile configFile = getConfigFile(); if (hasPermission(CONFIGURE)) { IOUtils.copy(configFile.getFile(), os); } else { String encoding = configFile.sniffEncoding(); String xml = FileUtils.readFileToString(configFile.getFile(), encoding); Matcher matcher = SECRET_PATTERN.matcher(xml); StringBuffer cleanXml = new StringBuffer(); while (matcher.find()) { if (Secret.decrypt(matcher.group(1)) != null) { matcher.appendReplacement(cleanXml, ">********<"); } } matcher.appendTail(cleanXml); org.apache.commons.io.IOUtils.write(cleanXml.toString(), os, encoding); } }
return Jenkins.ANONYMOUS; Secret oldSecret = Secret.decrypt(val); if (oldSecret != null) { LOGGER.log(Level.FINE, "Ignoring insecure stored CLI authentication for {0}", oldSecret.getPlainText());
private void buildProxyEnvVars(EnvVars env, TaskListener log) throws IOException, URISyntaxException { ProxyConfiguration proxycfg = Jenkins.getActiveInstance().proxy; if (proxycfg == null) { // no proxy configured return; } String userInfo = proxycfg.getUserName(); // append password only if userName if is defined if (userInfo != null && proxycfg.getEncryptedPassword() != null) { userInfo += ":" + Secret.decrypt(proxycfg.getEncryptedPassword()); } String proxyURL = new URI("http", userInfo, proxycfg.name, proxycfg.port, null, null, null).toString(); // refer to https://docs.npmjs.com/misc/config#https-proxy env.put("HTTP_PROXY", proxyURL); env.put("HTTPS_PROXY", proxyURL); String noProxyHosts = proxycfg.noProxyHost; if (noProxyHosts != null) { if (noProxyHosts.contains("*")) { log.getLogger().println("INFO: npm doesn't support wild card in no_proxy configuration"); } // refer to https://github.com/npm/npm/issues/7168 env.put("NO_PROXY", noProxyHosts.replaceAll("(\r?\n)+", ",")); } }
/** * Gets the persisted authentication for this Hudson. * * @return {@link Hudson#ANONYMOUS} if no such credential is found, or if * the stored credential is invalid. */ public Authentication get() { Secret userName = Secret.decrypt(props.getProperty(getPropertyKey())); if (userName == null) { return Hudson.ANONYMOUS; // failed to decrypt } try { UserDetails u = HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getSecurityRealm().loadUserByUsername(userName.toString()); return new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), u.getAuthorities()); } catch (AuthenticationException e) { return Hudson.ANONYMOUS; } catch (DataAccessException e) { return Hudson.ANONYMOUS; } }
/** * Gets the persisted authentication for this Hudson. * * @return {@link Hudson#ANONYMOUS} if no such credential is found, or if the stored credential is invalid. */ public Authentication get() { Hudson h = Hudson.getInstance(); Secret userName = Secret.decrypt(props.getProperty(getPropertyKey())); if (userName==null) return Hudson.ANONYMOUS; // failed to decrypt try { UserDetails u = h.getSecurityRealm().loadUserByUsername(userName.toString()); return new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), u.getAuthorities()); } catch (AuthenticationException e) { return Hudson.ANONYMOUS; } catch (DataAccessException e) { return Hudson.ANONYMOUS; } }
/** * Gets the persisted authentication for this Hudson. * * @return {@link Hudson#ANONYMOUS} if no such credential is found, or if the stored credential is invalid. */ public Authentication get() { Hudson h = Hudson.getInstance(); Secret userName = Secret.decrypt(props.getProperty(getPropertyKey())); if (userName==null) return Hudson.ANONYMOUS; // failed to decrypt try { UserDetails u = h.getSecurityRealm().loadUserByUsername(userName.toString()); return new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), u.getAuthorities()); } catch (AuthenticationException e) { return Hudson.ANONYMOUS; } catch (DataAccessException e) { return Hudson.ANONYMOUS; } }
/** * Gets the persisted authentication for this Hudson. * * @return {@link Hudson#ANONYMOUS} if no such credential is found, or if the stored credential is invalid. */ public Authentication get() { Hudson h = Hudson.getInstance(); Secret userName = Secret.decrypt(props.getProperty(getPropertyKey())); if (userName==null) return Hudson.ANONYMOUS; // failed to decrypt try { UserDetails u = h.getSecurityRealm().loadUserByUsername(userName.toString()); return new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), u.getAuthorities()); } catch (AuthenticationException e) { return Hudson.ANONYMOUS; } catch (DataAccessException e) { return Hudson.ANONYMOUS; } }
Matcher matcher = AbstractItem.SECRET_PATTERN.matcher(srcConfigFile.asString()); while (matcher.find()) { if (Secret.decrypt(matcher.group(1)) != null) {