Skip to content

Commit

Permalink
Standardise Authentication port (#45)
Browse files Browse the repository at this point in the history
* Added Property to specify the authentication port from config file.
  • Loading branch information
vaibhavthapliyal authored and andresoviedo committed Jun 24, 2019
1 parent e435b25 commit 60e9474
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build/configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#server=
# TCP port where the application will listen for incoming connections
port=1821
#Port where the authentication server listens
#auth.port=8093
# FTP anonymous login
ftp.anonymous.enabled=false
ftp.anonymous.home=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public final class GoogleDriveFactory {
* Application name as of Google Drive Service
*/
private static final String APPLICATION_NAME = "google-drive-ftp-adapter";

/**
* Default port for authentication server
*/
private int authPort = -1;

/**
* Global instance of the JSON factory.
*/
Expand All @@ -52,6 +58,8 @@ public final class GoogleDriveFactory {
public GoogleDriveFactory(Properties configuration) {
/* Directory to store user credentials. */
java.io.File DATA_STORE_DIR = new java.io.File("data/google/" + configuration.getProperty("account", "default"));

authPort = Integer.parseInt(configuration.getProperty("auth.port", String.valueOf("-1")));

try {
// initialize the data store factory
Expand Down Expand Up @@ -108,7 +116,7 @@ private Credential authorize() throws Exception {
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets, scopes)
.setDataStoreFactory(dataStoreFactory).build();
// authorize
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver.Builder().setPort(authPort).build()).authorize("user");
}

public Drive getDrive() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#server=
# TCP port where the application will listen for incoming connections
#port=1821
#Port where the authentication server listens
#auth.port=8093
# FTP anonymous login
#ftp.anonymous.enabled=false
#ftp.anonymous.home=
Expand Down

0 comments on commit 60e9474

Please sign in to comment.