Skip to content

Commit

Permalink
Fix #24 - Limit the extensibility of classes and methods
Browse files Browse the repository at this point in the history
Apply Guideline 4-5 / EXTEND-5: Limit the extensibility of classes and
methods from the Secure Coding Guidelines for Java SE
https://www.oracle.com/technetwork/java/seccodeguide-139067.html#4-5
  • Loading branch information
OlivierJaquemet committed Feb 26, 2020
1 parent 234ce89 commit b3bd9e7
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.security.InvalidParameterException;
import java.security.NoSuchAlgorithmException;

public class DefaultCodeGenerator implements CodeGenerator {
public final class DefaultCodeGenerator implements CodeGenerator {

private final HashingAlgorithm algorithm;
private final int digits;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.samstevens.totp.exceptions.CodeGenerationException;
import dev.samstevens.totp.time.TimeProvider;

public class DefaultCodeVerifier implements CodeVerifier {
public final class DefaultCodeVerifier implements CodeVerifier {

private final CodeGenerator codeGenerator;
private final TimeProvider timeProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.samstevens.totp.exceptions;

public class CodeGenerationException extends Exception {
public final class CodeGenerationException extends Exception {
public CodeGenerationException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.samstevens.totp.exceptions;

public class QrGenerationException extends Exception {
public final class QrGenerationException extends Exception {
public QrGenerationException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.samstevens.totp.exceptions;

public class TimeProviderException extends RuntimeException {
public final class TimeProviderException extends RuntimeException {
public TimeProviderException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/samstevens/totp/qr/QrData.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.nio.charset.StandardCharsets;

@SuppressWarnings("WeakerAccess")
public class QrData {
public final class QrData {

private final String type;
private final String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import dev.samstevens.totp.exceptions.QrGenerationException;
import java.io.ByteArrayOutputStream;

public class ZxingPngQrGenerator implements QrGenerator {
public final class ZxingPngQrGenerator implements QrGenerator {

private final Writer writer;
private int imageSize = 350;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Arrays;
import java.util.Random;

public class RecoveryCodeGenerator {
public final class RecoveryCodeGenerator {

private Random random = new SecureRandom();
private Base32 codec = new Base32();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.security.SecureRandom;

@SuppressWarnings("WeakerAccess")
public class DefaultSecretGenerator implements SecretGenerator {
public final class DefaultSecretGenerator implements SecretGenerator {

private final SecureRandom randomBytes = new SecureRandom();
private final static Base32 encoder = new Base32();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;

public class NtpTimeProvider implements TimeProvider {
public final class NtpTimeProvider implements TimeProvider {

private final NTPUDPClient client;
private final InetAddress ntpHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.samstevens.totp.exceptions.TimeProviderException;
import java.time.Instant;

public class SystemTimeProvider implements TimeProvider {
public final class SystemTimeProvider implements TimeProvider {
@Override
public long getTime() throws TimeProviderException {
return Instant.now().getEpochSecond();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/samstevens/totp/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.commons.codec.binary.Base64;

public class Utils {
public final class Utils {
private static Base64 base64Codec = new Base64();

// Class not meant to be instantiated
Expand Down

0 comments on commit b3bd9e7

Please sign in to comment.