From e4e227b18dcd4a4dd40bc3e3a8373f3d96c6511d Mon Sep 17 00:00:00 2001 From: "Tschaen, Brendan" Date: Thu, 7 Mar 2019 16:02:44 -0500 Subject: Update voting app with basic auth Change-Id: Ia9ec983950faa651d31b07fe19934cf4fe389421 Issue-ID: MUSIC-360 Signed-off-by: Tschaen, Brendan --- examples/VotingApp/src/main/java/main/VotingApp.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'examples/VotingApp/src') diff --git a/examples/VotingApp/src/main/java/main/VotingApp.java b/examples/VotingApp/src/main/java/main/VotingApp.java index 8846ba22..653cef2e 100644 --- a/examples/VotingApp/src/main/java/main/VotingApp.java +++ b/examples/VotingApp/src/main/java/main/VotingApp.java @@ -29,6 +29,7 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import java.util.Base64; import javax.ws.rs.core.MediaType; @@ -66,13 +67,11 @@ public class VotingApp { if (!namespace.equals("")) { builder.header("ns", namespace); } - if (!userId.equals("")) { - builder.header("userId", userId); + if (!userId.equals("") && !password.equals("")) { + String authString = Base64.getEncoder().encodeToString((userId + ":" + password).getBytes()); + builder.header("Authorization", "Basic " + authString); } - if (!password.equals("")) { - builder.header("password", password); - } - + return builder; } @@ -511,4 +510,4 @@ public class VotingApp { } -} \ No newline at end of file +} -- cgit 1.2.3-korg