public String isAuthenticated(Client client, Logger logger) {
        
        String ret;
        Response response =
                client.httpGet(
                        client.build(IS_AUTHENTICATED),
                        null,
                        null,
                        ResourceAccessLevel.PUBLIC);
        int responseCode = response.getStatusCode();
        
        // already authenticated
        if (isAlreadyAuthenticated(response, client.getUsername())) {
            ret = null;
            logLoggedInSuccessfully(client.getUsername(), client.getServerUrl(), logger);
        }
        // if not authenticated - get the address where to authenticate via WWW-Authenticate
        else if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
            String newUrl = response.getHeaders().get(AUTHENTICATE_HEADER).get(0).split("=")[1];
            newUrl = newUrl.replace("\"", "");
            newUrl += "/authenticate";
            ret = newUrl;
        }
        // error such as 404, or 500
        else {
            try {
                throw response.getFailure();
            } catch (Throwable cause) {
                throw new SSEException(cause);
            }
        }
        
        return ret;
    }
public String isAuthenticated ( Client client , Logger logger ) { String ret ; Response response = client . httpGet ( client . build ( IS_AUTHENTICATED ) , null , null , ResourceAccessLevel . PUBLIC ) ; int responseCode = response . getStatusCode ( ) ; if ( isAlreadyAuthenticated ( response , client . getUsername ( ) ) ) { ret = null ; logLoggedInSuccessfully ( client . getUsername ( ) , client . getServerUrl ( ) , logger ) ; } else if ( responseCode == HttpURLConnection . HTTP_UNAUTHORIZED ) { String newUrl = response . getHeaders ( ) . get ( AUTHENTICATE_HEADER ) . get ( 0 ) . split ( "=" ) [ 1 ] ; newUrl = newUrl . replace ( "\"" , "" ) ; newUrl += "/authenticate" ; ret = newUrl ; } else { try { throw response . getFailure ( ) ; } catch ( Throwable cause ) { throw new SSEException ( cause ) ; } } return ret ; }
@return null if authenticated.<br>
a URL to authenticate against if not authenticated.
@throws Exception
if error such as 404, or 500