Permalink
Browse files

added findbugs + maven task to check at compile time

  • Loading branch information...
1 parent 69eee25 commit e0a13c80504cf052260b4ac6f64f9fbe53846edf @fernandezpablo85 fernandezpablo85 committed Feb 13, 2013
View
23 pom.xml
@@ -49,19 +49,20 @@
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
-
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
-
+
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
@@ -70,6 +71,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
+ <version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -80,6 +82,23 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>2.5.2</version>
+ <executions>
+ <execution>
+ <id>failing-on-high</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <threshold>Low</threshold>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
View
2 src/main/java/org/scribe/builder/api/PlurkApi.java
@@ -26,7 +26,7 @@ public String getAccessTokenEndpoint()
return ACCESS_TOKEN_URL;
}
- public class Mobile extends PlurkApi
+ public static class Mobile extends PlurkApi
{
private static final String AUTHORIZATION_URL = "http://www.plurk.com/m/authorize?oauth_token=%s";
View
4 src/main/java/org/scribe/extractors/HeaderExtractorImpl.java
@@ -26,13 +26,13 @@ public String extract(OAuthRequest request)
Map<String, String> parameters = request.getOauthParameters();
StringBuffer header = new StringBuffer(parameters.size() * 20);
header.append(PREAMBLE);
- for (String key : parameters.keySet())
+ for (Map.Entry<String, String> entry : parameters.entrySet())
{
if(header.length() > PREAMBLE.length())
{
header.append(PARAM_SEPARATOR);
}
- header.append(String.format("%s=\"%s\"", key, OAuthEncoder.encode(parameters.get(key))));
+ header.append(String.format("%s=\"%s\"", entry.getKey(), OAuthEncoder.encode(entry.getValue())));
}
return header.toString();
}
View
4 src/main/java/org/scribe/model/Request.java
@@ -4,7 +4,7 @@
import java.net.*;
import java.nio.charset.*;
import java.util.*;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
import org.scribe.exceptions.*;
@@ -189,7 +189,7 @@ public void addPayload(String payload)
*/
public void addPayload(byte[] payload)
{
- this.bytePayload = payload;
+ this.bytePayload = payload.clone();
}
/**
View
2 src/main/java/org/scribe/services/HMACSha1SignatureService.java
@@ -44,7 +44,7 @@ private String doSign(String toSign, String keyString) throws Exception
Mac mac = Mac.getInstance(HMAC_SHA1);
mac.init(key);
byte[] bytes = mac.doFinal(toSign.getBytes(UTF8));
- return new String(Base64.encodeBase64(bytes)).replace(CARRIAGE_RETURN, EMPTY_STRING);
+ return new String(Base64.encodeBase64(bytes), UTF8).replace(CARRIAGE_RETURN, EMPTY_STRING);
}
/**
View
5 src/main/java/org/scribe/services/RSASha1SignatureService.java
@@ -11,6 +11,7 @@
{
private static final String METHOD = "RSA-SHA1";
private static final String RSA_SHA1 = "SHA1withRSA";
+ private static final String UTF8 = "UTF-8";
private PrivateKey privateKey;
@@ -28,8 +29,8 @@ public String getSignature(String baseString, String apiSecret, String tokenSecr
{
Signature signature = Signature.getInstance(RSA_SHA1);
signature.initSign(privateKey);
- signature.update(baseString.getBytes());
- return new String(Base64.encodeBase64(signature.sign(), false));
+ signature.update(baseString.getBytes(UTF8));
+ return new String(Base64.encodeBase64(signature.sign(), false), UTF8);
}
catch (Exception e)
{
View
3 src/main/java/org/scribe/services/TimestampServiceImpl.java
@@ -53,14 +53,15 @@ void setTimer(Timer timer)
*/
static class Timer
{
+ private final Random rand = new Random();
Long getMilis()
{
return System.currentTimeMillis();
}
Integer getRandomInteger()
{
- return new Random().nextInt();
+ return rand.nextInt();
}
}

0 comments on commit e0a13c8

Please sign in to comment.