You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@oltu.apache.org by "Chris Comstock (Commented) (JIRA)" <ji...@apache.org> on 2012/04/06 05:11:19 UTC

[jira] [Commented] (AMBER-52) Add functions to generate client id and secret

    [ 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