/** * @deprecated Use {@link #authenticate(BearerCredentials, String)} * * Returns a bearer Authorization header value for the given * {@link BearerCredentials}. * * @param credentials The credentials to encode. * * @return A bearer authorization string */ public static String authenticate(BearerCredentials credentials) { return authenticate(credentials, "ISO-8859-1"); }
/** * Returns authentication realm. The realm may not be null. * * @return The authentication realm */ @Override public String getRealm() { return getParameter("realm"); }
/** * Returns a String identifying the authentication challenge. This is * used, in combination with the host and port to determine if * authorization has already been attempted or not. Schemes which * require multiple requests to complete the authentication should * return a different value for each stage in the request. * * Additionally, the ID should take into account any changes to the * authentication challenge and return a different value when appropriate. * For example when the realm changes in basic authentication it should be * considered a different authentication attempt and a different value should * be returned. * * This method simply returns the realm for the challenge. * * @return String a String identifying the authentication challenge. * * @deprecated no longer used */ @Override public String getID() { return getRealm(); }
/** * Constructor for the basic authentication scheme. * * @param challenge Authentication challenge * * @throws MalformedChallengeException Thrown if the authentication challenge is malformed * * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} method */ public BearerAuthScheme(final String challenge) throws MalformedChallengeException { processChallenge(challenge); mComplete = true; }
/** * Processes the Bearer challenge. * * @param challenge The challenge string * * @throws MalformedChallengeException Thrown if the authentication challenge is malformed */ public void processChallenge(String challenge) throws MalformedChallengeException { String s = AuthChallengeParser.extractScheme(challenge); if (!s.equalsIgnoreCase(getSchemeName())) { throw new MalformedChallengeException( "Invalid " + getSchemeName() + " challenge: " + challenge); } mParams = AuthChallengeParser.extractParams(challenge); mComplete = true; }
/** * Produces bearer authorization string for the given set of * {@link Credentials}. * * @param credentials The set of credentials to be used for authentication * @param method Method name is ignored by the bearer authentication scheme * @param uri URI is ignored by the bearer authentication scheme * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable * for this authentication scheme * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure * @return A bearer authorization string * * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} */ public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException { Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, String, String)"); BearerCredentials bearer = null; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for bearer authentication: " + credentials.getClass().getName()); } return BearerAuthScheme.authenticate(bearer); }
/** * Produces bearer authorization string for the given set of {@link Credentials}. * * @param credentials The set of credentials to be used for authentication * @param method The method being authenticated * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable for this authentication * scheme. * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure. * * @return a basic authorization string */ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, HttpMethod)"); if (method == null) { throw new IllegalArgumentException("Method may not be null"); } BearerCredentials bearer = null; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for bearer authentication: " + credentials.getClass().getName()); } return BearerAuthScheme.authenticate( bearer, method.getParams().getCredentialCharset()); }