org.springframework.security.oauth2.common.util
Class RandomValueStringGenerator

java.lang.Object
  extended by org.springframework.security.oauth2.common.util.RandomValueStringGenerator

public class RandomValueStringGenerator
extends Object

Utility that generates a random-value ASCII string.

Author:
Ryan Heaton, Dave Syer

Constructor Summary
RandomValueStringGenerator()
          Create a generator with the default length (6).
RandomValueStringGenerator(int length)
          Create a generator of random strings of the length provided
 
Method Summary
 String generate()
           
protected  String getAuthorizationCodeString(byte[] verifierBytes)
          Convert these random bytes to a verifier string.
 void setLength(int length)
          The length of string to generate.
 void setRandom(Random random)
          The random value generator used to create token secrets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomValueStringGenerator

public RandomValueStringGenerator()
Create a generator with the default length (6).


RandomValueStringGenerator

public RandomValueStringGenerator(int length)
Create a generator of random strings of the length provided

Parameters:
length - the length of the strings generated
Method Detail

generate

public String generate()

getAuthorizationCodeString

protected String getAuthorizationCodeString(byte[] verifierBytes)
Convert these random bytes to a verifier string. The length of the byte array can be configured. The default implementation mods the bytes to fit into the ASCII letters 1-9, A-Z, a-z .

Parameters:
verifierBytes - The bytes.
Returns:
The string.

setRandom

public void setRandom(Random random)
The random value generator used to create token secrets.

Parameters:
random - The random value generator used to create token secrets.

setLength

public void setLength(int length)
The length of string to generate.

Parameters:
length - the length to set


Copyright © 2012. All Rights Reserved.