Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dependencies (esp. google.zxing) #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.samstevens.totp</groupId>
<groupId>com.github.moddx.totp</groupId>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not change this? Seems that @samdjstevens isn't looking at this library anymore though, we'd like an update of dependencies too.

<artifactId>totp-parent</artifactId>
<packaging>pom</packaging>
<version>1.7.1</version>
<version>1.7.2</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
Expand All @@ -22,12 +22,16 @@
<email>[email protected]</email>
<organizationUrl>https://github.com/samdjstevens</organizationUrl>
</developer>
<developer>
<name>moddx</name>
<organizationUrl>https://github.com/moddx</organizationUrl>
</developer>
</developers>

<scm>
<developerConnection>scm:git:[email protected]:samdjstevens/java-totp.git</developerConnection>
<tag>totp-1.7.1</tag>
<url>https://github.com/samdjstevens/java-totp</url>
<developerConnection>scm:git:[email protected]:moddx/java-totp.git</developerConnection>
<tag>totp-1.7.2</tag>
<url>https://github.com/moddx/java-totp</url>
</scm>

<licenses>
Expand Down Expand Up @@ -157,7 +161,7 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<phase>deploy</phase>
<goals>
<goal>sign</goal>
</goals>
Expand Down
10 changes: 5 additions & 5 deletions totp-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.samstevens.totp</groupId>
<artifactId>totp-parent</artifactId>
<version>1.7.1</version>
<version>1.7.2</version>
</parent>

<name>${project.groupId}:${project.artifactId}</name>
Expand All @@ -18,17 +18,17 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>totp</artifactId>
<version>1.7.1</version>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.2.5.RELEASE</version>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.2.5.RELEASE</version>
<version>2.7.8</version>
<optional>true</optional>
</dependency>
</dependencies>
Expand All @@ -43,7 +43,7 @@
<annotationProcessorPath>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.2.5.RELEASE</version>
<version>2.7.8</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
Expand Down
18 changes: 9 additions & 9 deletions totp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>dev.samstevens.totp</groupId>
<artifactId>totp-parent</artifactId>
<version>1.7.1</version>
<version>1.7.2</version>
</parent>

<artifactId>totp</artifactId>
Expand All @@ -17,47 +17,47 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.0</version>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.2.4</version>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
<version>1.15</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
<version>3.9.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.0</version>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.4.0</version>
<version>3.5.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dev.samstevens.totp.code;

import dev.samstevens.totp.exceptions.CodeGenerationException;
import org.apache.commons.codec.CodecPolicy;
import org.apache.commons.codec.binary.Base32;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
Expand Down Expand Up @@ -54,7 +56,7 @@ private byte[] generateHash(String key, long counter) throws InvalidKeyException
}

// Create a HMAC-SHA1 signing key from the shared key
Base32 codec = new Base32();
Base32 codec = new Base32(0, null, false, (byte) '=', CodecPolicy.STRICT);
byte[] decodedKey = codec.decode(key);
SecretKeySpec signKey = new SecretKeySpec(decodedKey, algorithm.getHmacAlgorithm());
Mac mac = Mac.getInstance(algorithm.getHmacAlgorithm());
Expand Down
16 changes: 0 additions & 16 deletions totp/src/test/java/dev/samstevens/totp/IOUtils.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import com.google.zxing.WriterException;
import dev.samstevens.totp.exceptions.QrGenerationException;
import org.junit.jupiter.api.Test;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import static dev.samstevens.totp.IOUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -28,7 +32,7 @@ public void testSomething() throws QrGenerationException, IOException {
.period(30)
.build();

writeFile(generator.generate(data), "./test_qr.png");
Files.write(Paths.get("./test_qr.png"), generator.generate(data));
}

@Test
Expand All @@ -43,17 +47,18 @@ public void testImageSize() throws QrGenerationException, IOException {
byte[] data = generator.generate(getData());

// Write the data to a temp file and read it into a BufferedImage to get the dimensions
String filename = "/tmp/test_qr.png";
writeFile(data, filename);
File file = new File(filename);
BufferedImage image = ImageIO.read(file);

assertEquals(500, generator.getImageSize());
assertEquals(500, image.getWidth());
assertEquals(500, image.getHeight());
final Path filepath = Files.createTempFile("test_qr", ".png");
try {
Files.write(filepath, data);
BufferedImage image = ImageIO.read(filepath.toFile());

// Delete the temp file
file.delete();
assertEquals(500, generator.getImageSize());
assertEquals(500, image.getWidth());
assertEquals(500, image.getHeight());
} finally {
filepath.toFile().delete();
}
}

@Test
Expand Down