Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branches 'release-1.6' and 'master'

  • Loading branch information...
commit 51521c8ac9903e9dec1c5018ffd15b5893b7a687 3 parents 3ae9e72 + c656163 + 3ae9e72
@nischal nischal authored
View
2  build.xml
@@ -5,7 +5,7 @@
<property name="lib.dir" value="lib" />
<property name="build.dir" value="build" />
<property name="project.name" value="face4j" />
- <property name="project.version" value="1.5.11" />
+ <property name="project.version" value="1.6" />
<property name="dist.dir" value="dist" />
<property name="archive.name-face4j" value="face4j-${project.version}" />
<property name="exclude-classes" value="com/face4j/dummy/**,com/face4j/facebook/test/**"></property>
View
BIN  dist/face4j-1.6.jar
Binary file not shown
View
BIN  lib/commons-io-2.0.1.jar
Binary file not shown
View
3  release.txt
@@ -82,3 +82,6 @@ version 0.4.1
15/01/2012
1.5.11
+
+26/04/2012
+1.6
View
76 src/com/face4j/facebook/http/APICaller.java
@@ -1,8 +1,20 @@
package com.face4j.facebook.http;
+import java.io.FileNotFoundException;
import java.io.IOException;
-
-import org.apache.commons.httpclient.*;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
@@ -30,10 +42,70 @@ private synchronized static HttpClient getHttpClient() {
connectionManager.getParams().setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 15);
connectionManager.getParams().setMaxTotalConnections(15);
httpClient = new HttpClient(connectionManager);
+
+ String username = null;
+ String password = null;
+ String host = null;
+ int port = -1;
+ Credentials credentials = null;
+
+ //Check if username and password exists in any resource file
+ try {
+ InputStream inputStream = ClassLoader.getSystemResourceAsStream("face4j.properties");
+ Properties properties = new Properties();
+ properties.load(inputStream);
+ inputStream.close();
+
+ username = properties.getProperty("client.proxy.username");
+ password = properties.getProperty("client.proxy.password");
+ host = properties.getProperty("client.proxy.host");
+ if(properties.getProperty("client.proxy.port") != null){
+ port = Integer.parseInt(properties.getProperty("client.proxy.port"));
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ if(username != null || password != null){
+ credentials = new UsernamePasswordCredentials(username, password);
+ httpClient.getState().setCredentials(AuthScope.ANY, credentials);
+ }
+
+ if(username != null || password != null || host != null || port > -1){
+ try {
+ httpClient.getState().setCredentials( new AuthScope(host, port), credentials);
+ } finally {
+ }
+ }
+
}
return httpClient;
}
+ /*public static void main(String[] args) {
+ InputStream inputStream = ClassLoader.getSystemResourceAsStream("face4j.properties");
+
+ try {
+ Properties properties = new Properties();
+ properties.load(inputStream);
+ inputStream.close();
+
+ Enumeration enuKeys = properties.keys();
+ while (enuKeys.hasMoreElements()) {
+ String key = (String) enuKeys.nextElement();
+ String value = properties.getProperty(key);
+ System.out.println(key + " : " + value);
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }*/
+
public static APICaller getInstance(){
return caller;
}
View
4 src/face4j.properties
@@ -0,0 +1,4 @@
+#client.proxy.host localhost
+#client.proxy.port 8080
+#client.proxy.username username-here
+#client.proxy.password password-here
Please sign in to comment.
Something went wrong with that request. Please try again.