incubator-amber-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pids...@apache.org
Subject svn commit: r955555 - in /incubator/amber/trunk/spec-api: ./ java/ java/src/ java/src/META-INF/ java/src/org/ java/src/org/apache/ java/src/org/apache/amber/
Date Thu, 17 Jun 2010 11:17:58 GMT
Author: pidster
Date: Thu Jun 17 11:17:57 2010
New Revision: 955555

URL: http://svn.apache.org/viewvc?rev=955555&view=rev
Log:
Partial API proposal

Added:
    incubator/amber/trunk/spec-api/
    incubator/amber/trunk/spec-api/java/
    incubator/amber/trunk/spec-api/java/src/
    incubator/amber/trunk/spec-api/java/src/META-INF/
    incubator/amber/trunk/spec-api/java/src/META-INF/oauth-providers.xsd
    incubator/amber/trunk/spec-api/java/src/org/
    incubator/amber/trunk/spec-api/java/src/org/apache/
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/HttpConnector.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuth.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthClient.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthConsumer.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthException.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthFactory.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameter.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameterLocation.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProvider.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProviders.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRequest.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponse.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponseParser.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRuntimeException.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthServer.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthSigner.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthToken.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/Version.java
    incubator/amber/trunk/spec-api/java/src/org/apache/amber/package-info.java

Added: incubator/amber/trunk/spec-api/java/src/META-INF/oauth-providers.xsd
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/META-INF/oauth-providers.xsd?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/META-INF/oauth-providers.xsd (added)
+++ incubator/amber/trunk/spec-api/java/src/META-INF/oauth-providers.xsd Thu Jun 17 11:17:57 2010
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<xs:element name="providers">
+  <xs:complexType>
+    <xs:choice minOccurs="1">
+      <xs:element name="provider">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="1">
+            <xs:element name="consumer">
+                <xs:complexType>
+                  <xs:attribute name="name" type="xs:string" use="required" />
+                  <xs:attribute name="key" type="xs:string" use="required" />
+                  <xs:attribute name="secret" type="xs:string" use="required" />
+                  <xs:attribute name="callback" type="xs:anyURI" use="optional" default="oob" />
+                </xs:complexType>
+            </xs:element>
+          </xs:choice>
+          <xs:attribute name="realm" type="xs:anyURI" use="required"/>
+          <xs:attribute name="signatureMethod" use="optional" default="HmacSHA1">
+            <xs:simpleType>
+              <xs:restriction base="xs:string">
+                <xs:enumeration value="Plaintext" />
+                <xs:enumeration value="RsaSHA1" />
+                <xs:enumeration value="HmacSHA1" />
+              </xs:restriction>
+            </xs:simpleType>
+          </xs:attribute>
+          <xs:attribute name="location" use="optional" default="Header">
+            <xs:simpleType>
+              <xs:restriction base="xs:string">
+                <xs:enumeration value="Header" />
+                <xs:enumeration value="Query" />
+                <xs:enumeration value="Body" />
+              </xs:restriction>
+            </xs:simpleType>
+          </xs:attribute>
+          <xs:attribute name="accessTokenPath" type="xs:anyURI" use="required"/>
+          <xs:attribute name="requestTokenPath" type="xs:anyURI" use="required"/>
+          <xs:attribute name="authenticatePath" type="xs:anyURI" use="optional"/>
+          <xs:attribute name="authorizePath" type="xs:anyURI" use="optional"/>
+          <xs:attribute name="responseParserClass" type="xs:string" use="optional"/>
+        </xs:complexType>
+      </xs:element>
+    </xs:choice>
+  </xs:complexType>
+</xs:element>
+</xs:schema>
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/HttpConnector.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/HttpConnector.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/HttpConnector.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/HttpConnector.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.io.IOException;
+
+/**
+ * <p>
+ * The HttpConnector does the work converting executing an
+ * {@link org.apache.amber.OAuthRequest} and returning an
+ * {@link org.apache.amber.OAuthResponse}. This is configurable to allow some choice
+ * with regard to libaries, code etc.
+ * </p>
+ * 
+ * <p>
+ * An implementation MUST provide a default connector.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface HttpConnector {
+
+    /**
+     * The execute method does the work of processing a request and returning a
+     * response from the Provider.
+     * 
+     * @param request
+     * @param authorization
+     * @return response
+     * @throws IOException
+     *             if something untoward happened, propagate the exception
+     */
+    OAuthResponse execute(OAuthRequest request, String authorization)
+            throws IOException;
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuth.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuth.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuth.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuth.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.ServiceLoader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.xml.sax.SAXException;
+
+/**
+ * <p>
+ * The OAuth object provides access to the {@link org.apache.amber.OAuthFactory}.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public final class OAuth {
+
+    /**
+     * 
+     */
+    public static final String JAXB_PACKAGE = "org.apache.amber.jaxb.package";
+
+    /**
+     * default callback value
+     */
+    public static final String OUT_OF_BAND = "oob";
+
+    /**
+     * oauth-providers.xsd schema
+     */
+    private static final String PROVIDER_XSD = "/META-INF/oauth-providers.xsd";
+
+    /**
+     * oauth-providers.xml filename
+     */
+    private static final String PROVIDER_XML = "META-INF/oauth-providers.xml";
+
+    /**
+     * oauth-properties.xml
+     */
+    private static final String PROPERTIES_XML = "META-INF/oauth-properties.xml";
+
+    /**
+     * Perform initialisation of a factory
+     * 
+     * @return An instantiated factory
+     * @throws OAuthRuntimeException
+     */
+    public static final OAuthFactory createFactory() throws OAuthRuntimeException {
+        return createFactory(Version.v1_0a);
+    }
+
+    /**
+     * Perform initialisation of a factory
+     * 
+     * @param properties
+     * 
+     * @return An instantiated factory
+     * @throws OAuthRuntimeException
+     */
+    public static final OAuthFactory createFactory(Properties properties) throws OAuthRuntimeException {
+        return createFactory(Version.v1_0a, properties);
+    }
+
+    /**
+     * Perform initialisation of a factory
+     * 
+     * @param version
+     * 
+     * @return An instantiated factory
+     * @throws OAuthRuntimeException
+     */
+    public static final OAuthFactory createFactory(Version version) throws OAuthRuntimeException {
+        Properties properties = new Properties();
+
+        // The getContextClassLoader() method is called inside the other
+        // load method anyway, so we might as well expose it here
+        // TODO avoid classloader memory leaks?
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+        try {
+            Enumeration<URL> resources = loader.getResources(PROPERTIES_XML);
+            while (resources.hasMoreElements()) {
+                // TODO specify classloader search order manually?
+                // Load the first resource
+                URL resource = resources.nextElement();
+                properties.loadFromXML(resource.openStream());
+            }
+        }
+        catch (IOException e) {
+            throw new OAuthRuntimeException(e);
+        }
+
+        return createFactory(version, properties);
+    }
+
+    /**
+     * Perform initialisation of a factory
+     * 
+     * @param version
+     * @param properties
+     * 
+     * @return An instantiated factory
+     * @throws OAuthRuntimeException
+     */
+    public static final OAuthFactory createFactory(Version version, Properties properties) throws OAuthRuntimeException {
+
+        // TODO Can we avoid classloader leaks and related trauma, by:
+        // ClassLoader loader = OAuth.class.getClassLoader();
+
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        ServiceLoader<OAuthFactory> factories = ServiceLoader.load(OAuthFactory.class, loader);
+
+        // Is this surplus, or might it help if we're in a modifiable
+        // environment?
+        factories.reload();
+
+        for (OAuthFactory factory : factories) {
+
+            if (!factory.getVersion().equals(version)) {
+                continue;
+            }
+
+            factory.setProperties(properties);
+
+            // ------------------------------------------------------------------------
+            // Load any installed OAuthProvider classes using the ServiceLoader
+            // mechanism
+            try {
+                ServiceLoader<OAuthProvider> providers = ServiceLoader.load(OAuthProvider.class, loader);
+
+                // Is this surplus, or might it help if we're in a modifiable
+                // environment?
+                providers.reload();
+
+                for (OAuthProvider provider : providers) {
+                    factory.register(provider);
+                }
+
+                // clean up forcibly
+                providers = null;
+            }
+            catch (Exception e) {
+                throw new OAuthRuntimeException(e);
+            }
+
+            // ------------------------------------------------------------------------
+            // Check for JAXB support in this implementation, and register any
+            // OAuthProvider's found
+            if (factory.getProperties().containsKey(JAXB_PACKAGE)) {
+
+                // ------------------------------------------------------------------------
+                // Load any installed OAuthProviders using the JAXB XML
+                // mechanism
+                try {
+
+                    // load schema from API resources
+                    URL schemaURL = OAuth.class.getResource(PROVIDER_XSD);
+                    SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
+                    Schema schema = schemaFactory.newSchema(schemaURL);
+
+                    // Use factory implementation class to determine package
+                    // String packageName =
+                    // factory.getClass().getPackage().getName();
+
+                    String packageName = factory.getProperties().getProperty(JAXB_PACKAGE);
+
+                    // Create unMarshaller for multiple usages
+                    JAXBContext context = JAXBContext.newInstance(packageName);
+                    Unmarshaller unMarshaller = context.createUnmarshaller();
+                    unMarshaller.setSchema(schema);
+
+                    // find multiple instances of the XML configuration file
+                    Enumeration<URL> providerXMLs = loader.getResources(PROVIDER_XML);
+
+                    while (providerXMLs.hasMoreElements()) {
+                        URL resourceURL = providerXMLs.nextElement();
+                        InputStream inputStream = resourceURL.openStream();
+                        Source source = new StreamSource(inputStream);
+
+                        try {
+                            // Parse the XML file, then loop and register the
+                            // providers
+                            JAXBElement<? extends OAuthProviders> element = unMarshaller.unmarshal(source, factory.getProviders().getClass());
+
+                            for (OAuthProvider provider : element.getValue().getProvider()) {
+                                factory.register(provider);
+                            }
+                        }
+                        catch (JAXBException e) {
+                            // TODO warn of error here, in log?
+                            e.printStackTrace();
+                        }
+                        finally {
+                            inputStream.close();
+                        }
+                    }
+                }
+                catch (IOException e) {
+                    throw new OAuthRuntimeException(e);
+                }
+                catch (SAXException e) {
+                    throw new OAuthRuntimeException(e);
+                }
+                catch (JAXBException e) {
+                    throw new OAuthRuntimeException(e);
+                }
+            }
+
+            // ------------------------------------------------------------------------
+            // return the completed OAuthFactory
+
+            return factory;
+        }
+
+        // clean up services forcibly, who knows what GC will do otherwise.
+        factories = null;
+
+        throw new OAuthRuntimeException(OAuthFactory.class.getName() + " implementation not found.");
+    }
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthClient.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthClient.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthClient.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthClient.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * An OAuth Service is an abstract representation of the standard remote API
+ * offered by an {@link org.apache.amber.OAuthProvider}, providing a simple mechanism
+ * for performing {@link org.apache.amber.OAuth} authentication and authorisation
+ * tasks.
+ * </p>
+ * 
+ * <h3>Using an OAuthClient</h3>
+ * 
+ * <p>
+ * By far the easiest way to use an OAuthClient is by configuring an
+ * {@link org.apache.amber.OAuthProvider} in an XML file (called
+ * &quot;oauth-providers.xml&quot;) and placing it in the META-INF directory on
+ * the applications classpath.
+ * </p>
+ * 
+ * <pre>
+ * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+ *  &lt;providers&gt;
+ *      &lt;provider
+ *          realm=&quot;http://example.com&quot;
+ *          algorithm=&quot;HmacSHA1&quot;
+ *          requestTokenPath=&quot;/oauth/request_token&quot;
+ *          authorizePath=&quot;/oauth/authorize&quot;
+ *          accessTokenPath=&quot;/oauth/access_token&quot;&gt;
+ *          &lt;consumer
+ *              name=&quot;mysite.com&quot;
+ *              callback=&quot;http://www.mysite.com/oauth/response&quot;
+ *              key=&quot;mykey&quot;
+ *              secret=&quot;mysecret&quot;/&gt;
+ *      &lt;/provider&gt;
+ *  &lt;/providers&gt;
+ * </pre>
+ * 
+ * <p>
+ * The OAuthClient is called by using it's realm name as a reference. The
+ * example below assumes the API is used in a Servlet environment, and simply
+ * redirects the user to the {@link org.apache.amber.OAuthProvider} to authorize the
+ * token.
+ * </p>
+ * 
+ * <p>
+ * The {@link org.apache.amber.OAuthProvider} uses the default
+ * {@link org.apache.amber.OAuthConsumer} configured in the XML file.
+ * </p>
+ * 
+ * <pre>
+ * HttpSession session = request.getSession();
+ * 
+ * OAuthClient service = OAuth.useService(&quot;http://example.com&quot;);
+ * OAuthToken requestToken = service.getRequestToken(); // This method also takes an OAuthToken implementation class 
+ * 
+ * session.setAttribute(&quot;requestToken&quot;, requestToken);
+ * 
+ * String authorizePath = service.getAuthorizeURL(requestToken);
+ * response.sendRedirect(authorizePath);
+ * </pre>
+ * 
+ * <p>
+ * If you supply your own implementation of the {@link org.apache.amber.OAuthToken}
+ * interface when you call the requestToken method, you could store the
+ * OAuthToken in a database.
+ * </p>
+ * 
+ * <p>
+ * The token is stored in the user session, as we can re-use it when the
+ * response comes back. We initialise the service and retrieve the token from
+ * the session, before resubmitting the token and the verifier to the
+ * {@link org.apache.amber.OAuthProvider}, who converts the authorised Request Token
+ * into an Access Token.
+ * </p>
+ * 
+ * <p>
+ * After checking that the token is authorised, we remove the old request token
+ * from the session and add the access token, so it can be used to sign future
+ * requests for services at the {@link org.apache.amber.OAuthProvider}.
+ * </p>
+ * 
+ * <pre>
+ * HttpSession session = req.getSession();
+ * 
+ * OAuthClient service = OAuth.useService(&quot;http://oauth.apache.site/&quot;);
+ * OAuthToken requestToken = OAuthToken.class.cast(session
+ *         .getAttribute(&quot;requestToken&quot;));
+ * 
+ * String oauth_token = req.getParameter(&quot;oauth_token&quot;); // you could check this matches the one in the session
+ * String oauth_verifier = req.getParameter(&quot;oauth_verifier&quot;); // supplied with the response
+ * OAuthToken accessToken = service.getAccessToken(requestToken, oauth_verifier);
+ * 
+ * if (accessToken.isAuthorized()) {
+ *     session.removeAttribute(&quot;requestToken&quot;);
+ *     session.setAttribute(&quot;accessToken&quot;, accessToken);
+ * }
+ * </pre>
+ * 
+ * <p>
+ * The OAuthClient could be initialised in an HttpServlet.init() method and
+ * stored in an instance field. Implementations must be thread-safe.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthClient extends Serializable {
+
+    /**
+     * Get a request token using the default consumer and token
+     * 
+     * @return token
+     * @throws OAuthException
+     */
+    OAuthToken getRequestToken() throws OAuthException;
+
+    /**
+     * Get a request token using the specified consumer
+     * 
+     * @param consumer
+     * @return token
+     * @throws OAuthException
+     */
+    OAuthToken getRequestToken(OAuthConsumer consumer) throws OAuthException;
+
+    /**
+     * Get a request token, instantiated from the provided class, using the
+     * default consumer
+     * 
+     * @param tokenClass
+     * @return token
+     * @throws OAuthException
+     */
+    OAuthToken getRequestToken(Class<? extends OAuthToken> tokenClass) throws OAuthException;
+
+    /**
+     * Get a request token, instantiated from the provided class, using the
+     * specified consumer
+     * 
+     * @param tokenClass
+     * @param consumer
+     * @return token
+     * @throws OAuthException
+     */
+    OAuthToken getRequestToken(Class<? extends OAuthToken> tokenClass, OAuthConsumer consumer) throws OAuthException;
+
+    /**
+     * Get the authentication URL for the configured provider, using the
+     * specified token
+     * 
+     * @param token
+     *            The token to be authenticated
+     * @return path The path to which the user should be directed for
+     *         authentication
+     */
+    String getAuthenticateURL(OAuthToken token);
+
+    /**
+     * Get the authentication URL for the configured provider, using the
+     * specified token and callback
+     * 
+     * @param token
+     * @param callback
+     *            The URL to which the user should be redirected after
+     *            authentication
+     * @return path The path to which the user should be directed for
+     *         authentication
+     */
+    String getAuthenticateURL(OAuthToken token, String callback);
+
+    /**
+     * Get the authorisation URL for the configured provider, using the
+     * specified token
+     * 
+     * @param token
+     *            The token to be authorised
+     * @return path The path to which the user should be directed for
+     *         authentication
+     */
+    String getAuthorizeURL(OAuthToken token);
+
+    /**
+     * Get the authorisation URL for the configured provider, using the
+     * specified token
+     * 
+     * @param token
+     * @param callback
+     *            The URL to which the user should be redirected after
+     *            authorisation
+     * @return path The path to which the user should be directed for
+     *         authorisation
+     */
+    String getAuthorizeURL(OAuthToken token, String callback);
+
+    /**
+     * Convert the authorised token to an access token, using the supplied
+     * verification code
+     * 
+     * @param token
+     * @param verifier
+     * @return authorised token
+     * @throws OAuthException
+     */
+    OAuthToken getAccessToken(OAuthToken token, String verifier) throws OAuthException;
+
+    /**
+     * Convert the authorised token to an access token, using the supplied
+     * consumer and verification code
+     * 
+     * @param consumer
+     * @param token
+     * @param verifier
+     * @return authorised token
+     * @throws OAuthException
+     */
+    OAuthToken getAccessToken(OAuthConsumer consumer, OAuthToken token, String verifier) throws OAuthException;
+
+    /**
+     * Get the current connector
+     * 
+     * @return connector
+     */
+    HttpConnector getConnector();
+
+    /**
+     * Set the connector to be used
+     * 
+     * @param httpConnector
+     */
+    void setConnector(HttpConnector httpConnector);
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthConsumer.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthConsumer.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthConsumer.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthConsumer.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * The OAuth Consumer is defined in the {@link org.apache.amber.OAuth} Specification as
+ * the client in one of the legs during an authorisation or authentication.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthConsumer extends Serializable {
+
+    /**
+     * The name field is a convenient reference to the Consumer and SHOULD match
+     * the string used during the Provider registration process
+     * 
+     * @return name
+     */
+    String getName();
+
+    /**
+     * @param name
+     *            the name to set
+     */
+    void setName(String name);
+
+    /**
+     * The key field contains the key string assigned to the Consumer by the
+     * Provider, during registration
+     * 
+     * @return the key
+     */
+    String getKey();
+
+    /**
+     * @param key
+     *            the key to set
+     */
+    void setKey(String key);
+
+    /**
+     * @return the secret
+     */
+    String getSecret();
+
+    /**
+     * The secret field contains the unique secret string generated by the
+     * Provider, during registration
+     * 
+     * @param secret
+     *            the secret to set
+     */
+    void setSecret(String secret);
+
+    /**
+     * The callback field contains the HTTP URL that the Provider will redirect
+     * the User to during the authentication / authorisation process.
+     * 
+     * It MUST be set to the &quot;OUT OF BAND&quot; value &quot;oob&quot; if
+     * the response can't be sent via an HTTP redirect.
+     * 
+     * @return the callback
+     */
+    String getCallback();
+
+    /**
+     * @param callback
+     *            the callback to set
+     */
+    void setCallback(String callback);
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthException.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthException.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthException.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthException.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * 
+ * <p>
+ * Check exception, wraps exceptions thrown by implementation that can be
+ * recovered from.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public class OAuthException extends Exception {
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public OAuthException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * @param message
+     */
+    public OAuthException(final String message) {
+        super(message);
+    }
+
+    /**
+     * @param cause
+     */
+    public OAuthException(final Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthFactory.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthFactory.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthFactory.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthFactory.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.util.Properties;
+
+/**
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthFactory {
+
+    /**
+     * @return version
+     */
+    Version getVersion();
+
+    /**
+     * @param properties
+     */
+    void setProperties(Properties properties);
+
+    /**
+     * @return properties
+     */
+    Properties getProperties();
+
+    /**
+     * @return providers
+     */
+    OAuthProviders getProviders();
+
+    /**
+     * @param provider
+     * @throws OAuthRuntimeException
+     */
+    void register(OAuthProvider provider) throws OAuthRuntimeException;
+
+    /**
+     * @param realm
+     * @return service
+     * @throws OAuthException
+     */
+    OAuthClient useService(String realm) throws OAuthException;
+
+    /**
+     * @param realm
+     * @return service
+     * @throws OAuthException
+     */
+    OAuthServer createServer(String realm) throws OAuthException;
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameter.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameter.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameter.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameter.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * The OAuth specification defines individual parameters required by a provider
+ * at different stages of the authentication and authorisation process.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public enum OAuthParameter {
+
+    /**
+     * The callback parameter name.
+     * 
+     * Value: oauth_callback
+     */
+    CALLBACK {
+        @Override
+        public String toString() {
+            return "oauth_callback";
+        }
+    },
+
+    /**
+     * The Consumer key parameter name.
+     * 
+     * Value: oauth_consumer_key
+     */
+    CONSUMER_KEY {
+        @Override
+        public String toString() {
+            return "oauth_consumer_key";
+        }
+    },
+
+    /**
+     * The nonce parameter name.
+     * 
+     * Value: oauth_nonce
+     */
+    NONCE {
+        @Override
+        public String toString() {
+            return "oauth_nonce";
+        }
+    },
+
+    /**
+     * The realm parameter name
+     * 
+     * Value: OAuth realm
+     */
+    REALM {
+        @Override
+        public String toString() {
+            return "OAuth realm";
+        }
+    },
+
+    /**
+     * The signature parameter name
+     * 
+     * Value: oauth_signature
+     */
+    SIGNATURE {
+        @Override
+        public String toString() {
+            return "oauth_signature";
+        }
+    },
+
+    /**
+     * The signature method parameter name
+     * 
+     * Value: oauth_signature_method
+     */
+    SIGNATURE_METHOD {
+        @Override
+        public String toString() {
+            return "oauth_signature_method";
+        }
+    },
+
+    /**
+     * The timestamp parameter name
+     * 
+     * Value: oauth_timestamp
+     */
+    TIMESTAMP {
+        @Override
+        public String toString() {
+            return "oauth_timestamp";
+        }
+    },
+
+    /**
+     * The token parameter name
+     * 
+     * Value: oauth_token
+     * 
+     * @see org.apache.amber.OAuthToken
+     */
+    TOKEN {
+        @Override
+        public String toString() {
+            return "oauth_token";
+        }
+    },
+
+    /**
+     * The token secret parameter name
+     * 
+     * Value: oauth_token_secret
+     * 
+     * @see org.apache.amber.OAuthToken
+     */
+    TOKEN_SECRET {
+        @Override
+        public String toString() {
+            return "oauth_token_secret";
+        }
+    },
+
+    /**
+     * The verifier parameter name
+     * 
+     * Value: oauth_verifier
+     */
+    VERIFIER {
+        @Override
+        public String toString() {
+            return "oauth_verifier";
+        }
+    },
+
+    /**
+     * The version parameter name
+     * 
+     * Value: oauth_version
+     * 
+     * @see org.apache.amber.Version
+     */
+    VERSION {
+        @Override
+        public String toString() {
+            return "oauth_version";
+        }
+    },
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameterLocation.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameterLocation.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameterLocation.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthParameterLocation.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * Defines the possible locations for the OAuth parameters during each request.
+ * N.B. Each Provider is likely to have a preferred location.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public enum OAuthParameterLocation {
+
+    /**
+     * OAuth parameters should be included in the appropriate header
+     */
+    Header,
+
+    /**
+     * OAuth parameters are included in the query string
+     * 
+     * N.B. size/length limits may impact on the request
+     */
+    Query,
+
+    /**
+     * OAuth parameters are included in the body of the request
+     */
+    Body,
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProvider.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProvider.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProvider.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProvider.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * <p>
+ * The minimum configurable values required to specify the different behaviour
+ * of a Provider (an entity defined by the OAuth specification).
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthProvider extends Serializable {
+
+    /**
+     * @return consumer
+     */
+    List<OAuthConsumer> getConsumers();
+
+    /**
+     * @param consumers
+     */
+    void setConsumers(List<OAuthConsumer> consumers);
+
+    /**
+     * @return the algorithm
+     */
+    String getAlgorithm();
+
+    /**
+     * @param algorithm
+     *            the algorithm to set
+     */
+    void setAlgorithm(String algorithm);
+
+    /**
+     * @return the location
+     */
+    OAuthParameterLocation getLocation();
+
+    /**
+     * @param location
+     *            the location to set
+     */
+    void setLocation(OAuthParameterLocation location);
+
+    /**
+     * @return the realm
+     */
+    String getRealm();
+
+    /**
+     * @param realm
+     *            the realm to set
+     */
+    void setRealm(String realm);
+
+    /**
+     * @return the requestTokenPath
+     */
+    String getRequestTokenPath();
+
+    /**
+     * @param requestTokenPath
+     *            the requestTokenPath to set
+     */
+    void setRequestTokenPath(String requestTokenPath);
+
+    /**
+     * @return the accessTokenPath
+     */
+    String getAccessTokenPath();
+
+    /**
+     * @param accessTokenPath
+     *            the accessTokenPath to set
+     */
+    void setAccessTokenPath(String accessTokenPath);
+
+    /**
+     * @return the authorizePath
+     */
+    String getAuthorizePath();
+
+    /**
+     * @param authorizePath
+     *            the authorizePath to set
+     */
+    void setAuthorizePath(String authorizePath);
+
+    /**
+     * @return the authenticatePath
+     */
+    String getAuthenticatePath();
+
+    /**
+     * @param authenticatePath
+     *            the authenticatePath to set
+     */
+    void setAuthenticatePath(String authenticatePath);
+
+    /**
+     * @return the responseParser
+     */
+    OAuthResponseParser getResponseParser();
+
+    /**
+     * @param responseParser
+     *            the responseParser to set
+     */
+    void setResponseParser(OAuthResponseParser responseParser);
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProviders.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProviders.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProviders.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthProviders.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.util.List;
+
+/**
+ * <p>
+ * A convenience object which contains multiple possible OAuth Service
+ * Providers, in order of preference.
+ * </p>
+ * 
+ * <p>
+ * The first Provider will be considered to be the default one, where
+ * applicable.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthProviders {
+
+    /**
+     * @return the provider
+     */
+    List<OAuthProvider> getProvider();
+
+    /**
+     * @param provider
+     *            the provider to set
+     */
+    void setProvider(List<OAuthProvider> provider);
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRequest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRequest.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRequest.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRequest.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * A convenient object representing the properties of an OAuth request to a
+ * {@link org.apache.amber.OAuthProvider}
+ * </p>
+ * 
+ * @author pidster
+ * 
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthRequest {
+
+    //
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponse.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponse.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponse.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponse.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * An object representing the response returned from an
+ * {@link org.apache.amber.OAuthClient} or {@link org.apache.amber.OAuthServer}
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ * @see org.apache.amber.OAuthClient
+ * 
+ */
+public interface OAuthResponse {
+
+    //
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponseParser.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponseParser.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponseParser.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthResponseParser.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * It's possible that a {@link org.apache.amber.OAuthProvider} will return OAuth
+ * information in a custom response format. The response parser interface allows
+ * a {@link org.apache.amber.OAuthProvider} to specific a concrete implementation.
+ * </p>
+ * 
+ * <p>
+ * An OAuth API implementation MUST provide a response parser that assumes the
+ * returned parameters are name/value pairs, separated by ampersand characters.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthResponseParser {
+
+    /**
+     * Update the provided token, to include the details from the response
+     * 
+     * @param token
+     * @param response
+     * @return token
+     */
+    OAuthToken parseResponse(OAuthToken token, OAuthResponse response);
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRuntimeException.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRuntimeException.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRuntimeException.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthRuntimeException.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * Unchecked exception wrapper, thrown when there is a configuration or other
+ * unchecked exception that prevents the implementation from operating.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public class OAuthRuntimeException extends RuntimeException {
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public OAuthRuntimeException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * @param message
+     */
+    public OAuthRuntimeException(final String message) {
+        super(message);
+    }
+
+    /**
+     * @param cause
+     */
+    public OAuthRuntimeException(final Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthServer.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthServer.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthServer.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthServer.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+/**
+ * <p>
+ * An OAuth Server provides the functionality required to deliver OAuth Provider
+ * functionality. It can be exposed by wrapping it in an HTTP layer, e.g. that
+ * provided by the Servlet Spec or perhaps directly exposed by a custom HTTP
+ * server.
+ * </p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthServer {
+
+    //
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthSigner.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthSigner.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthSigner.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthSigner.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.security.SignatureException;
+
+/**
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthSigner {
+
+    /**
+     * @return method
+     */
+    String getAlgorithm();
+
+    /**
+     * @param key
+     * @param message
+     * @return signature
+     * @throws SignatureException
+     */
+    String getSignature(String key, String message) throws SignatureException;
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthToken.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthToken.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthToken.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/OAuthToken.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.amber;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * An OAuthToken is the wrapper for the pair of key values returned by the
+ * {@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>
+ * 
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public interface OAuthToken extends Serializable {
+
+    /**
+     * @return the token
+     */
+    String getToken();
+
+    /**
+     * @param token
+     */
+    void setToken(String token);
+
+    /**
+     * @param token
+     * @return outcome
+     */
+    boolean matchesToken(String token);
+
+    /**
+     * @return the secret
+     */
+    String getSecret();
+
+    /**
+     * @param secret
+     */
+    void setSecret(String secret);
+
+}
\ No newline at end of file

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/Version.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/Version.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/Version.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/Version.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,91 @@
+/**
+ * 
+ */
+package org.apache.amber;
+
+/**
+ * @author pidster
+ * @version $Revision$ $Date$
+ * 
+ */
+public enum Version {
+
+    /**
+     * 1.0
+     * 
+     * @since 1.0
+     */
+    v1_0(1, 0),
+
+    /**
+     * 1.0a
+     * 
+     * @since 1.0a
+     */
+    v1_0a(1, 0, 'a')
+
+    ; // End of enum type definitions
+
+    private int major;
+    private int minor;
+    private char variant;
+
+    /**
+     * 
+     */
+    Version(int major, int minor) {
+        this.major = major;
+        this.minor = minor;
+        this.variant = ' ';
+    }
+
+    /**
+     * 
+     */
+    Version(int major, int minor, char variant) {
+        this.major = major;
+        this.minor = minor;
+        this.variant = variant;
+    }
+
+    /**
+     * @return handle
+     */
+    public String toHandle() {
+        StringBuilder s = new StringBuilder();
+
+        String className = Version.class.getName();
+        className = className.toLowerCase().replace('.', '_');
+        s.append(className);
+        s.append("_");
+        s.append(this.major);
+        s.append("_");
+        s.append(this.minor);
+        if (this.variant != ' ') {
+            s.append("_");
+            s.append(this.variant);
+        }
+
+        return s.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Enum#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder s = new StringBuilder();
+
+        s.append(this.major);
+        s.append(".");
+        s.append(this.minor);
+        if (this.variant != ' ') {
+            s.append(this.variant);
+        }
+
+        return s.toString();
+    }
+
+}

Added: incubator/amber/trunk/spec-api/java/src/org/apache/amber/package-info.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/java/src/org/apache/amber/package-info.java?rev=955555&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/java/src/org/apache/amber/package-info.java (added)
+++ incubator/amber/trunk/spec-api/java/src/org/apache/amber/package-info.java Thu Jun 17 11:17:57 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <h2>An OAuth Java Specification</h2>
+ * 
+ * <p>Provides the interfaces for an implementation of the OAuth specification.</p>
+ * 
+ * <p>The implementation MUST permit entirely programmatical configuration, configuration
+ * by the presence of an XML file called &quot;oauth-providers.xml&quot; located in a META-INF 
+ * directory on the classpath and by detecting classes configured using the ServiceLoader 
+ * mechanism.</p>
+ * 
+ * @author pidster
+ * @version $Revision$ $Date$
+ * @see org.apache.amber.OAuth
+ * 
+ */
+package org.apache.amber;
+



Mime
View raw message