1 /* 2 * Copyright (C) 2019 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 package android.net.ipsec.ike.exceptions; 17 18 import android.annotation.NonNull; 19 import android.net.ipsec.ike.ChildSessionCallback; 20 import android.net.ipsec.ike.IkeSessionCallback; 21 22 /** 23 * This exception is thrown if the remote server declined a request because of a temporary issue. 24 * 25 * <p>This exception indicates that the remote server receives a request that cannot be completed 26 * due to a temporary condition such as a rekeying operation. 27 * 28 * @see <a href="https://tools.ietf.org/html/rfc7296#section-2.7">RFC 7296, Internet Key Exchange 29 * Protocol Version 2 (IKEv2)</a> 30 * @hide 31 */ 32 public final class TemporaryFailureException extends IkeProtocolException { 33 private static final int EXPECTED_ERROR_DATA_LEN = 0; 34 35 /** 36 * Construct an instance of TemporaryFailureException. 37 * 38 * <p>Except for testing, IKE library users normally do not instantiate this object themselves 39 * but instead get a reference via {@link IkeSessionCallback} or {@link ChildSessionCallback}. 40 * 41 * @param message the descriptive message (which is saved for later retrieval by the {@link 42 * #getMessage()} method). 43 */ TemporaryFailureException(@onNull String message)44 public TemporaryFailureException(@NonNull String message) { 45 super(ERROR_TYPE_TEMPORARY_FAILURE, message); 46 } 47 48 /** 49 * Construct a instance of TemporaryFailureException from a notify payload. 50 * 51 * @param notifyData the notify data included in the payload. 52 * @hide 53 */ TemporaryFailureException(byte[] notifyData)54 public TemporaryFailureException(byte[] notifyData) { 55 super(ERROR_TYPE_TEMPORARY_FAILURE, notifyData); 56 } 57 58 /** @hide */ 59 @Override isValidDataLength(int dataLen)60 protected boolean isValidDataLength(int dataLen) { 61 return EXPECTED_ERROR_DATA_LEN == dataLen; 62 } 63 } 64