Class BasicAuthentication


  • public class BasicAuthentication
    extends Object

    Utility class for HTTP basic access authentication

    Copyright 2018 (C) by Martin Ganserer

    Version:
    1.0.0
    Author:
    Martin Ganserer
    • Method Detail

      • createAuthentication

        public static String createAuthentication​(String userName,
                                                  String password)
        Create a basic authentication string by using the provided credentials
        Parameters:
        userName -
        password -
        Returns:
        the authentication string
      • getUserName

        public static String getUserName​(String authenticationString)
        Extract the user name from the given authentication string
        Parameters:
        authenticationString -
        Returns:
        the user name
        Throws:
        IllegalArgumentException - if the authentication string is either empty or if it has an illegal format
      • getPassword

        public static String getPassword​(String authenticationString)
        Extract the password from the given authentication string
        Parameters:
        authenticationString -
        Returns:
        the password
        Throws:
        IllegalArgumentException - if the authentication string is either empty or if it has an illegal format