package org.scribe.model;

import java.io.*;

/**
 * Parameter object that groups OAuth config values
 * 
 * @author Pablo Fernandez
 */
public class OAuthConfig
{
  private final String apiKey;
  private final String apiSecret;
  private final String callback;
  private final SignatureType signatureType;
  private final String scope;
  private final OutputStream debugStream;
  
  public OAuthConfig(String key, String secret)
  {
    this(key, secret, null, null, null, null);
  }

  public OAuthConfig(String key, String secret, String callback, SignatureType type, String scope, OutputStream stream)
  {
    this.apiKey = key;
    this.apiSecret = secret;
    this.callback = callback;
    this.signatureType = type;
    this.scope = scope;
    this.debugStream = stream;
  }

  public String getApiKey()
  {
    return apiKey;
  }

  public String getApiSecret()
  {
    return apiSecret;
  }

  public String getCallback()
  {
    return callback;
  }

  public SignatureType getSignatureType()
  {
    return signatureType;
  }

  public String getScope()
  {
    return scope;
  }

  public boolean hasScope()
  {
    return scope != null;
  }

  public void log(String message)
  {
    if (debugStream != null)
    {
      message = message + "\n";
      try
      {
        debugStream.write(message.getBytes("UTF8"));
      }
      catch (Exception e)
      {
        throw new RuntimeException("there were problems while writing to the debug stream", e);
      }
    }
  }
}

@@ -20,16 +20,68 @@
 model;%0A%0A
+import org.apache.commons.lang3.RandomStringUtils;%0A%0A
 import j
@@ -90,16 +90,16 @@
 a.io.*;%0A
-
 %0A/**%0A * 
@@ -149,17 +149,16 @@
 alues%0A *
- 
 %0A * @aut
@@ -425,16 +425,44 @@
 ream;%0A  
+private final String state;%0A
 %0A  publi
@@ -678,24 +678,684 @@
 stream)%0A  %7B%0A
+    this(key, secret, callback, type, scope, stream, RandomStringUtils.randomAlphanumeric(32));%0A  %7D%0A%0A  /**%0A   * Constructor%0A   *%0A   * @param key Api key%0A   * @param secret Api Secret%0A   * @param callback OAuth callback (either URL or 'oob')%0A   * @param type Type of the OAuth signature%0A   * @param scope OAuth scope (optional)%0A   * @param stream An output stream used for debugging%0A   * @param state Optional state, a hard to guess string to use against XSS attacks. Some providers such as LinkedInApi2- support it.%0A   */%0A  public OAuthConfig(String key, String secret, String callback, SignatureType type, String scope, OutputStream stream, String state)%0A  %7B%0A
     this.api
@@ -1510,16 +1510,40 @@
 stream;%0A
+    this.state = state;%0A
   %7D%0A%0A  p
@@ -1817,32 +1817,32 @@
  getScope()%0A  %7B%0A
-
     return scope
@@ -1840,32 +1840,86 @@
 urn scope;%0A  %7D%0A%0A
+  public String getState()%0A  %7B%0A    return state;%0A  %7D%0A%0A
   public boolean

Add state to OAuthConfig