You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oltu.apache.org by to...@apache.org on 2010/12/18 17:34:43 UTC
svn commit: r1050662 [1/2] - in
/incubator/amber/trunk/oauth-2.0/oauth2-client-demo: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/amber/ src/main/java/org/apache/amber/oauth2/
src/main/java/org/...
Author: tommaso
Date: Sat Dec 18 16:34:41 2010
New Revision: 1050662
URL: http://svn.apache.org/viewvc?rev=1050662&view=rev
Log:
[AMBER-11] - import of Leelo OAuth 2.0 implementation - oauth2-client-demo module
Added:
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/ (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/pom.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/Utils.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/AuthzController.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/MainController.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RedirectController.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RegistrationController.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/ResourceController.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/TokenController.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/ApplicationException.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthParams.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthRegParams.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/jdoconfig.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/persistence.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/log4j.properties (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/app-config.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/mvc-config.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/urlrewrite.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_authz.jsp (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_resource.jsp (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/index.jsp (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/register.jsp (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/request_token.jsp (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/resource.jsp (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/web.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/test/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/test/resources/
incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/test/resources/log4j.properties (with props)
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 18 16:34:41 2010
@@ -0,0 +1,2 @@
+target
+oauth2-client-demo.iml
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/pom.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/pom.xml?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/pom.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/pom.xml Sat Dec 18 16:34:41 2010
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <artifactId>amber-oauth2-parent</artifactId>
+ <groupId>org.apache.amber</groupId>
+ <version>0.2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>oauth2-client-demo</artifactId>
+ <name>Apache Amber: OAuth 2.0 Implementation - Demo Application</name>
+ <packaging>war</packaging>
+
+
+ <!-- Specify hard-coded project properties here -->
+ <properties>
+ <org.springframework.version>3.0.3.RELEASE</org.springframework.version>
+ </properties>
+
+
+ <build>
+ <finalName>oauth2-demo</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.24</version>
+ <configuration>
+ <webAppConfig>
+ <contextPath>/</contextPath>
+ </webAppConfig>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8080</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jcl</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+
+
+ <!-- OAuth Dependency -->
+ <dependency>
+ <artifactId>oauth2-common</artifactId>
+ <groupId>org.apache.amber</groupId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- OAuth Dynamic Registration Dependency -->
+
+ <dependency>
+ <artifactId>oauth2-dynamicreg-common</artifactId>
+ <groupId>org.apache.amber</groupId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <artifactId>oauth2-dynamicreg-client</artifactId>
+ <groupId>org.apache.amber</groupId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Spring MVC -->
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${org.springframework.version}</version>
+ <exclusions>
+ <!-- Exclude Commons Logging in favor of SLF4j -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${org.springframework.version}</version>
+ </dependency>
+
+
+ <!-- URL Rewrite -->
+ <!-- URL Rewrite -->
+ <dependency>
+ <groupId>org.tuckey</groupId>
+ <artifactId>urlrewritefilter</artifactId>
+ <version>3.1.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!--
+ Make use of JSP tags. Remove, if you don't use JSPs
+ -->
+ <dependency>
+ <artifactId>standard</artifactId>
+ <groupId>taglibs</groupId>
+ <version>1.1.2</version>
+ <type>jar</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+
+</project>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/Utils.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/Utils.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/Utils.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/Utils.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,200 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.client.demo.exception.ApplicationException;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.apache.amber.oauth2.client.demo.model.OAuthRegParams;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public final class Utils {
+ private Utils() {
+ }
+
+ public static final String REDIRECT_URI = "http://localhost:8080/redirect";
+ public static final String DISCOVERY_URI = "http://localhost:8080";
+
+ public static final String REG_TYPE_PULL = "pull";
+ public static final String REG_TYPE_PUSH = "push";
+
+ public static final String FACEBOOK = "facebook";
+ public static final String FACEBOOK_AUTHZ = "https://graph.facebook.com/oauth/authorize";
+ public static final String FACEBOOK_TOKEN = "https://graph.facebook.com/oauth/access_token";
+
+ public static final String GOWALLA = "gowalla";
+ public static final String GOWALLA_AUTHZ = "https://gowalla.com/api/oauth/authorize";
+ public static final String GOWALLA_TOKEN = "https://gowalla.com/api/oauth/access_token";
+
+ public static final String GITHUB = "github";
+ public static final String GITHUB_AUTHZ = "https://github.com/login/oauth/authorize";
+ public static final String GITHUB_TOKEN = "https://github.com/login/oauth/access_token";
+
+ public static final String SMART_GALLERY = "smart_gallery";
+ public static final String SMART_GALLERY_AUTHZ = "http://localhost:8090/oauth/authorize";
+ public static final String SMART_GALLERY_TOKEN = "http://localhost:8090/oauth/token";
+ public static final String SMART_GALLERY_REGISTER = "http://localhost:8090/oauthreg/register";
+
+ public static void validateRegistrationParams(OAuthRegParams oauthParams) throws ApplicationException {
+
+ String regType = oauthParams.getRegistrationType();
+
+ String name = oauthParams.getName();
+ String url = oauthParams.getUrl();
+ String description = oauthParams.getDescription();
+ StringBuffer sb = new StringBuffer();
+
+ if (isEmpty(url)) {
+ sb.append("Application URL ");
+ }
+
+ if (REG_TYPE_PUSH.equals(regType)) {
+ if (isEmpty(name)) {
+ sb.append("Application Name ");
+ }
+
+ if (isEmpty(description)) {
+ sb.append("Application URL ");
+ }
+ } else if (!REG_TYPE_PULL.equals(regType)) {
+ throw new ApplicationException("Incorrect registration type: " + regType);
+ }
+
+ String incorrectParams = sb.toString();
+ if ("".equals(incorrectParams)) {
+ return;
+ }
+ throw new ApplicationException("Incorrect parameters: " + incorrectParams);
+
+ }
+
+ public static void validateAuthorizationParams(OAuthParams oauthParams) throws ApplicationException {
+
+
+ String authzEndpoint = oauthParams.getAuthzEndpoint();
+ String tokenEndpoint = oauthParams.getTokenEndpoint();
+ String clientId = oauthParams.getClientId();
+ String clientSecret = oauthParams.getClientSecret();
+ String redirectUri = oauthParams.getRedirectUri();
+
+ StringBuffer sb = new StringBuffer();
+
+ if (isEmpty(authzEndpoint)) {
+ sb.append("Authorization Endpoint ");
+ }
+
+ if (isEmpty(tokenEndpoint)) {
+ sb.append("Token Endpoint ");
+ }
+
+ if (isEmpty(clientId)) {
+ sb.append("Client ID ");
+ }
+
+ if (isEmpty(clientSecret)) {
+ sb.append("Client Secret ");
+ }
+
+ if (!REDIRECT_URI.equals(redirectUri)) {
+ sb.append("Redirect URI");
+ }
+
+ String incorrectParams = sb.toString();
+ if ("".equals(incorrectParams)) {
+ return;
+ }
+ throw new ApplicationException("Incorrect parameters: " + incorrectParams);
+
+ }
+
+ public static void validateTokenParams(OAuthParams oauthParams) throws ApplicationException {
+
+ String authzEndpoint = oauthParams.getAuthzEndpoint();
+ String tokenEndpoint = oauthParams.getTokenEndpoint();
+ String clientId = oauthParams.getClientId();
+ String clientSecret = oauthParams.getClientSecret();
+ String redirectUri = oauthParams.getRedirectUri();
+ String authzCode = oauthParams.getAuthzCode();
+
+ StringBuffer sb = new StringBuffer();
+
+ if (isEmpty(authzCode)) {
+ sb.append("Authorization Code ");
+ }
+
+ if (isEmpty(authzEndpoint)) {
+ sb.append("Authorization Endpoint ");
+ }
+
+ if (isEmpty(tokenEndpoint)) {
+ sb.append("Token Endpoint ");
+ }
+
+ if (isEmpty(clientId)) {
+ sb.append("Client ID ");
+ }
+
+ if (isEmpty(clientSecret)) {
+ sb.append("Client Secret ");
+ }
+
+ if (!REDIRECT_URI.equals(redirectUri)) {
+ sb.append("Redirect URI");
+ }
+
+ String incorrectParams = sb.toString();
+ if ("".equals(incorrectParams)) {
+ return;
+ }
+ throw new ApplicationException("Incorrect parameters: " + incorrectParams);
+
+ }
+
+ public static boolean isEmpty(String value) {
+ return value == null || "".equals(value);
+ }
+
+
+ public static String findCookieValue(HttpServletRequest request, String key) {
+ Cookie[] cookies = request.getCookies();
+
+ for (Cookie cookie : cookies) {
+ if (cookie.getName().equals(key)) {
+ return cookie.getValue();
+ }
+ }
+ return "";
+ }
+
+ public static String isIssued(String value) {
+ if (isEmpty(value)) {
+ return "(Not issued)";
+ }
+ return value;
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/Utils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/AuthzController.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/AuthzController.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/AuthzController.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/AuthzController.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.controller;
+
+
+import java.io.IOException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.amber.oauth2.client.demo.exception.ApplicationException;
+import org.apache.amber.oauth2.client.request.OAuthClientRequest;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.message.types.ResponseType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.view.RedirectView;
+
+import org.apache.amber.oauth2.client.demo.Utils;
+
+/**
+ * Handles requests for the application welcome page.
+ *
+ * @author Maciej Machulak
+ * @author Lukasz Moren
+ */
+@Controller
+@RequestMapping("/")
+public class AuthzController {
+
+
+ private Logger logger = LoggerFactory.getLogger(AuthzController.class);
+
+ @RequestMapping("/authorize")
+ public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams,
+ HttpServletRequest req,
+ HttpServletResponse res)
+ throws OAuthSystemException, IOException {
+
+ try {
+
+ Utils.validateAuthorizationParams(oauthParams);
+
+ res.addCookie(new Cookie("clientId", oauthParams.getClientId()));
+ res.addCookie(new Cookie("clientSecret", oauthParams.getClientSecret()));
+ res.addCookie(new Cookie("authzEndpoint", oauthParams.getAuthzEndpoint()));
+ res.addCookie(new Cookie("tokenEndpoint", oauthParams.getTokenEndpoint()));
+ res.addCookie(new Cookie("redirectUri", oauthParams.getRedirectUri()));
+ res.addCookie(new Cookie("scope", oauthParams.getScope()));
+ res.addCookie(new Cookie("app", oauthParams.getApplication()));
+
+ OAuthClientRequest request = OAuthClientRequest
+ .authorizationLocation(oauthParams.getAuthzEndpoint())
+ .setClientId(oauthParams.getClientId())
+ .setRedirectURI(oauthParams.getRedirectUri())
+ .setResponseType(ResponseType.CODE.toString())
+ .setScope(oauthParams.getScope())
+ .buildQueryMessage();
+
+ return new ModelAndView(new RedirectView(request.getLocationUri()));
+
+ } catch (ApplicationException e) {
+ oauthParams.setErrorMessage(e.getMessage());
+ return new ModelAndView("get_authz");
+ }
+ }
+
+
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/AuthzController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/MainController.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/MainController.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/MainController.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/MainController.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.controller;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.amber.oauth2.client.demo.Utils;
+import org.apache.amber.oauth2.client.demo.model.OAuthRegParams;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+@Controller
+@RequestMapping("/")
+public class MainController {
+
+ private Logger logger = LoggerFactory.getLogger(MainController.class);
+
+ @RequestMapping("/index")
+ public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams)
+ throws OAuthSystemException, IOException {
+ return new ModelAndView("index");
+ }
+
+ @RequestMapping("/main/{app}")
+ public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams,
+ @ModelAttribute("oauthRegParams") OAuthRegParams oauthRegParams,
+ @PathVariable("app") String app,
+ HttpServletResponse res)
+ throws OAuthSystemException, IOException {
+
+ boolean selected = false;
+ if (Utils.GITHUB.equals(app)) {
+ selected = true;
+ oauthParams.setAuthzEndpoint(Utils.GITHUB_AUTHZ);
+ oauthParams.setTokenEndpoint(Utils.GITHUB_TOKEN);
+
+ } else if (Utils.FACEBOOK.equals(app)) {
+ selected = true;
+ oauthParams.setAuthzEndpoint(Utils.FACEBOOK_AUTHZ);
+ oauthParams.setTokenEndpoint(Utils.FACEBOOK_TOKEN);
+ } else if (Utils.GOWALLA.equals(app)) {
+ selected = true;
+ oauthParams.setAuthzEndpoint(Utils.GOWALLA_AUTHZ);
+ oauthParams.setTokenEndpoint(Utils.GOWALLA_TOKEN);
+ } else if (Utils.SMART_GALLERY.equals(app)) {
+ selected = true;
+ oauthRegParams.setAuthzEndpoint(Utils.SMART_GALLERY_AUTHZ);
+ oauthRegParams.setTokenEndpoint(Utils.SMART_GALLERY_TOKEN);
+ oauthRegParams.setRegistrationEndpoint(Utils.SMART_GALLERY_REGISTER);
+ oauthRegParams.setApplication(app);
+ oauthRegParams.setRedirectUri(Utils.REDIRECT_URI);
+ return new ModelAndView("register");
+ }
+ if (selected) {
+ oauthParams.setApplication(app);
+ oauthParams.setRedirectUri(Utils.REDIRECT_URI);
+ return new ModelAndView("get_authz");
+ }
+
+ return new ModelAndView("index");
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/MainController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RedirectController.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RedirectController.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RedirectController.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RedirectController.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,98 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.controller;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.amber.oauth2.client.demo.Utils;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.apache.amber.oauth2.client.response.OAuthAuthzResponse;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+@Controller
+@RequestMapping("/redirect")
+public class RedirectController {
+
+ @RequestMapping(method = RequestMethod.GET)
+ public ModelAndView handleRedirect(@ModelAttribute("oauthParams") OAuthParams oauthParams,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+
+
+ try {
+
+ // Create the response wrapper
+ OAuthAuthzResponse oar = null;
+ oar = OAuthAuthzResponse.oauthCodeAuthzResponse(request);
+
+
+ // Get Authorization Code
+ String code = oar.getCode();
+
+ // Get OAuth Info
+ String clientId = Utils.findCookieValue(request, "clientId");
+ String clientSecret = Utils.findCookieValue(request, "clientSecret");
+ String authzEndpoint = Utils.findCookieValue(request, "authzEndpoint");
+ String tokenEndpoint = Utils.findCookieValue(request, "tokenEndpoint");
+ String redirectUri = Utils.findCookieValue(request, "redirectUri");
+ String scope = Utils.findCookieValue(request, "scope");
+
+ String app = Utils.findCookieValue(request, "app");
+ response.addCookie(new Cookie("app", app));
+
+ oauthParams.setAuthzCode(code);
+ oauthParams.setClientId(clientId);
+ oauthParams.setClientSecret(clientSecret);
+ oauthParams.setAuthzEndpoint(authzEndpoint);
+ oauthParams.setTokenEndpoint(tokenEndpoint);
+ oauthParams.setRedirectUri(redirectUri);
+ oauthParams.setScope(Utils.isIssued(scope));
+ oauthParams.setApplication(app);
+
+
+ } catch (OAuthProblemException e) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("</br>");
+ sb.append("Error code: ").append(e.getError()).append("</br>");
+ sb.append("Error description: ").append(e.getDescription()).append("</br>");
+ sb.append("Error uri: ").append(e.getUri()).append("</br>");
+ sb.append("State: ").append(e.getState()).append("</br>");
+ oauthParams.setErrorMessage(sb.toString());
+ return new ModelAndView("main");
+ }
+
+ return new ModelAndView("request_token");
+
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RedirectController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RegistrationController.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RegistrationController.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RegistrationController.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RegistrationController.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,104 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.controller;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.client.URLConnectionClient;
+import org.apache.amber.oauth2.client.demo.Utils;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.apache.amber.oauth2.client.demo.model.OAuthRegParams;
+import org.apache.amber.oauth2.client.request.OAuthClientRequest;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.ext.dynamicreg.client.OAuthRegistrationClient;
+import org.apache.amber.oauth2.ext.dynamicreg.client.request.OAuthClientRegistrationRequest;
+import org.apache.amber.oauth2.ext.dynamicreg.common.OAuthRegistration;
+import org.apache.amber.oauth2.ext.dynamicreg.client.response.OAuthClientRegistrationResponse;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import org.apache.amber.oauth2.client.demo.exception.ApplicationException;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+@Controller
+@RequestMapping("/")
+public class RegistrationController {
+
+ @RequestMapping(value = "/register")
+ public ModelAndView authorize(@ModelAttribute("oauthRegParams") OAuthRegParams oauthRegParams,
+ @ModelAttribute("oauthParams") OAuthParams oauthParams,
+ HttpServletRequest req) throws OAuthSystemException, IOException {
+
+
+ try {
+
+ Utils.validateRegistrationParams(oauthRegParams);
+
+ OAuthClientRequest request = null;
+ if (Utils.REG_TYPE_PULL.equals(oauthRegParams.getRegistrationType())) {
+ request = OAuthClientRegistrationRequest
+ .location(oauthRegParams.getRegistrationEndpoint(), OAuthRegistration.Type.PULL)
+ .setUrl(oauthRegParams.getUrl())
+ .buildBodyMessage();
+ } else {
+ request = OAuthClientRegistrationRequest
+ .location(oauthRegParams.getRegistrationEndpoint(), OAuthRegistration.Type.PUSH)
+ .setName(oauthRegParams.getName())
+ .setUrl(oauthRegParams.getUrl())
+ .setDescription(oauthRegParams.getDescription())
+ .setRedirectURI(oauthRegParams.getRedirectUri())
+ .setIcon(oauthRegParams.getIcon())
+ .buildBodyMessage();
+ }
+
+
+ OAuthRegistrationClient client = new OAuthRegistrationClient(new URLConnectionClient());
+ OAuthClientRegistrationResponse response = client.clientInfo(request);
+
+ oauthParams.setClientId(response.getClientId());
+ oauthParams.setClientSecret(response.getClientSecret());
+ oauthParams.setAuthzEndpoint(oauthRegParams.getAuthzEndpoint());
+ oauthParams.setTokenEndpoint(oauthRegParams.getTokenEndpoint());
+ oauthParams.setApplication(oauthRegParams.getApplication());
+ oauthParams.setRedirectUri(oauthRegParams.getRedirectUri());
+
+ return new ModelAndView("get_authz");
+
+
+ } catch (ApplicationException e) {
+ oauthRegParams.setErrorMessage(e.getMessage());
+ return new ModelAndView("register");
+ } catch (OAuthProblemException e) {
+ oauthRegParams.setErrorMessage(e.getMessage());
+ return new ModelAndView("register");
+ }
+ }
+
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/RegistrationController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/ResourceController.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/ResourceController.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/ResourceController.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/ResourceController.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.controller;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.client.demo.Utils;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.apache.amber.oauth2.common.utils.OAuthUtils;
+import org.apache.amber.oauth2.common.OAuth;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+@Controller
+@RequestMapping("/get_resource")
+public class ResourceController {
+
+ @RequestMapping
+ public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams,
+ HttpServletRequest req) {
+
+ try {
+ String tokenName = OAuth.OAUTH_TOKEN_DRAFT_0;
+ if (Utils.SMART_GALLERY.equals(oauthParams.getApplication())) {
+ tokenName = OAuth.OAUTH_TOKEN;
+ }
+ URL url = new URL(
+ oauthParams.getResourceUrl() + "?" + tokenName + "=" + oauthParams.getAccessToken());
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+ if (conn.getResponseCode() == 200) {
+ oauthParams.setResource(OAuthUtils.saveStreamAsString(conn.getInputStream()));
+ } else {
+ oauthParams.setErrorMessage(
+ "Could not access resource: " + conn.getResponseCode() + " " + conn.getResponseMessage());
+ }
+ } catch (IOException e) {
+ oauthParams.setErrorMessage(e.getMessage());
+ }
+
+ return new ModelAndView("resource");
+
+
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/ResourceController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/TokenController.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/TokenController.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/TokenController.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/TokenController.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.controller;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.client.OAuthClient;
+import org.apache.amber.oauth2.client.URLConnectionClient;
+import org.apache.amber.oauth2.client.demo.Utils;
+import org.apache.amber.oauth2.client.demo.exception.ApplicationException;
+import org.apache.amber.oauth2.client.demo.model.OAuthParams;
+import org.apache.amber.oauth2.client.request.OAuthClientRequest;
+import org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.message.types.GrantType;
+import org.apache.amber.oauth2.client.response.GitHubTokenResponse;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import org.apache.amber.oauth2.client.response.OAuthJSONAccessTokenResponse;
+
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+@Controller
+@RequestMapping("/get_token")
+public class TokenController {
+
+ @RequestMapping
+ public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams,
+ HttpServletRequest req) throws OAuthSystemException, IOException {
+
+ try {
+
+ Utils.validateTokenParams(oauthParams);
+
+ OAuthClientRequest request = OAuthClientRequest
+ .tokenLocation(oauthParams.getTokenEndpoint())
+ .setClientId(oauthParams.getClientId())
+ .setClientSecret(oauthParams.getClientSecret())
+ .setRedirectURI(oauthParams.getRedirectUri())
+ .setCode(oauthParams.getAuthzCode())
+ .setGrantType(GrantType.AUTHORIZATION_CODE)
+ .buildQueryMessage();
+
+ OAuthClient client = new OAuthClient(new URLConnectionClient());
+ String app = Utils.findCookieValue(req, "app");
+
+ OAuthAccessTokenResponse oauthResponse = null;
+ Class<? extends OAuthAccessTokenResponse> cl = OAuthJSONAccessTokenResponse.class;
+
+ if (Utils.FACEBOOK.equals(app)) {
+ cl = GitHubTokenResponse.class;
+ } else if (Utils.GITHUB.equals(app)) {
+ cl = GitHubTokenResponse.class;
+ }
+
+ oauthResponse = client.accessToken(request, cl);
+
+ oauthParams.setAccessToken(oauthResponse.getAccessToken());
+ oauthParams.setExpiresIn(Utils.isIssued(oauthResponse.getExpiresIn()));
+ oauthParams.setRefreshToken(Utils.isIssued(oauthResponse.getRefreshToken()));
+
+ return new ModelAndView("get_resource");
+
+ } catch (ApplicationException e) {
+ oauthParams.setErrorMessage(e.getMessage());
+ return new ModelAndView("request_token");
+ } catch (OAuthProblemException e) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("</br>");
+ sb.append("Error code: ").append(e.getError()).append("</br>");
+ sb.append("Error description: ").append(e.getDescription()).append("</br>");
+ sb.append("Error uri: ").append(e.getUri()).append("</br>");
+ sb.append("State: ").append(e.getState()).append("</br>");
+ oauthParams.setErrorMessage(sb.toString());
+ return new ModelAndView("get_authz");
+ }
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/TokenController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/ApplicationException.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/ApplicationException.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/ApplicationException.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/ApplicationException.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.exception;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class ApplicationException extends Exception {
+
+ public ApplicationException() {
+ super(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public ApplicationException(String s) {
+ super(s); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public ApplicationException(String s, Throwable throwable) {
+ super(s, throwable); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public ApplicationException(Throwable throwable) {
+ super(throwable); //To change body of overridden methods use File | Settings | File Templates.
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/exception/ApplicationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthParams.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthParams.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthParams.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthParams.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,159 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.model;
+
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class OAuthParams {
+
+ private String clientId;
+ private String clientSecret;
+ private String redirectUri;
+ private String authzEndpoint;
+ private String tokenEndpoint;
+ private String authzCode;
+ private String accessToken;
+ private String expiresIn;
+ private String refreshToken;
+ private String scope;
+ private String resourceUrl;
+ private String resource;
+ private String application;
+
+ private String errorMessage;
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ public String getRedirectUri() {
+ return redirectUri;
+ }
+
+ public void setRedirectUri(String redirectUri) {
+ this.redirectUri = redirectUri;
+ }
+
+ public String getAuthzEndpoint() {
+ return authzEndpoint;
+ }
+
+ public void setAuthzEndpoint(String authzEndpoint) {
+ this.authzEndpoint = authzEndpoint;
+ }
+
+ public String getTokenEndpoint() {
+ return tokenEndpoint;
+ }
+
+ public void setTokenEndpoint(String tokenEndpoint) {
+ this.tokenEndpoint = tokenEndpoint;
+ }
+
+ public String getAuthzCode() {
+ return authzCode;
+ }
+
+ public void setAuthzCode(String authzCode) {
+ this.authzCode = authzCode;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public String getExpiresIn() {
+ return expiresIn;
+ }
+
+ public void setExpiresIn(String expiresIn) {
+ this.expiresIn = expiresIn;
+ }
+
+ public String getRefreshToken() {
+ return refreshToken;
+ }
+
+ public void setRefreshToken(String refreshToken) {
+ this.refreshToken = refreshToken;
+ }
+
+ public String getResourceUrl() {
+ return resourceUrl;
+ }
+
+ public void setResourceUrl(String resourceUrl) {
+ this.resourceUrl = resourceUrl;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ public String getApplication() {
+ return application;
+ }
+
+ public void setApplication(String application) {
+ this.application = application;
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthParams.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthRegParams.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthRegParams.java?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthRegParams.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthRegParams.java Sat Dec 18 16:34:41 2010
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * 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.oauth2.client.demo.model;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class OAuthRegParams extends OAuthParams {
+
+ private String registrationType;
+ private String name = "OAuth V2.0 Demo Application";
+ private String url = "http://localhost:8080";
+ private String description = "Demo Application of the OAuth V2.0 Protocol";
+ private String icon = "http://localhost:8080/demo.png";
+ private String registrationEndpoint;
+
+ public String getRegistrationType() {
+ return registrationType;
+ }
+
+ public void setRegistrationType(String registrationType) {
+ this.registrationType = registrationType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getIcon() {
+ return icon;
+ }
+
+ public void setIcon(String icon) {
+ this.icon = icon;
+ }
+
+ public String getRegistrationEndpoint() {
+ return registrationEndpoint;
+ }
+
+ public void setRegistrationEndpoint(String registrationEndpoint) {
+ this.registrationEndpoint = registrationEndpoint;
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/java/org/apache/amber/oauth2/client/demo/model/OAuthRegParams.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/jdoconfig.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/jdoconfig.xml?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/jdoconfig.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/jdoconfig.xml Sat Dec 18 16:34:41 2010
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+-->
+
+<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <persistence-manager-factory name="transactions-optional">
+ <property name="javax.jdo.PersistenceManagerFactoryClass"
+ value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
+ <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
+ <property name="javax.jdo.option.NontransactionalRead" value="true"/>
+ <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
+ <property name="javax.jdo.option.RetainValues" value="true"/>
+ <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
+ </persistence-manager-factory>
+</jdoconfig>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/jdoconfig.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/persistence.xml?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/persistence.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/persistence.xml Sat Dec 18 16:34:41 2010
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="transactions-optional">
+ <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
+ <properties>
+ <property name="datanucleus.NontransactionalRead" value="true"/>
+ <property name="datanucleus.NontransactionalWrite" value="true"/>
+ <property name="datanucleus.ConnectionURL" value="appengine"/>
+ </properties>
+ </persistence-unit>
+
+</persistence>
\ No newline at end of file
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/log4j.properties?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/log4j.properties (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/log4j.properties Sat Dec 18 16:34:41 2010
@@ -0,0 +1,29 @@
+#
+# Copyright 2010 Newcastle University
+#
+# http://research.ncl.ac.uk/smart/
+#
+# 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.
+#
+
+log4j.rootCategory=INFO, CONSOLE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%d{yyyy-mm-dd hh:mm:ss.S},%6.6r]%-5p[%t]%x(%F:%L) - %m%n
+
+#log4j.logger.org.hibernate.search=TRACE
\ No newline at end of file
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/app-config.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/app-config.xml?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/app-config.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/app-config.xml Sat Dec 18 16:34:41 2010
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <!-- Scans within the base package of the application for @Components to configure as beans -->
+ <context:component-scan base-package="org.apache.amber.oauth2.client.demo"/>
+
+</beans>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/app-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/mvc-config.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/mvc-config.xml?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/mvc-config.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/mvc-config.xml Sat Dec 18 16:34:41 2010
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
+
+ <!-- Configures support for @Controllers -->
+ <mvc:annotation-driven/>
+
+ <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
+ <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <property name="prefix" value="/WEB-INF/views/"/>
+ <property name="suffix" value=".jsp"/>
+ </bean>
+
+</beans>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/spring/mvc-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/urlrewrite.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/urlrewrite.xml?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/urlrewrite.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/urlrewrite.xml Sat Dec 18 16:34:41 2010
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+-->
+
+<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
+ "http://tuckey.org/res/dtds/urlrewrite3.0.dtd">
+<urlrewrite default-match-type="wildcard">
+ <rule>
+ <from>/</from>
+ <to>/app/index</to>
+ </rule>
+ <rule>
+ <from>/**</from>
+ <to>/app/$1</to>
+ </rule>
+ <outbound-rule>
+ <from>/app/**</from>
+ <to>/$1</to>
+ </outbound-rule>
+</urlrewrite>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/urlrewrite.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_authz.jsp
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_authz.jsp?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_authz.jsp (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_authz.jsp Sat Dec 18 16:34:41 2010
@@ -0,0 +1,84 @@
+<%--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ page session="false" %>
+<%--@elvariable id="oauthParams" type="org.apache.amber.oauth2.client.demo.model.OAuthParams"--%>
+
+<html>
+<head>
+ <title>OAuth V2.0 Client Application</title>
+</head>
+
+<body>
+<h1>Sample OAuth V2.0 Client Application</h1>
+
+<h2>Web Server Flow</h2>
+
+<h3>Step 1. Get User's Authorization</h3></p>
+
+<c:if test="${!empty oauthParams.errorMessage}">
+ <font color="red"><p>Error: ${oauthParams.errorMessage}</p></font>
+</c:if>
+
+<form:form commandName="oauthParams" action="/authorize">
+ <table>
+ <tr>
+ <td>Required OAuth parameters:</td>
+ </tr>
+ <tr>
+ <td>Requested Access Scope</td>
+ <td><form:input size="70" path="scope"/></td>
+ </tr>
+ <tr>
+ <td>End-User Authorization URL:</td>
+ <td><form:input size="70" path="authzEndpoint"/></td>
+ </tr>
+ <tr>
+ <td>Token Endpoint:</td>
+ <td><form:input size="70" path="tokenEndpoint"/></td>
+ </tr>
+ <tr>
+ <td>Client ID:</td>
+ <td><form:input size="70" path="clientId"/></td>
+ </tr>
+ <tr>
+ <td>Client Secret:</td>
+ <td><form:input size="70" path="clientSecret"/></td>
+ </tr>
+ <tr>
+ <td>Redirect URI:</td>
+ <td><form:input size="70" path="redirectUri"/></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <form:hidden path="application"/>
+ <input type="submit" value="Get Authorization"/>
+ </td>
+ </tr>
+ </table>
+</form:form>
+
+</body>
+</html>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_authz.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_resource.jsp
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_resource.jsp?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_resource.jsp (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_resource.jsp Sat Dec 18 16:34:41 2010
@@ -0,0 +1,99 @@
+<%--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ page session="false" %>
+<%--@elvariable id="oauthParams" type="org.apache.amber.oauth2.client.demo.model.OAuthParams"--%>
+
+<html>
+<head>
+ <title>OAuth V2.0 Client Application</title>
+</head>
+
+<body>
+<h1>Sample OAuth V2.0 Client Application</h1>
+
+<h2>Web Server Flow</h2>
+
+<h3>Step 3. Get Resource</h3></p>
+
+<c:if test="${!empty oauthParams.errorMessage}">
+ <p><font color="red">${oauthParams.errorMessage}</font></p>
+</c:if>
+
+<form:form commandName="oauthParams" action="/get_resource">
+ <table>
+ <tr>
+ <td>Required OAuth parameters:</td>
+ </tr>
+ <tr>
+ <td>Resource URL:</td>
+ <td><form:input size="70" path="resourceUrl"/></td>
+ </tr>
+ <tr>
+ <td>Access Token:</td>
+ <td><form:input size="70" path="accessToken" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Expires In:</td>
+ <td><form:input size="70" path="expiresIn" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Refresh Token:</td>
+ <td><form:input size="70" path="refreshToken" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Requested Access Scope</td>
+ <td><form:input size="70" path="scope" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>End-User Authorization URL:</td>
+ <td><form:input size="70" path="authzEndpoint" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Token Endpoint:</td>
+ <td><form:input size="70" path="tokenEndpoint" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Client ID:</td>
+ <td><form:input size="70" path="clientId" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Client Secret:</td>
+ <td><form:input size="70" path="clientSecret" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td>Redirect URI:</td>
+ <td><form:input size="70" path="redirectUri" readonly="true"/></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <form:hidden path="application"/>
+ <input type="submit" value="Get Resource"/>
+ </td>
+ </tr>
+ </table>
+</form:form>
+</body>
+</html>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/get_resource.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/index.jsp
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/index.jsp?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/index.jsp (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/index.jsp Sat Dec 18 16:34:41 2010
@@ -0,0 +1,47 @@
+<%--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ page session="false" %>
+<%--@elvariable id="oauthParams" type="org.apache.amber.oauth2.client.demo.model.OAuthParams"--%>
+
+<html>
+<head>
+ <title>OAuth V2.0 Client Application</title>
+</head>
+
+<body>
+<h1>Sample OAuth V2.0 Client Application</h1>
+
+<h2>Web Server Flow</h2>
+
+<h3>Choose Application</h3>
+
+<a href="/main/smart_gallery">Smart Gallery</a>
+<a href="/main/facebook">Facebook</a>
+<a href="/main/github">Github</a>
+<a href="/main/gowalla">Gowalla</a>
+
+</body>
+</html>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/register.jsp
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/register.jsp?rev=1050662&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/register.jsp (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/register.jsp Sat Dec 18 16:34:41 2010
@@ -0,0 +1,93 @@
+<%--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ 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.
+
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ page session="false" %>
+<%--@elvariable id="oauthRegParams" type="org.apache.amber.oauth2.client.demo.model.OAuthRegParams"--%>
+
+<html>
+<head>
+ <title>OAuth V2.0 Client Application</title>
+</head>
+
+<body>
+<h1>Sample OAuth V2.0 Client Application</h1>
+
+<h2>Dynamic Registration</h2>
+
+<h3>Step 0. Dynamically Register Application</h3>
+
+<c:if test="${!empty oauthRegParams.errorMessage}">
+ <p><font color="red">${oauthRegParams.errorMessage}</font></p>
+</c:if>
+
+<form:form commandName="oauthRegParams" action="/register">
+ <table>
+ <tr>
+ <td>Required OAuth Dynamic Registration parameters:</td>
+ </tr>
+ <tr>
+ <td>Registration Type:</td>
+ <td><form:select path="registrationType">
+ <form:option value="push"/>
+ <form:option value="pull"/>
+ </form:select></td>
+ </tr>
+ <tr>
+ <td>Application Name:</td>
+ <td><form:input size="70" path="name"/></td>
+ </tr>
+ <tr>
+ <td>Application URL:</td>
+ <td><form:input size="70" path="url"/></td>
+ </tr>
+ <tr>
+ <td>Application Description:</td>
+ <td><form:input size="70" path="description"/></td>
+ </tr>
+ <tr>
+ <td>Application Redirect URI:</td>
+ <td><form:input size="70" path="redirectUri"/></td>
+ </tr>
+ <tr>
+ <td>Application Icon URL:</td>
+ <td><form:input size="70" path="icon"/></td>
+ </tr>
+ <tr>
+ <td>OAuth Registration Endpoint:</td>
+ <td><form:input size="70" path="registrationEndpoint"/></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <form:hidden path="authzEndpoint"/>
+ <form:hidden path="tokenEndpoint"/>
+ <form:hidden path="application"/>
+ <input type="submit" value="Register Application"/>
+ </td>
+ </tr>
+ </table>
+</form:form>
+
+</body>
+</html>
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-client-demo/src/main/webapp/WEB-INF/views/register.jsp
------------------------------------------------------------------------------
svn:eol-style = native