Skip to content

Commit

Permalink
Fixed the typo on the withTimestampingAuthority() methods in PESigner (
Browse files Browse the repository at this point in the history
…Fixes #43)
  • Loading branch information
aeons authored and ebourg committed Nov 3, 2017
1 parent 3aa737c commit f825653
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Changes

Version 2.1 (in development)
* The first timestamping authority specified is no longer skipped (contributed by Thomas Atzmueller)
* Fixed the typo on the withTimestampingAuthority() methods in PESigner (contributed by Bjørn Madsen)
* Upgraded BouncyCastle to 1.57

Version 2.0 (2017-06-12)
Expand Down
31 changes: 27 additions & 4 deletions jsign-core/src/main/java/net/jsign/PESigner.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,45 @@ public PESigner withTimestampingMode(TimestampingMode tsmode) {
/**
* Set the URL of the timestamping authority. RFC 3161 servers as used
* for jar signing are not compatible with Authenticode signatures.
*
* @since 2.1
*/
public PESigner withTimestampingAuthority(String url) {
return withTimestampingAuthority(new String[] { url });
}

/**
* Set the URL of the timestamping authority. RFC 3161 servers as used
* for jar signing are not compatible with Authenticode signatures.
*
* @deprecated
*/
public PESigner withTimestampingAutority(String url) {
return withTimestampingAutority(new String[] { url });
return withTimestampingAuthority(url);
}

/**
* Set the URL of the timestamping authority. RFC 3161 servers as used
* for jar signing are not compatible with Authenticode signatures.
*
* @since 2.0
* @since 2.1
*/
public PESigner withTimestampingAutority(String... url) {
public PESigner withTimestampingAuthority(String... url) {
this.tsaurlOverride = url;
return this;
}


/**
* Set the URL of the timestamping authority. RFC 3161 servers as used
* for jar signing are not compatible with Authenticode signatures.
*
* @since 2.0
* @deprecated
*/
public PESigner withTimestampingAutority(String... url) {
return withTimestampingAuthority(url);
}

/**
* Set the Timestamper implementation.
*/
Expand Down
2 changes: 1 addition & 1 deletion jsign-core/src/main/java/net/jsign/PESignerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public PESigner build() throws SignerException {
.withTimestampingMode(tsmode != null ? TimestampingMode.of(tsmode) : TimestampingMode.AUTHENTICODE)
.withTimestampingRetries(tsretries)
.withTimestampingRetryWait(tsretrywait)
.withTimestampingAutority(tsaurl != null ? tsaurl.split(",") : null);
.withTimestampingAuthority(tsaurl != null ? tsaurl.split(",") : null);
}

public void sign(File file) throws SignerException {
Expand Down
28 changes: 14 additions & 14 deletions jsign-core/src/test/java/net/jsign/PESignerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@ public void testReplaceSignature() throws Exception {
assertEquals("Digest algorithm", DigestAlgorithm.SHA256.oid, signatures.get(0).getDigestAlgorithmIDs().iterator().next().getAlgorithm());
}

public void testInvalidAuthenticodeTimestampingAutority() throws Exception {
testInvalidTimestampingAutority(TimestampingMode.AUTHENTICODE);
public void testInvalidAuthenticodeTimestampingAuthority() throws Exception {
testInvalidTimestampingAuthority(TimestampingMode.AUTHENTICODE);
}

public void testInvalidRFC3161TimestampingAutority() throws Exception {
testInvalidTimestampingAutority(TimestampingMode.RFC3161);
public void testInvalidRFC3161TimestampingAuthority() throws Exception {
testInvalidTimestampingAuthority(TimestampingMode.RFC3161);
}

public void testInvalidTimestampingAutority(TimestampingMode mode) throws Exception {
public void testInvalidTimestampingAuthority(TimestampingMode mode) throws Exception {
File sourceFile = new File("target/test-classes/wineyes.exe");
File targetFile = new File("target/test-classes/wineyes-timestamped-unavailable-" + mode.name().toLowerCase() + ".exe");

Expand All @@ -405,7 +405,7 @@ public void testInvalidTimestampingAutority(TimestampingMode mode) throws Except
signer.withDigestAlgorithm(DigestAlgorithm.SHA1);
signer.withTimestamping(true);
signer.withTimestampingMode(mode);
signer.withTimestampingAutority("http://www.google.com/" + mode.name().toLowerCase());
signer.withTimestampingAuthority("http://www.google.com/" + mode.name().toLowerCase());
signer.withTimestampingRetries(1);

try {
Expand All @@ -422,15 +422,15 @@ public void testInvalidTimestampingAutority(TimestampingMode mode) throws Except
assertTrue(signatures.isEmpty());
}

public void testBrokenAuthenticodeTimestampingAutority() throws Exception {
testBrokenTimestampingAutority(TimestampingMode.AUTHENTICODE);
public void testBrokenAuthenticodeTimestampingAuthority() throws Exception {
testBrokenTimestampingAuthority(TimestampingMode.AUTHENTICODE);
}

public void testBrokenRFC3161TimestampingAutority() throws Exception {
testBrokenTimestampingAutority(TimestampingMode.RFC3161);
public void testBrokenRFC3161TimestampingAuthority() throws Exception {
testBrokenTimestampingAuthority(TimestampingMode.RFC3161);
}

public void testBrokenTimestampingAutority(TimestampingMode mode) throws Exception {
public void testBrokenTimestampingAuthority(TimestampingMode mode) throws Exception {
File sourceFile = new File("target/test-classes/wineyes.exe");
File targetFile = new File("target/test-classes/wineyes-timestamped-broken-" + mode.name().toLowerCase() + ".exe");

Expand All @@ -442,7 +442,7 @@ public void testBrokenTimestampingAutority(TimestampingMode mode) throws Excepti
signer.withDigestAlgorithm(DigestAlgorithm.SHA1);
signer.withTimestamping(true);
signer.withTimestampingMode(mode);
signer.withTimestampingAutority("http://github.com");
signer.withTimestampingAuthority("http://github.com");
signer.withTimestampingRetries(1);

try {
Expand All @@ -465,7 +465,7 @@ public void testInvalidTimestampingURL() throws Exception {
signer.withDigestAlgorithm(DigestAlgorithm.SHA1);
signer.withTimestamping(true);
signer.withTimestampingMode(TimestampingMode.RFC3161);
signer.withTimestampingAutority("example://example.com");
signer.withTimestampingAuthority("example://example.com");
signer.withTimestampingRetries(1);

try {
Expand Down Expand Up @@ -497,7 +497,7 @@ public void testTimestampingFailover(TimestampingMode mode, String validURL) thr
signer.withTimestamping(true);
signer.withTimestampingMode(mode);
signer.withTimestampingRetryWait(1);
signer.withTimestampingAutority("http://www.google.com/" + mode.name().toLowerCase(), "http://github.com", validURL);
signer.withTimestampingAuthority("http://www.google.com/" + mode.name().toLowerCase(), "http://github.com", validURL);

signer.sign(peFile);

Expand Down

0 comments on commit f825653

Please sign in to comment.