Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
separate SSL and authentication options
Browse files Browse the repository at this point in the history
just because you're using authentication doesn't mean you want to use
SSL
  • Loading branch information
joehobson committed Jan 17, 2012
1 parent 68e46e5 commit 87e76d1
Showing 1 changed file with 52 additions and 9 deletions.
61 changes: 52 additions & 9 deletions src/com/navnorth/learningregistry/LRExporter.java
Expand Up @@ -62,6 +62,7 @@ public class LRExporter
// Cofiguration variables
private int batchSize;
private String url;
private boolean publishOverSSL = false;
private String publishAuthUser;
private String publishAuthPassword;

Expand All @@ -87,12 +88,12 @@ public LRExporter(int batchSize, String url)

/**
* Creates the exporter object with the specified details
* This version of the constructor sets the exporter up to use SSL
* This version of the constructor sets the exporter up to send a username and password
*
* @param batchSize the number of items to submit per batch to the Learning Registry node
* @param url location of the Learning Registry node to use for export
* @param publishAuthUser user value for SSL
* @param publishAuthPassword password value for SSL
* @param publishAuthUser user value for authentication
* @param publishAuthPassword password value for authentication
*/
public LRExporter(int batchSize, String url, String publishAuthUser, String publishAuthPassword)
{
Expand All @@ -102,6 +103,26 @@ public LRExporter(int batchSize, String url, String publishAuthUser, String publ
this.publishAuthPassword = publishAuthPassword;
}

/**
* Creates the exporter object with the specified details
* This version of the constructor sets the exporter up to use SSL
*
* @param batchSize the number of items to submit per batch to the Learning Registry node
* @param url location of the Learning Registry node to use for export
* @param publishAuthUser user value for authentication
* @param publishAuthPassword password value for authentication
* @param publishOverSSL whether or not to use SSL for publishing
*/
public LRExporter(int batchSize, String url, String publishAuthUser, String publishAuthPassword, boolean publishOverSSL)
{
this.batchSize = batchSize;
this.url = url;
this.publishAuthUser = publishAuthUser;
this.publishAuthPassword = publishAuthPassword;
this.publishOverSSL = publishOverSSL;
}


/**
* Attempt to configure the exporter with the values used in the constructor
* This must be called before an exporter can be used and after any setting of configuration values
Expand Down Expand Up @@ -129,15 +150,15 @@ public void configure() throws LRException

this.batchSize = batchSize;

// If both authorization values are not present, use the non-SSL url
if (publishAuthUser == null || publishAuthPassword == null)
// if SSL, use SSL prefix
if (publishOverSSL)
{
this.url = publishUrlPrefix + url + publishUrlPath;
this.url = publishSSLUrlPrefix + url + publishUrlPath;
}
// Otherwise, use the SSL url
// Otherwise, use the non-SSL url
else
{
this.url = publishSSLUrlPrefix + url + publishUrlPath;
this.url = publishUrlPrefix + url + publishUrlPath;
}

this.publishAuthUser = publishAuthUser;
Expand Down Expand Up @@ -400,7 +421,7 @@ public void setPublishAuthPassword(String publishAuthPassword)
this.publishAuthPassword = publishAuthPassword;
configured = false;
}

/**
* Get the publishAuthPassword value
*
Expand All @@ -410,4 +431,26 @@ public String getPublishAuthPassword()
{
return publishAuthPassword;
}

/**
* Get the publishOverSSL value
*
* @return publishOverSSL value
*/
public boolean getPublishOverSSL()
{
return publishOverSSL;
}

/**
* Sets the publishOverSSL value
* Must call "configure" on exporter after setting this
*
* @param publishOverSSL value
*/
public void setPublishOverSSL(boolean publishOverSSL)
{
this.publishOverSSL = publishOverSSL;
configured = false;
}
}

0 comments on commit 87e76d1

Please sign in to comment.