diff options
Diffstat (limited to 'ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java')
-rw-r--r-- | ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java b/ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java new file mode 100644 index 00000000..f25f0db6 --- /dev/null +++ b/ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java @@ -0,0 +1,19 @@ +package org.openecomp.portalapp.widget.utils; + +import java.nio.charset.Charset; +import java.util.Base64; + +public class AuthorizationUtil { + + public boolean authorization(String auth, String security_user, String security_pass){ + if (auth != null && auth.startsWith("Basic")) { + String base64Credentials = auth.substring("Basic".length()).trim(); + String credentials = new String(Base64.getDecoder().decode(base64Credentials), + Charset.forName("UTF-8")); + final String[] values = credentials.split(":",2); + if(security_user.equals(values[0]) && security_pass.equals(values[1])) + return true; + } + return false; + } +} |