hudson.Util.toHexString()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(249)

本文整理了Java中hudson.Util.toHexString()方法的一些代码示例,展示了Util.toHexString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.toHexString()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:toHexString

Util.toHexString介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

public static String generateCookie() {
  byte[] cookie = new byte[32];
  secureRandom.nextBytes(cookie);
  return Util.toHexString(cookie);
}

代码示例来源:origin: jenkinsci/jenkins

@Nonnull
public static String toHexString(@Nonnull byte[] bytes) {
  return toHexString(bytes,0,bytes.length);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Determines the file name from md5sum.
 */
private static @Nonnull File getFingerprintFile(@Nonnull byte[] md5sum) {
  assert md5sum.length==16;
  return new File( Jenkins.getInstance().getRootDir(),
    "fingerprints/"+ Util.toHexString(md5sum,0,1)+'/'+Util.toHexString(md5sum,1,1)+'/'+Util.toHexString(md5sum,2,md5sum.length-2)+".xml");
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets the MD5 hash string.
 */
@Exported(name="hash")
public @Nonnull String getHashString() {
  return Util.toHexString(md5sum);
}

代码示例来源:origin: jenkinsci/jenkins

@SuppressFBWarnings("NP_NONNULL_RETURN_VIOLATION")
private @Nonnull String plainSecretToHashInHex(@Nonnull String secretValueInPlainText) {
  byte[] hashBytes = plainSecretToHashBytes(secretValueInPlainText);
  return Util.toHexString(hashBytes);
}

代码示例来源:origin: jenkinsci/jenkins

@Deprecated
private void _changeApiToken(){
  byte[] random = new byte[16];   // 16x8=128bit worth of randomness, since we use md5 digest as the API token
  RANDOM.nextBytes(random);
  apiToken = Secret.fromString(Util.toHexString(random));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Computes the message authentication code and return it as a string.
 * While redundant, often convenient.
 */
public String mac(String message) {
  try {
    return Util.toHexString(mac(message.getBytes("UTF-8")));
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * @param build
 *      set to non-null if {@link Fingerprint} to be created (if so)
 *      will have this build as the owner. Otherwise null, to indicate
 *      an owner-less build.
 * @throws IOException Loading error
 */
public @Nonnull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @Nonnull String fileName, @Nonnull byte[] md5sum) throws IOException {
  return getOrCreate(build,fileName, Util.toHexString(md5sum));
}

代码示例来源:origin: jenkinsci/jenkins

public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
  byte[] data = (byte[]) source;
  writer.setValue(Util.toHexString(data));
}

代码示例来源:origin: jenkinsci/jenkins

return toHexString(md5.digest());
} catch (NoSuchAlgorithmException e) {
  throw new IOException("MD5 not installed",e);    // impossible

代码示例来源:origin: jenkinsci/jenkins

public InputStream extract(InputStream _in) throws IOException {
  HeadBufferingStream in = new HeadBufferingStream(_in,SIDE_BUFFER_SIZE);
  try {
    return new GZIPInputStream(in, 8192, true);
  } catch (IOException e) {
    // various people reported "java.io.IOException: Not in GZIP format" here, so diagnose this problem better
    in.fillSide();
    throw new IOException(e.getMessage()+"\nstream="+Util.toHexString(in.getSideBuffer()),e);
  }
}
public OutputStream compress(OutputStream out) throws IOException {

代码示例来源:origin: jenkinsci/jenkins

/**
 * {@inheritDoc}
 */
@Override
protected synchronized String issueCrumb(ServletRequest request, String salt) {
  if (request instanceof HttpServletRequest) {
    if (md != null) {
      HttpServletRequest req = (HttpServletRequest) request;
      StringBuilder buffer = new StringBuilder();
      Authentication a = Jenkins.getAuthentication();
      if (a != null) {
        buffer.append(a.getName());
      }
      buffer.append(';');
      if (!isExcludeClientIPFromCrumb()) {
        buffer.append(getClientIP(req));
      }
      md.update(buffer.toString().getBytes());
      return Util.toHexString(md.digest(salt.getBytes()));
    }
  }
  return null;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Create a new token with the given name and return it id and secret value. 
 * Result meant to be sent / displayed and then discarded.
 */
public synchronized @Nonnull TokenUuidAndPlainValue generateNewToken(@Nonnull String name) {
  // 16x8=128bit worth of randomness, using brute-force you need on average 2^127 tries (~10^37)
  byte[] random = new byte[16];
  RANDOM.nextBytes(random);
  String secretValue = Util.toHexString(random);
  String tokenTheUserWillUse = HASH_VERSION + secretValue;
  assert tokenTheUserWillUse.length() == 2 + 32;
  
  String secretValueHashed = this.plainSecretToHashInHex(secretValue);
  
  HashValue hashValue = new HashValue(HASH_VERSION, secretValueHashed);
  HashedToken token = HashedToken.buildNew(name, hashValue);
  
  this.addToken(token);
  
  return new TokenUuidAndPlainValue(token.uuid, tokenTheUserWillUse);
}

代码示例来源:origin: jenkinsci/gitlab-plugin

public void doGenerateSecretToken(@AncestorInPath final Job<?, ?> project, StaplerResponse response) {
  byte[] random = new byte[16];   // 16x8=128bit worth of randomness, since we use md5 digest as the API token
  RANDOM.nextBytes(random);
  String secretToken = Util.toHexString(random);
  response.setHeader("script", "document.getElementById('secretToken').value='" + secretToken + "'");
}

代码示例来源:origin: jenkinsci/jenkins

w.print(Util.toHexString(md5sum));
w.println("</md5sum>");
w.print("  <fileName>");

代码示例来源:origin: jenkinsci/jenkins

public DefaultConfidentialStore(File rootDir) throws IOException, InterruptedException {
  this.rootDir = rootDir;
  if (rootDir.mkdirs()) {
    // protect this directory. but don't change the permission of the existing directory
    // in case the administrator changed this.
    new FilePath(rootDir).chmod(0700);
  }
  TextFile masterSecret = new TextFile(new File(rootDir,"master.key"));
  if (!masterSecret.exists()) {
    // we are only going to use small number of bits (since export control limits AES key length)
    // but let's generate a long enough key anyway
    masterSecret.write(Util.toHexString(randomBytes(128)));
  }
  this.masterKey = Util.toAes128Key(masterSecret.readTrim());
}

代码示例来源:origin: jenkinsci/jenkins

/**
   * Returns the persisted hex string value.
   *
   * If the value isn't persisted, a new random value is created.
   *
   * @throws Error
   *      If the secret fails to load. Not throwing a checked exception is for the convenience
   *      of the caller.
   */
  public String get() {
    try {
      if (secret==null) {
        synchronized (this) {
          if (secret==null) {
            byte[] payload = load();
            if (payload==null) {
              payload = ConfidentialStore.get().randomBytes(length/2);
              store(payload);
            }
            secret = Util.toHexString(payload).substring(0,length);
          }
        }
      }
      return secret;
    } catch (IOException e) {
      throw new Error("Failed to load the key: "+getId(),e);
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

byte[] random = new byte[32];
sr.nextBytes(random);
secretKey = Util.toHexString(random);
secretFile.write(secretKey);

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Determines the file name from md5sum.
 */
private static File getFingerprintFile(byte[] md5sum) {
  assert md5sum.length==16;
  return new File( Hudson.getInstance().getRootDir(),
    "fingerprints/"+ Util.toHexString(md5sum,0,1)+'/'+Util.toHexString(md5sum,1,1)+'/'+Util.toHexString(md5sum,2,md5sum.length-2)+".xml");
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Determines the file name from md5sum.
 */
private static @Nonnull File getFingerprintFile(@Nonnull byte[] md5sum) {
  assert md5sum.length==16;
  return new File( Jenkins.getInstance().getRootDir(),
    "fingerprints/"+ Util.toHexString(md5sum,0,1)+'/'+Util.toHexString(md5sum,1,1)+'/'+Util.toHexString(md5sum,2,md5sum.length-2)+".xml");
}

相关文章