1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.volley;
18
19import android.content.Intent;
20
21import com.android.volley.NetworkResponse;
22import com.android.volley.VolleyError;
23
24/**
25 * Error indicating that there was an authentication failure when performing a Request.
26 */
27@SuppressWarnings("serial")
28public class AuthFailureError extends VolleyError {
29    /** An intent that can be used to resolve this exception. (Brings up the password dialog.) */
30    private Intent mResolutionIntent;
31
32    public AuthFailureError() { }
33
34    public AuthFailureError(Intent intent) {
35        mResolutionIntent = intent;
36    }
37
38    public AuthFailureError(NetworkResponse response) {
39        super(response);
40    }
41
42    public AuthFailureError(String message) {
43        super(message);
44    }
45
46    public AuthFailureError(String message, Exception reason) {
47        super(message, reason);
48    }
49
50    public Intent getResolutionIntent() {
51        return mResolutionIntent;
52    }
53
54    @Override
55    public String getMessage() {
56        if (mResolutionIntent != null) {
57            return "User needs to (re)enter credentials.";
58        }
59        return super.getMessage();
60    }
61}
62