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 17 package com.android.volley; 18 19 import android.content.Intent; 20 21 /** Error indicating that there was an authentication failure when performing a Request. */ 22 @SuppressWarnings("serial") 23 public class AuthFailureError extends VolleyError { 24 /** An intent that can be used to resolve this exception. (Brings up the password dialog.) */ 25 private Intent mResolutionIntent; 26 27 public AuthFailureError() {} 28 29 public AuthFailureError(Intent intent) { 30 mResolutionIntent = intent; 31 } 32 33 public AuthFailureError(NetworkResponse response) { 34 super(response); 35 } 36 37 public AuthFailureError(String message) { 38 super(message); 39 } 40 41 public AuthFailureError(String message, Exception reason) { 42 super(message, reason); 43 } 44 45 public Intent getResolutionIntent() { 46 return mResolutionIntent; 47 } 48 49 @Override 50 public String getMessage() { 51 if (mResolutionIntent != null) { 52 return "User needs to (re)enter credentials."; 53 } 54 return super.getMessage(); 55 } 56 } 57