Navigation Menu

Skip to content

Commit

Permalink
Corrected error with config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
amgrobelny-box committed Nov 9, 2017
1 parent 93ab17c commit 446b441
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions box-java-servlet-skeleton-app/Dockerfile
Expand Up @@ -2,6 +2,7 @@ FROM tomcat:latest
COPY ./UnlimitedJCEPolicyJDK8/* \
/usr/lib/jvm/java-1.8-openjdk/jre/lib/security/
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
ADD ./config.json /usr/local/tomcat/
ADD ./target/servlet-with-box-and-auth0.war /usr/local/tomcat/webapps/ROOT.war
EXPOSE 8080
CMD ["catalina.sh", "run"]
4 changes: 2 additions & 2 deletions box-java-servlet-skeleton-app/README.md
Expand Up @@ -35,7 +35,7 @@ If you don't install this, you'll get an exception about key length. This is not
* *You may need to enter a 2-factor confirmation code.*
* Save the JSON config file -- this config file also contains the private key generated for your application.
* *Note: Box does not store the generated private key and this config file is the only copy of the private key. You can always delete this keypair from your application and generate a new keypair if you lose this config file.*
4. Be sure to add your configuration file to the `src > main > resource` directory.
4. Be sure to add your configuration file to the root of this project directory.
5. In the "CORS Allowed Origins" section, add `http://localhost:8080`.

#### Step 2. Authorize the Application in Your Box Account
Expand All @@ -49,7 +49,7 @@ If you don't install this, you'll get an exception about key length. This is not
* Your application is now authorized to access your Box account.

##### Step 3. Add Configuration File to the Java App
1. Add your generated Box config file to `src > main > resource` and name the file `config.json`.
1. Add your generated Box config file to the root of this project and name the file `config.json`.

#### Auth0 Configuration
Additionally, since you manage the identity and authorization for your Box App Users within your Java application, you'll need an identity service to fully utilize JWT authentication on behalf of your App Users.
Expand Down
Expand Up @@ -7,6 +7,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
Expand All @@ -32,19 +33,14 @@ public class BoxHelper {
static BoxConfig boxConfig;

static {
Path configPath;
try {
System.out.println("Searching for file..");
configPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource(BOX_CONFIG).toURI());
System.out.println(configPath.toString());
try (BufferedReader reader = Files.newBufferedReader(configPath, Charset.forName("UTF-8"))) {
boxConfig = BoxConfig.readFrom(reader);
accessTokenCache = new InMemoryLRUAccessTokenCache(MAX_CACHE_ENTRIES);
} catch (java.io.IOException e1) {
e1.printStackTrace();
}
} catch (URISyntaxException e) {
e.printStackTrace();
System.out.println("Searching for file..");
Path configPath = Paths.get(String.join("", System.getProperty("user.dir"), File.separator, BOX_CONFIG));
System.out.println(configPath.toString());
try (BufferedReader reader = Files.newBufferedReader(configPath, Charset.forName("UTF-8"))) {
boxConfig = BoxConfig.readFrom(reader);
accessTokenCache = new InMemoryLRUAccessTokenCache(MAX_CACHE_ENTRIES);
} catch (java.io.IOException e1) {
e1.printStackTrace();
}
}

Expand Down

0 comments on commit 446b441

Please sign in to comment.