public String generateSessionId ( ) { byte random [ ] = new byte [ 16 ] ; // Render the result as a String of hexadecimal digits StringBuilder buffer = new StringBuilder ( ) ; int resultLenBytes = 0 ; while ( resultLenBytes < sessionIdLength ) { getRandomBytes ( random ) ; for ( int j = 0 ; j < random . length && resultLenBytes < sessionIdLength ; j ++ ) { byte b1 = ( byte ) ( ( random [ j ] & 0xf0 ) >> 4 ) ; byte b2 = ( byte ) ( random [ j ] & 0x0f ) ; if ( b1 < 10 ) { buffer . append ( ( char ) ( ' ' + b1 ) ) ; } else { buffer . append ( ( char ) ( ' ' + ( b1 - 10 ) ) ) ; } if ( b2 < 10 ) { buffer . append ( ( char ) ( ' ' + b2 ) ) ; } else { buffer . append ( ( char ) ( ' ' + ( b2 - 10 ) ) ) ; } resultLenBytes ++ ; } } if ( jvmRoute != null && jvmRoute . length ( ) > 0 ) { buffer . append ( ' ' ) . append ( jvmRoute ) ; } return buffer . toString ( ) ; }
Generate and return a new session identifier .