diff --git a/README.md b/README.md index 21985694..a01c0e65 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Install with Docker ------------------- From a Docker host, run this command to download and install Sismics Docs. The server will run on . -The default admin password is "admin". Don't forget to change it before going to production. +**The default admin password is "admin". Don't forget to change it before going to production.** docker run --rm --name sismics_docs_latest -d -p 8100:8080 -v sismics_docs_latest:/data sismics/docs:latest diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/LuceneUtil.java b/docs-core/src/main/java/com/sismics/docs/core/util/LuceneUtil.java index 2754c533..52f8df67 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/LuceneUtil.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/LuceneUtil.java @@ -1,7 +1,6 @@ package com.sismics.docs.core.util; -import java.io.IOException; - +import com.sismics.docs.core.model.context.AppContext; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; @@ -10,7 +9,7 @@ import org.apache.lucene.store.Directory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.sismics.docs.core.model.context.AppContext; +import java.io.IOException; /** * Lucene utils. @@ -26,8 +25,7 @@ public class LuceneUtil { /** * Encapsulate a process into a Lucene context. * - * @param runnable - * @throws IOException + * @param runnable Runnable */ public static void handle(LuceneRunnable runnable) { // Standard analyzer @@ -53,14 +51,18 @@ public class LuceneUtil { } catch (Exception e) { log.error("Error in running index writing transaction", e); try { - indexWriter.rollback(); + if (indexWriter != null) { + indexWriter.rollback(); + } } catch (IOException e1) { log.error("Cannot rollback index writing transaction", e1); } } try { - indexWriter.close(); + if (indexWriter != null) { + indexWriter.close(); + } } catch (IOException e) { log.error("Cannot commit and close IndexWriter", e); } @@ -75,9 +77,9 @@ public class LuceneUtil { /** * Code to run in a Lucene context. * - * @param indexWriter - * @throws Exception + * @param indexWriter Index writer + * @throws Exception e */ - public abstract void run(IndexWriter indexWriter) throws Exception; + void run(IndexWriter indexWriter) throws Exception; } } diff --git a/docs-core/src/main/java/com/sismics/util/totp/GoogleAuthenticator.java b/docs-core/src/main/java/com/sismics/util/totp/GoogleAuthenticator.java index c37147f9..92305303 100644 --- a/docs-core/src/main/java/com/sismics/util/totp/GoogleAuthenticator.java +++ b/docs-core/src/main/java/com/sismics/util/totp/GoogleAuthenticator.java @@ -30,19 +30,14 @@ package com.sismics.util.totp; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Random; +import org.apache.commons.codec.binary.Base32; +import org.apache.commons.codec.binary.Base64; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.codec.binary.Base32; -import org.apache.commons.codec.binary.Base64; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.*; /** * This class implements the functionality described in RFC 6238 (TOTP: Time @@ -116,7 +111,7 @@ public final class GoogleAuthenticator { /** * Modulus used to truncate the scratch code. */ - public static final int SCRATCH_CODE_MODULUS = (int) Math.pow(10, SCRATCH_CODE_LENGTH); + private static final int SCRATCH_CODE_MODULUS = (int) Math.pow(10, SCRATCH_CODE_LENGTH); /** * Magic number representing an invalid scratch code. @@ -171,14 +166,6 @@ public final class GoogleAuthenticator { config = new GoogleAuthenticatorConfig(); } - public GoogleAuthenticator(GoogleAuthenticatorConfig config) { - if (config == null) { - throw new IllegalArgumentException("Configuration cannot be null."); - } - - this.config = config; - } - /** * @return the random number generator algorithm. * @since 0.5.0 @@ -227,7 +214,7 @@ public final class GoogleAuthenticator { * @return the validation code for the provided key at the specified instant * of time. */ - int calculateCode(byte[] key, long tm) { + private int calculateCode(byte[] key, long tm) { // Allocating an array of bytes to represent the specified instant // of time. byte[] data = new byte[8]; @@ -439,7 +426,7 @@ public final class GoogleAuthenticator { return authorize(secret, verificationCode, new Date().getTime()); } - public boolean authorize(String secret, int verificationCode, long time) throws GoogleAuthenticatorException { + private boolean authorize(String secret, int verificationCode, long time) throws GoogleAuthenticatorException { // Checking user input and failing if the secret key was not provided. if (secret == null) { throw new IllegalArgumentException("Secret cannot be null."); diff --git a/pom.xml b/pom.xml index 0f862c3c..e7a2b538 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,7 @@ 1.11.2 1.3.0 + 9.2.13.v20150730 9.2.13.v20150730 9.2.13.v20150730 @@ -199,7 +200,7 @@ commons-lang ${commons-lang.commons-lang.version} - + commons-io commons-io