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

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

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

Util.toHexString介绍

暂无

代码示例

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

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

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

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

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

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

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

  1. /**
  2. * Gets the MD5 hash string.
  3. */
  4. @Exported(name="hash")
  5. public @Nonnull String getHashString() {
  6. return Util.toHexString(md5sum);
  7. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. protected synchronized String issueCrumb(ServletRequest request, String salt) {
  6. if (request instanceof HttpServletRequest) {
  7. if (md != null) {
  8. HttpServletRequest req = (HttpServletRequest) request;
  9. StringBuilder buffer = new StringBuilder();
  10. Authentication a = Jenkins.getAuthentication();
  11. if (a != null) {
  12. buffer.append(a.getName());
  13. }
  14. buffer.append(';');
  15. if (!isExcludeClientIPFromCrumb()) {
  16. buffer.append(getClientIP(req));
  17. }
  18. md.update(buffer.toString().getBytes());
  19. return Util.toHexString(md.digest(salt.getBytes()));
  20. }
  21. }
  22. return null;
  23. }

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Returns the persisted hex string value.
  3. *
  4. * If the value isn't persisted, a new random value is created.
  5. *
  6. * @throws Error
  7. * If the secret fails to load. Not throwing a checked exception is for the convenience
  8. * of the caller.
  9. */
  10. public String get() {
  11. try {
  12. if (secret==null) {
  13. synchronized (this) {
  14. if (secret==null) {
  15. byte[] payload = load();
  16. if (payload==null) {
  17. payload = ConfidentialStore.get().randomBytes(length/2);
  18. store(payload);
  19. }
  20. secret = Util.toHexString(payload).substring(0,length);
  21. }
  22. }
  23. }
  24. return secret;
  25. } catch (IOException e) {
  26. throw new Error("Failed to load the key: "+getId(),e);
  27. }
  28. }
  29. }

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

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

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

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

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

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

相关文章