Skip to content

Commit

Permalink
Merge branches 'release-1.6' and 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nischal committed Apr 26, 2012
3 parents 3ae9e72 + c656163 + 3ae9e72 commit 51521c8
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file added dist/face4j-1.6.jar
Binary file not shown.
Binary file added lib/commons-io-2.0.1.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ version 0.4.1

15/01/2012
1.5.11

26/04/2012
1.6
76 changes: 74 additions & 2 deletions src/com/face4j/facebook/http/APICaller.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/face4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#client.proxy.host localhost
#client.proxy.port 8080
#client.proxy.username username-here
#client.proxy.password password-here

0 comments on commit 51521c8

Please sign in to comment.