Codota Logo
Utf8
Code IndexAdd Codota to your IDE (free)

How to use
Utf8
in
org.springframework.security.crypto.codec

Best Java code snippets using org.springframework.security.crypto.codec.Utf8 (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-security

private static byte[] bytesUtf8(String s) {
  if (s == null) {
    return null;
  }
  return Utf8.encode(s); // need to check if Utf8.encode() runs in constant time (probably not). This may leak length of string.
}
origin: spring-projects/spring-security

private String encode(CharSequence rawPassword, byte[] salt) {
  MessageDigest sha;
  try {
    sha = MessageDigest.getInstance("SHA");
    sha.update(Utf8.encode(rawPassword));
  }
  catch (java.security.NoSuchAlgorithmException e) {
    throw new IllegalStateException("No SHA implementation available!");
  }
  if (salt != null) {
    sha.update(salt);
  }
  byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt);
  String prefix;
  if (salt == null || salt.length == 0) {
    prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX;
  }
  else {
    prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX;
  }
  return prefix + Utf8.decode(Base64.getEncoder().encode(hash));
}
origin: spring-projects/spring-security

  private String encodePart(byte[] part) {
    return Utf8.decode(Base64.getEncoder().encode(part));
  }
}
origin: spring-projects/spring-security

public static String convertPasswordToString(Object passObj) {
  Assert.notNull(passObj, "Password object to convert must not be null");
  if (passObj instanceof byte[]) {
    return Utf8.decode((byte[]) passObj);
  }
  else if (passObj instanceof String) {
    return (String) passObj;
  }
  else {
    throw new IllegalArgumentException(
        "Password object was not a String or byte array.");
  }
}
origin: spring-projects/spring-security

/**
 * Constructs a standard password encoder with a secret value as well as iterations
 * and hash.
 *
 * @param secret the secret
 * @param iterations the number of iterations. Users should aim for taking about .5
 * seconds on their own system.
 * @param hashWidth the size of the hash
 */
public Pbkdf2PasswordEncoder(CharSequence secret, int iterations, int hashWidth) {
  this.secret = Utf8.encode(secret);
  this.iterations = iterations;
  this.hashWidth = hashWidth;
}
origin: spring-projects/spring-security

public Token allocateToken(String extendedInformation) {
  Assert.notNull(extendedInformation,
      "Must provided non-null extendedInformation (but it can be empty)");
  long creationTime = new Date().getTime();
  String serverSecret = computeServerSecretApplicableAt(creationTime);
  String pseudoRandomNumber = generatePseudoRandomNumber();
  String content = Long.toString(creationTime) + ":" + pseudoRandomNumber + ":"
      + extendedInformation;
  // Compute key
  String sha512Hex = Sha512DigestUtils.shaHex(content + ":" + serverSecret);
  String keyPayload = content + ":" + sha512Hex;
  String key = Utf8.decode(Base64.getEncoder().encode(Utf8.encode(keyPayload)));
  return new DefaultToken(key, creationTime, extendedInformation);
}
origin: org.springframework.security/spring-security-core

  private String encodePart(byte[] part) {
    return Utf8.decode(Base64.getEncoder().encode(part));
  }
}
origin: org.springframework.security/spring-security-core

private static byte[] bytesUtf8(String s) {
  if (s == null) {
    return null;
  }
  return Utf8.encode(s); // need to check if Utf8.encode() runs in constant time (probably not). This may leak length of string.
}
origin: org.springframework.security/spring-security-core

private String encode(CharSequence rawPassword, byte[] salt) {
  MessageDigest sha;
  try {
    sha = MessageDigest.getInstance("SHA");
    sha.update(Utf8.encode(rawPassword));
  }
  catch (java.security.NoSuchAlgorithmException e) {
    throw new IllegalStateException("No SHA implementation available!");
  }
  if (salt != null) {
    sha.update(salt);
  }
  byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt);
  String prefix;
  if (salt == null || salt.length == 0) {
    prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX;
  }
  else {
    prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX;
  }
  return prefix + Utf8.decode(Base64.getEncoder().encode(hash));
}
origin: spring-projects/spring-security

private String encode(byte[] digest) {
  if (this.encodeHashAsBase64) {
    return Utf8.decode(Base64.getEncoder().encode(digest));
  }
  else {
    return new String(Hex.encode(digest));
  }
}
origin: org.springframework.security/spring-security-core

/**
 * Constructs a standard password encoder with a secret value as well as iterations
 * and hash.
 *
 * @param secret the secret
 * @param iterations the number of iterations. Users should aim for taking about .5
 * seconds on their own system.
 * @param hashWidth the size of the hash
 */
public Pbkdf2PasswordEncoder(CharSequence secret, int iterations, int hashWidth) {
  this.secret = Utf8.encode(secret);
  this.iterations = iterations;
  this.hashWidth = hashWidth;
}
origin: org.springframework.security/spring-security-core

public Token allocateToken(String extendedInformation) {
  Assert.notNull(extendedInformation,
      "Must provided non-null extendedInformation (but it can be empty)");
  long creationTime = new Date().getTime();
  String serverSecret = computeServerSecretApplicableAt(creationTime);
  String pseudoRandomNumber = generatePseudoRandomNumber();
  String content = Long.toString(creationTime) + ":" + pseudoRandomNumber + ":"
      + extendedInformation;
  // Compute key
  String sha512Hex = Sha512DigestUtils.shaHex(content + ":" + serverSecret);
  String keyPayload = content + ":" + sha512Hex;
  String key = Utf8.decode(Base64.getEncoder().encode(Utf8.encode(keyPayload)));
  return new DefaultToken(key, creationTime, extendedInformation);
}
origin: spring-projects/spring-security

private String encode(byte[] digest) {
  if (this.encodeHashAsBase64) {
    return Utf8.decode(Base64.getEncoder().encode(digest));
  }
  else {
    return new String(Hex.encode(digest));
  }
}
origin: spring-projects/spring-security

private byte[] decodePart(String part) {
  return Base64.getDecoder().decode(Utf8.encode(part));
}
origin: spring-projects/spring-security

    Utf8.decode(Base64.getDecoder().decode(Utf8.encode(key))), ":");
Assert.isTrue(tokens.length >= 4, () -> "Expected 4 or more tokens but found "
    + tokens.length);
origin: org.springframework.security/spring-security-core

private String encode(byte[] digest) {
  if (this.encodeHashAsBase64) {
    return Utf8.decode(Base64.getEncoder().encode(digest));
  }
  else {
    return new String(Hex.encode(digest));
  }
}
origin: org.springframework.security/spring-security-core

private byte[] decodePart(String part) {
  return Base64.getDecoder().decode(Utf8.encode(part));
}
origin: cloudfoundry/uaa

  @Override
  public AuditEvent getAuditEvent() {

    String name = getAuthentication().getName();

    try {
      // Store hash of name, to conceal accidental entry of sensitive info
      // (e.g. password)
      name = Utf8.decode(Base64.encode(MessageDigest.getInstance("SHA-1").digest(Utf8.encode(name))));
    } catch (NoSuchAlgorithmException shouldNeverHappen) {
      name = "NOSHA";
    }

    return createAuditRecord(name, AuditEventType.UserNotFound, getOrigin(getAuthenticationDetails()), "");

  }
}
origin: org.springframework.security/spring-security-core

private String encode(byte[] digest) {
  if (this.encodeHashAsBase64) {
    return Utf8.decode(Base64.getEncoder().encode(digest));
  }
  else {
    return new String(Hex.encode(digest));
  }
}
origin: spring-projects/spring-security

private String digest(CharSequence rawPassword, byte[] salt) {
  byte[] derived = SCrypt.generate(Utf8.encode(rawPassword), salt, cpuCost, memoryCost, parallelization, keyLength);
  String params = Long
      .toString(((int) (Math.log(cpuCost) / Math.log(2)) << 16L) | memoryCost << 8 | parallelization, 16);
  StringBuilder sb = new StringBuilder((salt.length + derived.length) * 2);
  sb.append("$").append(params).append('$');
  sb.append(encodePart(salt)).append('$');
  sb.append(encodePart(derived));
  return sb.toString();
}
org.springframework.security.crypto.codecUtf8

Javadoc

UTF-8 Charset encoder/decoder.

For internal use only.

Most used methods

  • encode
    Get the bytes of the String in UTF-8 encoded form.
  • decode
    Decode the bytes in UTF-8 form into a String.

Popular in Java

  • Start an intent from android
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • startActivity (Activity)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now