Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
benjamin.ertl
aai-identity-harmonization
Commits
cf5aa5f8
Commit
cf5aa5f8
authored
Jan 11, 2016
by
benjamin.ertl
Browse files
fix
parent
d0abe699
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/edu/kit/scc/Utils.java
View file @
cf5aa5f8
...
...
@@ -5,6 +5,7 @@ import java.io.InputStream;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
org.apache.commons.codec.binary.Base64
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -15,6 +16,10 @@ public final class Utils {
private
Utils
()
{
}
public
static
String
encodeBase64
(
String
string
)
{
return
new
String
(
Base64
.
encodeBase64
(
string
.
getBytes
()));
}
public
static
Properties
loadProperties
()
{
InputStream
in
=
null
;
Properties
properties
=
new
Properties
();
...
...
src/main/java/edu/kit/scc/http/HttpClient.java
View file @
cf5aa5f8
...
...
@@ -10,7 +10,6 @@ import java.security.NoSuchAlgorithmException;
import
java.security.SecureRandom
;
import
java.security.cert.X509Certificate
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.List
;
import
javax.net.ssl.SSLContext
;
...
...
@@ -41,6 +40,8 @@ import org.slf4j.LoggerFactory;
import
com.google.common.io.ByteStreams
;
import
edu.kit.scc.Utils
;
/**
* HTTP client implementation.
*
...
...
@@ -86,7 +87,7 @@ public class HttpClient {
urlConnection
.
setRequestProperty
(
"Accept"
,
"*/*"
);
if
(
user
!=
null
&&
!
user
.
isEmpty
())
{
String
value
=
Base64
.
getEncoder
().
encodeToString
(
(
user
+
":"
+
password
)
.
getBytes
())
;
String
value
=
Utils
.
encodeBase64
(
user
+
":"
+
password
);
log
.
debug
(
"Authorization: Basic {}"
,
value
);
urlConnection
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
value
);
}
...
...
@@ -154,7 +155,7 @@ public class HttpClient {
urlConnection
.
setDoOutput
(
true
);
if
(
user
!=
null
&&
!
user
.
isEmpty
())
{
String
value
=
Base64
.
getEncoder
().
encodeToString
(
(
user
+
":"
+
password
)
.
getBytes
())
;
String
value
=
Utils
.
encodeBase64
(
user
+
":"
+
password
);
log
.
debug
(
"Authorization: Basic {}"
,
value
);
urlConnection
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
value
);
}
...
...
src/main/java/edu/kit/scc/http/HttpsClient.java
View file @
cf5aa5f8
...
...
@@ -3,7 +3,6 @@ package edu.kit.scc.http;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.Base64
;
import
javax.net.ssl.HttpsURLConnection
;
...
...
@@ -12,6 +11,8 @@ import org.slf4j.LoggerFactory;
import
com.google.common.io.ByteStreams
;
import
edu.kit.scc.Utils
;
/**
* HTTPS client implementation.
*
...
...
@@ -57,7 +58,7 @@ public class HttpsClient {
urlConnection
.
setRequestProperty
(
"Accept"
,
"*/*"
);
if
(
user
!=
null
&&
!
user
.
isEmpty
())
{
String
value
=
Base64
.
getEncoder
().
encodeToString
(
(
user
+
":"
+
password
)
.
getBytes
())
;
String
value
=
Utils
.
encodeBase64
(
user
+
":"
+
password
);
log
.
debug
(
"Authorization: Basic {}"
,
value
);
urlConnection
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
value
);
}
...
...
@@ -126,7 +127,7 @@ public class HttpsClient {
urlConnection
.
setDoOutput
(
true
);
if
(
user
!=
null
&&
!
user
.
isEmpty
())
{
String
value
=
Base64
.
getEncoder
().
encodeToString
(
(
user
+
":"
+
password
)
.
getBytes
())
;
String
value
=
Utils
.
encodeBase64
(
user
+
":"
+
password
);
log
.
debug
(
"Authorization: Basic {}"
,
value
);
urlConnection
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
value
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment