oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1432904 - in /incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client: OAuthClient.java request/OAuthBearerClientRequest.java response/OAuthClientResponse.java response/OAuthResourceResponse.java
Date Mon, 14 Jan 2013 12:52:52 GMT
Author: asanso
Date: Mon Jan 14 12:52:52 2013
New Revision: 1432904

URL: http://svn.apache.org/viewvc?rev=1432904&view=rev
Log:
AMBER-70 -  Extend the client library in order to easily handle bearer token request

Added:
    incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/request/OAuthBearerClientRequest.java
    incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthResourceResponse.java
Modified:
    incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
    incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthClientResponse.java

Modified: incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java?rev=1432904&r1=1432903&r2=1432904&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
(original)
+++ incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/OAuthClient.java
Mon Jan 14 12:52:52 2013
@@ -26,6 +26,7 @@ import java.util.Map;
 
 import org.apache.amber.oauth2.client.request.OAuthClientRequest;
 import org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse;
+import org.apache.amber.oauth2.client.response.OAuthClientResponse;
 import org.apache.amber.oauth2.client.response.OAuthJSONAccessTokenResponse;
 import org.apache.amber.oauth2.common.OAuth;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
@@ -75,6 +76,10 @@ public class OAuthClient {
         throws OAuthSystemException, OAuthProblemException {
         return accessToken(request, requestMethod, OAuthJSONAccessTokenResponse.class);
     }
+    
+    public  <T extends OAuthClientResponse> T resource(OAuthClientRequest request,
String requestMethod,Class<T> responseClass) throws OAuthSystemException, OAuthProblemException{
+    	return httpClient.execute(request, null, requestMethod, responseClass);     
+    }
 
     public void shutdown() {
         httpClient.shutdown();

Added: incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/request/OAuthBearerClientRequest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/request/OAuthBearerClientRequest.java?rev=1432904&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/request/OAuthBearerClientRequest.java
(added)
+++ incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/request/OAuthBearerClientRequest.java
Mon Jan 14 12:52:52 2013
@@ -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.
+ */
+package org.apache.amber.oauth2.client.request;
+
+import org.apache.amber.oauth2.client.request.OAuthClientRequest.OAuthRequestBuilder;
+import org.apache.amber.oauth2.common.OAuth;
+
+public class OAuthBearerClientRequest extends OAuthRequestBuilder  {
+
+	public OAuthBearerClientRequest(String url) {
+		super(url);
+	}
+
+    public OAuthBearerClientRequest setAccessToken(String accessToken) {
+        this.parameters.put(OAuth.OAUTH_BEARER_TOKEN, accessToken);
+        return this;
+    }
+	
+}

Modified: incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthClientResponse.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthClientResponse.java?rev=1432904&r1=1432903&r2=1432904&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthClientResponse.java
(original)
+++ incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthClientResponse.java
Mon Jan 14 12:52:52 2013
@@ -48,7 +48,7 @@ public abstract class OAuthClientRespons
 
     protected abstract void setBody(String body) throws OAuthProblemException;
 
-    protected abstract void setContentType(String contentTypr);
+    protected abstract void setContentType(String contentType);
 
     protected abstract void setResponseCode(int responseCode);
 

Added: incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthResourceResponse.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthResourceResponse.java?rev=1432904&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthResourceResponse.java
(added)
+++ incubator/amber/trunk/oauth-2.0/client/src/main/java/org/apache/amber/oauth2/client/response/OAuthResourceResponse.java
Mon Jan 14 12:52:52 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.response;
+
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+
+public class OAuthResourceResponse  extends OAuthClientResponse {
+	
+    public String getBody() {
+        return body;
+    }	
+ 
+	public int getResponseCode() {
+		return responseCode;
+	}
+	
+	public String getContentType(){
+		return contentType;
+	}
+    
+	@Override
+	protected void setBody(String body) throws OAuthProblemException {
+		 this.body = body;
+	}
+
+	@Override
+	protected void setContentType(String contentType) {
+		this.contentType = contentType;	
+	}
+
+	@Override
+	protected void setResponseCode(int responseCode) {
+		this.responseCode = responseCode;
+	}
+	
+	@Override
+	protected void init(String body, String contentType, int responseCode) throws OAuthProblemException
{
+        this.setBody(body);
+        this.setContentType(contentType);
+        this.setResponseCode(responseCode);
+	}
+
+}



Mime
View raw message