• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 when IKE authentication failed.
24  *
25  * @see <a href="https://tools.ietf.org/html/rfc7296#section-2.21.2">RFC 7296, Internet Key Exchange
26  *     Protocol Version 2 (IKEv2)</a>
27  * @hide
28  */
29 public final class AuthenticationFailedException extends IkeProtocolException {
30     private static final int EXPECTED_ERROR_DATA_LEN = 0;
31 
32     /**
33      * Construct a instance of AuthenticationFailedException.
34      *
35      * <p>Except for testing, IKE library users normally do not instantiate this object themselves
36      * but instead get a reference via {@link IkeSessionCallback} or {@link ChildSessionCallback}.
37      *
38      * @param message the descriptive message (which is saved for later retrieval by the {@link
39      *     #getMessage()} method).
40      */
AuthenticationFailedException(@onNull String message)41     public AuthenticationFailedException(@NonNull String message) {
42         super(ERROR_TYPE_AUTHENTICATION_FAILED, message);
43     }
44 
45     /**
46      * Construct a instance of AuthenticationFailedException.
47      *
48      * <p>Except for testing, IKE library users normally do not instantiate this object themselves
49      * but instead get a reference via {@link IkeSessionCallback} or {@link ChildSessionCallback}.
50      *
51      * @param cause the cause (which is saved for later retrieval by the {@link #getCause()}
52      *     method).
53      */
AuthenticationFailedException(@onNull Throwable cause)54     public AuthenticationFailedException(@NonNull Throwable cause) {
55         super(ERROR_TYPE_AUTHENTICATION_FAILED, cause);
56     }
57 
58     /**
59      * Construct a instance of AuthenticationFailedException from a notify payload.
60      *
61      * @param notifyData the notify data included in the payload.
62      * @hide
63      */
AuthenticationFailedException(byte[] notifyData)64     public AuthenticationFailedException(byte[] notifyData) {
65         super(ERROR_TYPE_AUTHENTICATION_FAILED, notifyData);
66     }
67 
68     /** @hide */
69     @Override
isValidDataLength(int dataLen)70     protected boolean isValidDataLength(int dataLen) {
71         return EXPECTED_ERROR_DATA_LEN == dataLen;
72     }
73 }
74