Skip to content

Commit 27dd767

Browse files
committed
Take into account Sonar comments
1 parent 6d3e409 commit 27dd767

49 files changed

Lines changed: 441 additions & 492 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/DigestUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ public static String toMd5(String target) {
189189
}
190190

191191
/**
192-
* Returns the MD5 digest of the target string. Target is decoded to bytes using the named charset.
193-
* The returned hexadecimal String always contains 32 lowercase alphanumeric characters. For
194-
* example, if the target is "HelloWorld", this method returns "68e109f0f40ca72a15e05cc22786f8e6".
192+
* Returns the MD5 digest of the target string. Target is decoded to bytes using the named
193+
* charset. The returned hexadecimal String always contains 32 lowercase alphanumeric
194+
* characters. For example, if the target is "HelloWorld", this method returns
195+
* "68e109f0f40ca72a15e05cc22786f8e6".
195196
*
196197
* @param target The string to encode.
197198
* @param charsetName The character set.
@@ -233,7 +234,8 @@ public static String toSha1(String target) {
233234
}
234235

235236
/**
236-
* Returns the SHA1 digest of the target string. Target is decoded to bytes using the named charset.
237+
* Returns the SHA1 digest of the target string. Target is decoded to bytes using the named
238+
* charset.
237239
*
238240
* @param target The string to encode.
239241
* @param charsetName The character set.

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/DigestVerifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public DigestVerifier(String algorithm, T wrappedVerifier, String wrappedAlgorit
5353

5454
/**
5555
* Computes the digest of a secret according to a specified algorithm. By default, MD5 hashes
56-
* (represented as a sequence of 32 hexadecimal digits) and SHA-1 hashes are supported. For
57-
* an additional algorithm, override this method.
56+
* (represented as a sequence of 32 hexadecimal digits) and SHA-1 hashes are supported. For an
57+
* additional algorithm, override this method.
5858
*
5959
* @param identifier The user identifier.
6060
* @param secret The regular secret to digest.

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/internal/AwsUtils.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,15 @@ public static String getS3StringToSign(Request request, Series<Header> headers)
306306
contentType = "application/x-www-form-urlencoded";
307307
}
308308

309-
return (method != null ? method : "") + "\n" +
310-
(contentMD5 != null ? contentMD5 : "") + "\n" +
311-
(contentType != null ? contentType : "") + "\n" +
312-
(date != null ? date : "") + "\n" +
313-
(canonicalizedAmzHeaders != null ? canonicalizedAmzHeaders : "") +
314-
(canonicalizedResource != null ? canonicalizedResource : "");
309+
return (method != null ? method : "")
310+
+ "\n"
311+
+ (contentMD5 != null ? contentMD5 : "")
312+
+ "\n"
313+
+ (contentType != null ? contentType : "")
314+
+ "\n"
315+
+ (date != null ? date : "")
316+
+ "\n"
317+
+ (canonicalizedAmzHeaders != null ? canonicalizedAmzHeaders : "")
318+
+ (canonicalizedResource != null ? canonicalizedResource : "");
315319
}
316320
}

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/internal/AwsVerifier.java

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* Copyright 2005-2024 Qlik
3-
* <p>
3+
*<p>
44
* The content of this file is subject to the terms of the Apache 2.0 open
55
* source license available at https://www.opensource.org/licenses/apache-2.0
6-
* <p>
6+
*<p>
77
* Restlet is a registered trademark of QlikTech International AB.
88
*/
99
package org.restlet.ext.crypto.internal;
@@ -29,7 +29,7 @@
2929
*
3030
* @author Jean-Philippe Steinmetz <caskater47@gmail.com>
3131
* @see <a href="http://docs.amazonwebservices.com/AmazonS3/latest/RESTAuthentication.html">
32-
* Authenticating REST Requests</a>
32+
* Authenticating REST Requests</a>
3333
*/
3434
public class AwsVerifier extends SecretVerifier {
3535
/** Default maximum request age (15 minutes) */
@@ -44,8 +44,7 @@ public class AwsVerifier extends SecretVerifier {
4444
/**
4545
* Creates a new HttpAwsS3Verifier instance.
4646
*
47-
* @param wrappedVerifier
48-
* The wrapped verifier containing local identifier/secret couples
47+
* @param wrappedVerifier The wrapped verifier containing local identifier/secret couples
4948
*/
5049
public AwsVerifier(LocalVerifier wrappedVerifier) {
5150
this(wrappedVerifier, DEFAULT_MAX_REQUEST_AGE);
@@ -54,11 +53,9 @@ public AwsVerifier(LocalVerifier wrappedVerifier) {
5453
/**
5554
* Creates a new HttpAwsS3Verifier instance.
5655
*
57-
* @param wrappedVerifier
58-
* The wrapped verifier containing local identifier/secret couples
59-
* @param maxRequestAge
60-
* The maximum age of a request, in milliseconds, before it is considered
61-
* stale
56+
* @param wrappedVerifier The wrapped verifier containing local identifier/secret couples
57+
* @param maxRequestAge The maximum age of a request, in milliseconds, before it is considered
58+
* stale
6259
*/
6360
public AwsVerifier(LocalVerifier wrappedVerifier, long maxRequestAge) {
6461
super();
@@ -79,16 +76,13 @@ protected String getIdentifier(Request request, Response response) {
7976

8077
String[] parts = request.getChallengeResponse().getRawValue().split(":");
8178

82-
return (parts.length == 2)
83-
? parts[0]
84-
: null;
79+
return (parts.length == 2) ? parts[0] : null;
8580
}
8681

8782
/**
8883
* Returns the local secret associated with a given identifier.
8984
*
90-
* @param identifier
91-
* The identifier to lookup.
85+
* @param identifier The identifier to lookup.
9286
* @return The secret associated with the identifier or null.
9387
*/
9488
public char[] getLocalSecret(String identifier) {
@@ -119,9 +113,7 @@ protected char[] getSecret(Request request, Response response) {
119113

120114
String[] parts = request.getChallengeResponse().getRawValue().split(":");
121115

122-
return (parts.length == 2)
123-
? parts[1].toCharArray()
124-
: null;
116+
return (parts.length == 2) ? parts[1].toCharArray() : null;
125117
}
126118

127119
/**
@@ -146,8 +138,7 @@ public void setMaxRequestAge(long value) {
146138
/**
147139
* Sets the wrapped local secret verifier.
148140
*
149-
* @param wrappedVerifier
150-
* The local secret verifier.
141+
* @param wrappedVerifier The local secret verifier.
151142
*/
152143
public void setWrappedVerifier(LocalVerifier wrappedVerifier) {
153144
this.wrappedVerifier = wrappedVerifier;

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/internal/CryptoUtils.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
/**
22
* Copyright 2005-2024 Qlik
3-
* <p>
3+
*<p>
44
* The content of this file is subject to the terms of the Apache 2.0 open
55
* source license available at https://www.opensource.org/licenses/apache-2.0
6-
* <p>
6+
*<p>
77
* Restlet is a registered trademark of QlikTech International AB.
88
*/
99
package org.restlet.ext.crypto.internal;
1010

11-
import java.nio.charset.Charset;
1211
import java.nio.charset.StandardCharsets;
1312
import java.security.GeneralSecurityException;
1413
import java.util.Base64;
15-
1614
import javax.crypto.Cipher;
1715
import javax.crypto.spec.SecretKeySpec;
18-
1916
import org.restlet.ext.crypto.DigestUtils;
2017

2118
/**
@@ -118,8 +115,8 @@ public static byte[] encrypt(String algo, String base64Secret, String content)
118115
}
119116

120117
/**
121-
* Generates nonce as recommended in section 3.2.1 of RFC-2617, but without the ETag field.
122-
* The format is: <code><pre>
118+
* Generates nonce as recommended in section 3.2.1 of RFC-2617, but without the ETag field. The
119+
* format is: <code><pre>
123120
* Base64.encodeBytes(currentTimeMS + &quot;:&quot;
124121
* + md5String(currentTimeMS + &quot;:&quot; + secretKey))
125122
* </pre></code>

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/internal/HttpAzureSharedKeyHelper.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import java.util.Base64;
1212
import java.util.Date;
13-
import java.util.Iterator;
1413
import java.util.SortedMap;
1514
import java.util.TreeMap;
1615
import org.restlet.Request;
@@ -158,14 +157,19 @@ public void formatResponse(
158157
final String canonicalizedResource = getCanonicalizedResourceName(request.getResourceRef());
159158

160159
// Set up the message part
161-
final String rest = methodName + '\n' +
162-
contentMd5 + '\n' +
163-
contentType + '\n' +
164-
date + '\n' +
165-
canonicalizedAzureHeaders +
166-
'/' +
167-
challenge.getIdentifier() +
168-
canonicalizedResource;
160+
final String rest =
161+
methodName
162+
+ '\n'
163+
+ contentMd5
164+
+ '\n'
165+
+ contentType
166+
+ '\n'
167+
+ date
168+
+ '\n'
169+
+ canonicalizedAzureHeaders
170+
+ '/'
171+
+ challenge.getIdentifier()
172+
+ canonicalizedResource;
169173

170174
// Append the SharedKey credentials
171175
cw.append(challenge.getIdentifier())

org.restlet.ext.crypto/src/main/java/org/restlet/ext/crypto/internal/HttpAzureSharedKeyLiteHelper.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ public void formatResponse(
8585
String canonicalizedResource = getCanonicalizedResourceName(request.getResourceRef());
8686

8787
// Set up the message part
88-
final String rest = date + '\n' +
89-
'/' +
90-
challenge.getIdentifier() +
91-
canonicalizedResource;
88+
final String rest = date + '\n' + '/' + challenge.getIdentifier() + canonicalizedResource;
9289

9390
// Append the SharedKey credentials
9491
cw.append(challenge.getIdentifier())

org.restlet.ext.freemarker/src/main/java/org/restlet/ext/freemarker/FreemarkerConverter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.restlet.ext.freemarker;
1010

1111
import freemarker.template.Template;
12-
import java.io.IOException;
1312
import java.util.List;
1413
import org.restlet.engine.converter.ConverterHelper;
1514
import org.restlet.engine.resource.VariantInfo;

org.restlet.ext.freemarker/src/main/java/org/restlet/ext/freemarker/TemplateFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import org.restlet.util.Resolver;
2121

2222
/**
23-
* Filter the response's entity and wrap it with a FreeMarker's template representation. By default, the
24-
* template representation provides a data model based on the request and response objects. In order
25-
* for the wrapping to happen, the representations must have the {@link Encoding#FREEMARKER}
23+
* Filter the response's entity and wrap it with a FreeMarker's template representation. By default,
24+
* the template representation provides a data model based on the request and response objects. In
25+
* order for the wrapping to happen, the representations must have the {@link Encoding#FREEMARKER}
2626
* encoding set.<br>
2727
* <br>
2828
* Concurrency note: instances of this class or its subclasses can be invoked by several threads at

org.restlet.ext.jackson/src/main/java/org/restlet/ext/jackson/JacksonRepresentation.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.io.IOException;
2424
import java.io.OutputStream;
2525
import org.restlet.data.MediaType;
26-
import org.restlet.engine.Edition;
2726
import org.restlet.ext.jackson.internal.XmlFactoryProvider;
2827
import org.restlet.representation.OutputRepresentation;
2928
import org.restlet.representation.Representation;
@@ -171,17 +170,6 @@ protected ObjectMapper createObjectMapper() {
171170

172171
} else if (MediaType.APPLICATION_XML.isCompatible(getMediaType())
173172
|| MediaType.TEXT_XML.isCompatible(getMediaType())) {
174-
if (Edition.ANDROID.isCurrentEdition()
175-
&& XmlFactoryProvider.inputFactoryProvider == null) {
176-
XmlFactoryProvider.inputFactoryProvider =
177-
new com.ctc.wstx.osgi.InputFactoryProviderImpl();
178-
}
179-
if (Edition.ANDROID.isCurrentEdition()
180-
&& XmlFactoryProvider.outputFactoryProvider == null) {
181-
XmlFactoryProvider.outputFactoryProvider =
182-
new com.ctc.wstx.osgi.OutputFactoryProviderImpl();
183-
}
184-
185173
javax.xml.stream.XMLInputFactory xif = XmlFactoryProvider.newInputFactory();
186174
xif.setProperty(
187175
javax.xml.stream.XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,

0 commit comments

Comments
 (0)