oltu-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Comstock (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMBER-52) Add functions to generate client id and secret
Date Fri, 06 Apr 2012 03:11:19 GMT

    [ https://issues.apache.org/jira/browse/AMBER-52?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13247991#comment-13247991
] 

Chris Comstock commented on AMBER-52:
-------------------------------------

I wasn't sure where this class should actually live so below is the code for generate random
strings which can be used for client ID and secret generate.

{code}
import java.security.SecureRandom;
import java.util.Random;

public final class Oauth2Util {
	
	 /* The set of values to be used in generate values. */
	  private static final String symbols = "ABCDEFGJKLMNPRSTUVWXYZ0123456789"; 

	  private final Random random = new SecureRandom();

	  private char[] buf;

	  public void randomString(int length)
	  {
	    if (length < 1)
	      throw new IllegalArgumentException("length < 1: " + length);
	    buf = new char[length];
	  }

	  public String generateValue(int length)
	  {
		this.randomString(length);
		
	    for (int idx = 0; idx < buf.length; ++idx) 
	      buf[idx] = symbols.charAt(random.nextInt(symbols.length()));
	    return new String(buf);
	  }

}
{code}
                
> Add functions to generate client id and secret
> ----------------------------------------------
>
>                 Key: AMBER-52
>                 URL: https://issues.apache.org/jira/browse/AMBER-52
>             Project: Amber
>          Issue Type: Improvement
>          Components: OAuth 2.0 - Authorization Server
>            Reporter: Chris Comstock
>            Priority: Minor
>
> Create functions to generate a new client id and secret.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message