Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions org.restlet.gwt/org.restlet.gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@
<artifactId>gwt-dev</artifactId>
<version>${lib-gwt-version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${lib-junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,13 @@ public final class ChallengeResponse extends ChallengeMessage {
private volatile String secretAlgorithm;

/** The server nonce count. */
private volatile int serverNounceCount;
private volatile int serverNonceCount;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the word nonce was mispelled. I've deprecated the accessors and add new ones.


/**
* The time when the response was issued, as returned by {@link System#currentTimeMillis()}.
*/
private volatile long timeIssued;




/**
* Constructor with no credentials.
*
Expand Down Expand Up @@ -102,7 +99,7 @@ public ChallengeResponse(ChallengeScheme scheme) {
* The client nonce value.
* @param serverNonce
* The server nonce.
* @param serverNounceCount
* @param serverNonceCount
* The server nonce count.
* @param timeIssued
* The time when the response was issued, as returned by {@link System#currentTimeMillis()}.
Expand All @@ -111,7 +108,7 @@ public ChallengeResponse(ChallengeScheme scheme,
Series<Parameter> parameters, String identifier, char[] secret,
String secretAlgorithm, String realm, String quality,
Reference digestRef, String digestAlgorithm, String opaque,
String clientNonce, String serverNonce, int serverNounceCount,
String clientNonce, String serverNonce, int serverNonceCount,
long timeIssued) {
super(scheme, realm, parameters, digestAlgorithm, opaque, serverNonce);
this.clientNonce = clientNonce;
Expand All @@ -120,7 +117,7 @@ public ChallengeResponse(ChallengeScheme scheme,
this.quality = quality;
this.secret = secret;
this.secretAlgorithm = secretAlgorithm;
this.serverNounceCount = serverNounceCount;
this.serverNonceCount = serverNonceCount;
this.timeIssued = timeIssued;
}

Expand Down Expand Up @@ -284,13 +281,23 @@ public String getSecretAlgorithm() {

/**
* Returns the server nonce count.
*
*
* @return The server nonce count.
* @deprecated Use {@code getServerNonceCount} instead.
*/
@Deprecated
public int getServerNounceCount() {
return serverNounceCount;
return getServerNonceCount();
}

/**
* Returns the server nonce count.
*
* @return The server nonce count.
*/
public int getServerNonceCount() {
return serverNonceCount;
}

/**
* Returns the time when the response was issued, as returned by {@link System#currentTimeMillis()}.
Expand Down Expand Up @@ -383,14 +390,23 @@ public void setSecretAlgorithm(String secretDigestAlgorithm) {

/**
* Sets the server nonce count.
*
* @param serverNounceCount
* The server nonce count.
*
* @param serverNonceCount The server nonce count.
* @deprecated Use {@code setServerNonceCount} instead.
*/
public void setServerNounceCount(int serverNounceCount) {
this.serverNounceCount = serverNounceCount;
@Deprecated
public void setServerNounceCount(int serverNonceCount) {
setServerNonceCount(serverNonceCount);
}

/**
* Sets the server nonce count.
*
* @param serverNonceCount The server nonce count.
*/
public void setServerNonceCount(int serverNonceCount) {
this.serverNonceCount = serverNonceCount;
}
/**
* Sets the time when the response was issued, as returned by {@link System#currentTimeMillis()}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ public final class Status {

private static final String BASE_HTTP = "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html";

private static final String BASE_RESTLET = "http://restlet.org/learn/javadocs/"
+ Engine.MAJOR_NUMBER
+ '.'
+ Engine.MINOR_NUMBER
+ "/gwt/api/";
private static final String BASE_RESTLET = "https://javadoc.io/static/org.restlet.gwt/org.restlet.gwt/" + Engine.VERSION + "/";

@Deprecated
private static final String BASE_WEBDAV = "http://www.webdav.org/specs/rfc2518.html";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to add the tests for the GWT edition

* Copyright 2005-2024 Qlik
*
* The contents of this file is subject to the terms of the Apache 2.0 open
* source license available at http://www.opensource.org/licenses/apache-2.0
*
* Restlet is a registered trademark of QlikTech International AB.
*/

package org.restlet.client.engine;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class EngineTest {

@Test
public void engineVersionShouldBeEqualToMavenProjectVersion() {
// When I retrieve the Maven project's version as stated in the pom file.
Properties properties = new Properties();
try (InputStream resourceAsStream = EngineTest.class.getClassLoader().getResourceAsStream("maven-version.properties")) {
properties.load(resourceAsStream);
} catch (IOException e) {
Assertions.fail("Can't load the properties file that contain the Maven's project version");
}

// Then the Maven project's version should be equal to the Engine's version.
assertEquals(Engine.VERSION, properties.getProperty("maven.version"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven.version=${project.version}
5 changes: 0 additions & 5 deletions org.restlet.java/org.restlet.example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
<description>Example projects including those from the tutorial</description>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${lib-testng-version}</version>
</dependency>
<dependency>
<groupId>org.restlet</groupId>
<artifactId>org.restlet</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions org.restlet.java/org.restlet.ext.crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<artifactId>org.restlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${lib-junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* Copyright 2005-2024 Qlik
*
* <p>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we'll have to take care of code formatting...

* The contents of this file is subject to the terms of the Apache 2.0 open
* source license available at http://www.opensource.org/licenses/apache-2.0
*
* <p>
* Restlet is a registered trademark of QlikTech International AB.
*/

package org.restlet.ext.crypto;

import java.util.logging.Level;

import org.restlet.Context;
import org.restlet.data.Digest;
import org.restlet.security.LocalVerifier;
import org.restlet.security.SecretVerifier;

import java.util.logging.Level;

/**
* Wrapper verifier that can verify digested secrets. If the provided secret is
* a digest, then the local secret must either be a digest of the same algorithm
Expand All @@ -24,7 +24,7 @@
* <br>
* If the provided secret is a regular secret, then the local secret can be in
* any digest algorithm or a regular secret.
*
*
* @see Digest
* @see DigestAuthenticator
* @author Jerome Louvel
Expand All @@ -42,7 +42,7 @@ public class DigestVerifier<T extends SecretVerifier> extends SecretVerifier {

/**
* Constructor.
*
*
* @param algorithm
* The digest algorithm of provided secrets.
* @param wrappedVerifier
Expand All @@ -53,7 +53,7 @@ public class DigestVerifier<T extends SecretVerifier> extends SecretVerifier {
* @see Digest
*/
public DigestVerifier(String algorithm, T wrappedVerifier,
String wrappedAlgorithm) {
String wrappedAlgorithm) {
this.algorithm = algorithm;
this.wrappedAlgorithm = wrappedAlgorithm;
this.wrappedVerifier = wrappedVerifier;
Expand All @@ -64,7 +64,7 @@ public DigestVerifier(String algorithm, T wrappedVerifier,
* default, MD5 hashes (represented as a sequence of 32 hexadecimal digits)
* and SHA-1 hashes are supported. For additional algorithm, override this
* method.
*
*
* @param identifier
* The user identifier.
* @param secret
Expand All @@ -81,37 +81,62 @@ protected char[] digest(String identifier, char[] secret, String algorithm) {
/**
* Returns the digest algorithm of provided secrets. Provided secrets are
* the ones sent by clients when attempting to authenticate.
*
*
* @return The digest algorithm of input secrets.
*/
public String getAlgorithm() {
return algorithm;
}

/**
* Sets the digest algorithm of provided secrets. Provided secrets are the
* ones sent by clients when attempting to authenticate.
*
* @param algorithm
* The digest algorithm of secrets provided by the user.
* @see Digest
*/
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}

/**
* Returns the digest algorithm of secrets returned by the wrapped verifier.
* The secrets from the wrapped verifier are the ones used by the verifier
* to compare those sent by clients when attempting to authenticate.
*
*
* @return The digest algorithm of secrets returned by the wrapped verifier.
*/
public String getWrappedAlgorithm() {
return wrappedAlgorithm;
}

/**
* Sets the digest algorithm of secrets returned by the wrapped verifier.
* The secrets from the wrapped verifier are the ones used by the verifier
* to compare those sent by clients when attempting to authenticate.
*
* @param wrappedAlgorithm
* The digest algorithm of secrets returned by the wrapped
* verifier.
* @see Digest
*/
public void setWrappedAlgorithm(String wrappedAlgorithm) {
this.wrappedAlgorithm = wrappedAlgorithm;
}

/**
* Returns the wrapped secret associated to a given identifier. This method
* can only be called if the wrapped verifier is a {@link LocalVerifier}.
*
*
* @param identifier
* The identifier to lookup.
* @return The secret associated to the identifier or null.
*/
public char[] getWrappedSecret(String identifier) {
char[] result = null;

if (getWrappedVerifier() instanceof LocalVerifier) {
LocalVerifier localVerifier = (LocalVerifier) getWrappedVerifier();
if (getWrappedVerifier() instanceof LocalVerifier localVerifier) {
result = localVerifier.getLocalSecret(identifier);
} else {
Context.getCurrentLogger()
Expand All @@ -127,7 +152,7 @@ public char[] getWrappedSecret(String identifier) {
* identifier. If the wrapped algorithm is null it returns the digest of the
* wrapped secret, otherwise the algorithms must be identical. This method
* can only be called if the wrapped verifier is a {@link LocalVerifier}.
*
*
* @param identifier
* The identifier to lookup.
* @return The secret associated to the identifier or null.
Expand All @@ -150,42 +175,16 @@ public char[] getWrappedSecretDigest(String identifier) {

/**
* Returns the wrapped secret verifier.
*
*
* @return The wrapped secret verifier.
*/
public T getWrappedVerifier() {
return wrappedVerifier;
}

/**
* Sets the digest algorithm of provided secrets. Provided secrets are the
* ones sent by clients when attempting to authenticate.
*
* @param algorithm
* The digest algorithm of secrets provided by the user.
* @see Digest
*/
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}

/**
* Sets the digest algorithm of secrets returned by the wrapped verifier.
* The secrets from the wrapped verifier are the ones used by the verifier
* to compare those sent by clients when attempting to authenticate.
*
* @param wrappedAlgorithm
* The digest algorithm of secrets returned by the wrapped
* verifier.
* @see Digest
*/
public void setWrappedAlgorithm(String wrappedAlgorithm) {
this.wrappedAlgorithm = wrappedAlgorithm;
}

/**
* Sets the wrapped secret verifier.
*
*
* @param wrappedVerifier
* The wrapped secret verifier.
*/
Expand All @@ -208,8 +207,8 @@ public int verify(String identifier, char[] secret) {
result = getWrappedVerifier().verify(identifier, secretDigest);
} else {
if (getWrappedAlgorithm() == null) {
result = compare(secretDigest,
getWrappedSecretDigest(identifier)) ? RESULT_VALID
result = compare(secretDigest, getWrappedSecretDigest(identifier))
? RESULT_VALID
: RESULT_INVALID;
} else if (getAlgorithm().equals(getWrappedAlgorithm())) {
result = getWrappedVerifier().verify(identifier, secretDigest);
Expand Down
Loading