Commits

Joeri Sykora committed 6443cfc

configure oauth handling for jersey-oauth

Comments (0)

Files changed (7)

oauthprovider/nb-configuration.xml

 -->
         <netbeans.compile.on.save>all</netbeans.compile.on.save>
         <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
+        <org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>user</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
     </properties>
 </project-shared-configuration>

oauthprovider/pom.xml

             <version>1.0.0</version>
         </dependency>
         <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-server</artifactId>
-            <version>1.11.1</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
-            <artifactId>oauth-signature</artifactId>
-            <version>1.11.1</version>
-        </dependency>
-        <dependency>
             <groupId>javax</groupId>
             <artifactId>javaee-web-api</artifactId>
             <version>6.0</version>

oauthprovider/src/main/java/com/mycompany/oauthprovider/servlet/OAuthServlet.java

  *
  * @author joeri
  */
-@WebServlet(name = "OAuthServlet", urlPatterns = {"/oauth"})
+@WebServlet(name = "OAuthServlet", urlPatterns = {"/oauth/authenticate"})
 public class OAuthServlet extends HttpServlet {
 
 	/**

oauthprovider/src/main/java/com/mycompany/oauthprovider/view/Authorization.java

 		if (user != null) {
 			this.verifier = oauthBean.authorizeServiceConsumer(user.getId(), oauthToken, true);
 			if ("oob".equals(requestToken.getCallback())) {
-				return "/pages/verifier";
+				return "/pages/oob";
 			} else {
 				FacesContext.getCurrentInstance().getExternalContext().redirect(requestToken.getCallback() + "?" + OAuthParameters.TOKEN + "=" + URLEncoder.encode(oauthToken, "UTF-8") + "&" + OAuthParameters.VERIFIER + "=" + URLEncoder.encode(verifier, "UTF-8"));
 			}
 
 		if ("oob".equals(requestToken.getCallback())) {
 			this.verifier = "Denied.";
-			return "/pages/verifier";
+			return "/pages/oob";
 		} else {
 			FacesContext.getCurrentInstance().getExternalContext().redirect(requestToken.getCallback());
 		}

oauthprovider/src/main/webapp/WEB-INF/web.xml

 		<param-value>Development</param-value>
 	</context-param>
 
+	<filter>
+		<filter-name>jerseyfilter</filter-name>
+		<filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
+		<init-param>
+			<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
+			<param-value>(/index.jsp|/serviceconsumer|/(faces|pages|oauth)/.*)</param-value>
+		</init-param>
+		<init-param>
+			<param-name>com.sun.jersey.config.property.oauth.ignorePathPattern</param-name>
+			<param-value>requestToken|accessToken</param-value>
+		</init-param>
+		<init-param>
+			<param-name>com.sun.jersey.config.property.packages</param-name>
+			<param-value>com.sun.jersey.oauth.server.api.resources;com.lodgon.dali.core.oauth</param-value>
+		</init-param>
+	</filter>
+	<filter-mapping>
+		<filter-name>jerseyfilter</filter-name>
+		<url-pattern>/*</url-pattern>
+	</filter-mapping>
+
 	<servlet>
-			<servlet-name>Faces Servlet</servlet-name>
-			<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
-			<load-on-startup>1</load-on-startup>
+		<servlet-name>Faces Servlet</servlet-name>
+		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
 	</servlet>
-
 	<servlet-mapping>
-			<servlet-name>Faces Servlet</servlet-name>
-			<url-pattern>/faces/*</url-pattern>
-			<url-pattern>*.faces</url-pattern>
+		<servlet-name>Faces Servlet</servlet-name>
+		<url-pattern>/faces/*</url-pattern>
+		<url-pattern>*.faces</url-pattern>
 	</servlet-mapping>
 
 	<session-config>

oauthprovider/src/main/webapp/sections/authorize/content.xhtml

 			<h:form id="form">
 				<h:inputHidden id="oauth_token" value="#{authorization.oauthToken}"/>
 				<h:inputHidden id="user_uid" value="#{authorization.userUid}"/>
-				<h:commandButton value="Yes" action="#{authorization.authorize}"/>
-				<h:commandButton value="No" action="#{authorization.reject}"/>
+				<h:commandButton value="Yes" action="#{authorization.allow()}"/>
+				<h:commandButton value="No" action="#{authorization.deny()}"/>
 			</h:form>
 		</ui:composition>
 	</h:body>

oauthprovider/src/main/webapp/sections/login/content.xhtml

 		</ui:composition>
 	</h:body>
 </html>
-