src/main/java/pityoulish/tickets/DefaultTicketManager.java
protected String computeToken(String username)
  {
    // concatenate the username with some random characters
    StringBuilder sb = new StringBuilder(username.length()+6);
    sb.append(username).append('@');

    double random = Math.random();
    // 5*6 = 30 bits of randomness should be available...
    for (int i=0; i<5; i++)
     {
       double which = random * RANDOM_TOKEN_CHARS.length();
       sb.append(RANDOM_TOKEN_CHARS.charAt((int) which));
       random = which - (double)(int)which;
     }

    return sb.toString();
  }
/**
   * Computes a random token for a username.
   *
   * @param username    the username, will be included in the token
   *
   * @return    a token for a new ticket for the argument user
   */
Computes a random token for a username.
@param username    the username, will be included in the token

@return    a token for a new ticket for the argument user
Computes a random token for a username . @param username the username will be included in the token @return a token for a new ticket for the argument user
protected String computeToken(String username)
  {
    StringBuilder sb = new StringBuilder(username.length()+6);
    sb.append(username).append('@');
    double random = Math.random();
    for (int i=0; i<5; i++)
     {
       double which = random * RANDOM_TOKEN_CHARS.length();
       sb.append(RANDOM_TOKEN_CHARS.charAt((int) which));
       random = which - (double)(int)which;
     }
    return sb.toString();
  }
protected String computeToken ( String username ) { StringBuilder sb = new StringBuilder ( username . length ( ) + 6 ) ; sb . append ( username ) . append ( '@' ) ; double random = Math . random ( ) ; for ( int i = 0 ; i < 5 ; i ++ ) { double which = random * RANDOM_TOKEN_CHARS . length ( ) ; sb . append ( RANDOM_TOKEN_CHARS . charAt ( ( int ) which ) ) ; random = which - ( double ) ( int ) which ; } return sb . toString ( ) ; }
Computes a random token for a username.
Computes a random token for a username .
// concatenate the username with some random characters // 5*6 = 30 bits of randomness should be available...