Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void loadJSONResources(InputStream inputStream)

JsonNode patternsNode = current.get("patterns");
if (patternsNode == null)
throw new RuntimeException(
"Missing patterns for scope" + scopeval);
throw new RuntimeException("Missing patterns for scope"
+ scopeval);

List<Rule> rlist = new LinkedList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.http.util.Args;
import org.apache.http.util.ByteArrayBuffer;
import org.apache.storm.Config;
import org.apache.storm.shade.org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we relied on non-shaded dependencies - snakeyaml is in our pom already - or even better on the standard Java classes e.g. https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Encoder.html

import org.slf4j.LoggerFactory;

import com.digitalpebble.stormcrawler.Metadata;
Expand Down Expand Up @@ -112,6 +113,30 @@ public void configure(final Config conf) {
defaultHeaders.add(new BasicHeader("Accept", accept));
}

boolean useBasicAuth = ConfUtils.getBoolean(conf,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having a separate configuration for activating or deactivating the authentication, what about checking if http.basicauth.user is not null? If it is set, we use it. That would keep things simpler.

"http.basicauth.enabled", false);

// use a basic auth?
if (useBasicAuth) {

String basicAuthUser = ConfUtils.getString(conf,
"http.basicauth.user", null);
String basicAuthPass = ConfUtils.getString(conf,
"http.basicauth.password", null);

if (StringUtils.isNotBlank(basicAuthUser)
&& StringUtils.isNotBlank(basicAuthPass)) {
char[] encoding = Base64Coder.encode(new String(basicAuthUser
+ ":" + basicAuthPass).getBytes());
defaultHeaders.add(new BasicHeader("Authorization", "Basic "
+ String.valueOf(encoding)));
} else {
LOG.warn("Basic Auth has been disabled, credentials are empty. Please set "
+ "'http.basicauth.user' and 'http.basicauth.pass'.");
}

}

String acceptLanguage = ConfUtils.getString(conf,
"http.accept.language");
if (StringUtils.isNotBlank(acceptLanguage)) {
Expand Down