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.net.ipsec.ike.ChildSessionCallback; 19 import android.net.ipsec.ike.IkeSessionCallback; 20 21 /** 22 * This exception is thrown if Traffic Selectors negotiation failed. 23 * 24 * <p>This exception indicates either proposed Traffic Selectors by callers is not acceptable or the 25 * negotiated Traffic Selectors from the remote server is invalid. 26 * 27 * @hide 28 */ 29 // If remote server is the exchange initiator, IKE library should respond with a TS_UNACCEPTABLE 30 // Notify message. If the remote server is the exchange responder, IKE library should initiate a 31 // Delete IKE exchange and close the IKE Session. 32 public final class TsUnacceptableException extends IkeProtocolException { 33 private static final int EXPECTED_ERROR_DATA_LEN = 0; 34 35 /** 36 * Construct an instance of TsUnacceptableException. 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 */ TsUnacceptableException()41 public TsUnacceptableException() { 42 super(ERROR_TYPE_TS_UNACCEPTABLE); 43 } 44 45 /** 46 * Construct a instance of TsUnacceptableException from a notify payload. 47 * 48 * @param notifyData the notify data included in the payload. 49 * @hide 50 */ TsUnacceptableException(byte[] notifyData)51 public TsUnacceptableException(byte[] notifyData) { 52 super(ERROR_TYPE_TS_UNACCEPTABLE, notifyData); 53 } 54 55 /** @hide */ 56 @Override isValidDataLength(int dataLen)57 protected boolean isValidDataLength(int dataLen) { 58 return EXPECTED_ERROR_DATA_LEN == dataLen; 59 } 60 } 61