The reason it's an interface is so that a user can pass in any class, e.g. one that extends an existing Principal implementation in a servlet container, or a token that is a JPA POJO.
We'd provide a default entity in the implementation, if an existing one isn't used. Sorry, my bad - I should have documented that logic somewhere. p On 5 July 2010 11:23, <[email protected]> wrote: > Author: simonetripodi > Date: Mon Jul 5 10:23:31 2010 > New Revision: 960525 > > URL: http://svn.apache.org/viewvc?rev=960525&view=rev > Log: > The Token can be represented as a final entity rather than an interface. > > Modified: > > incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthToken.java > > Modified: > incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthToken.java > URL: > http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthToken.java?rev=960525&r1=960524&r2=960525&view=diff > ============================================================================== > --- > incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthToken.java > (original) > +++ > incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthToken.java > Mon Jul 5 10:23:31 2010 > @@ -17,6 +17,10 @@ > package org.apache.amber; > > import java.io.Serializable; > +import java.util.HashMap; > +import java.util.Map; > +import java.util.Map.Entry; > +import java.util.Set; > > /** > * <p> > @@ -24,46 +28,104 @@ import java.io.Serializable; > * {...@link org.apache.amber.OAuthClient} during the authentication or > authorisation > * process. > * </p> > - * > + * > * <p> > * The implementation MUST also support validation of the returned access > token > * values to determine whether the token is authorised or unauthorised. > * </p> > - * > + * > * <p> > * A Map contains additional response parameters, sent by the provider. > * </p> > - * > - * > - * @version $Revision$ $Date$ > - * > + * > + * @version $Id$ > */ > -public interface OAuthToken extends Serializable { > +public final class OAuthToken implements Serializable { > > /** > - * @return the token > + * The default serialVersionUID. > */ > - String getToken(); > + private static final long serialVersionUID = 1L; > > /** > - * @param token > + * The additional response parameters, sent by the provider. > */ > - void setToken(String token); > + private final Map<String, String> additionalParameters = new > HashMap<String, String>(); > > /** > - * @param token > - * @return outcome > + * The {...@code oauth_token} parameter. > */ > - boolean matchesToken(String token); > + private String token; > > /** > - * @return the secret > + * The {...@code oauth_token_secret} parameter. > */ > - String getSecret(); > + private String tokenSecret; > > /** > - * @param secret > + * The {...@code oauth_callback_confirmed} parameter. > */ > - void setSecret(String secret); > + private boolean callbackConfirmed; > > -} > \ No newline at end of file > + /** > + * @return the the {...@code oauth_token} parameter. > + */ > + public String getToken() { > + return this.token; > + } > + > + /** > + * @param token the {...@code oauth_token} parameter. > + */ > + public void setToken(String token) { > + this.token = token; > + } > + > + /** > + * @return the {...@code oauth_token_secret} parameter. > + */ > + public String getTokenSecret() { > + return tokenSecret; > + } > + > + /** > + * @param tokenSecret the {...@code oauth_token_secret} parameter. > + */ > + public void setTokenSecret(String tokenSecret) { > + this.tokenSecret = tokenSecret; > + } > + > + /** > + * @return the {...@code oauth_callback_confirmed} parameter. > + */ > + public boolean isCallbackConfirmed() { > + return callbackConfirmed; > + } > + > + /** > + * @param callbackConfirmed the {...@code oauth_callback_confirmed} > parameter. > + */ > + public void setCallbackConfirmed(boolean callbackConfirmed) { > + this.callbackConfirmed = callbackConfirmed; > + } > + > + /** > + * Associates the specified value with the specified name in this > additional > + * parameters map. > + * > + * @param name name with which the specified value is to be associated. > + * @param value value to be associated with the specified name. > + */ > + public void addAdditionalParameters(String name, String value) { > + this.additionalParameters.put(name, value); > + } > + > + /** > + * @return a {...@link Set} view of the mappings contained in this > additional > + * parameters map > + */ > + public Set<Entry<String, String>> additionalParametersEntrySet() { > + return this.additionalParameters.entrySet(); > + } > + > +} > > > -- -- pidster.com
