• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 android.net.ssl;
18 
19 import static java.util.Objects.requireNonNull;
20 
21 import libcore.util.NonNull;
22 import libcore.util.Nullable;
23 
24 import java.security.InvalidParameterException;
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.Set;
31 
32 import javax.net.ssl.ManagerFactoryParameters;
33 
34 /**
35  * Parameters for configuring a {@code KeyManager} that supports PAKE
36  * (Password Authenticated Key Exchange) on the server side.
37  *
38  * <p>This class holds the necessary information for the {@code KeyManager} to perform PAKE
39  * authentication, including a mapping of client and server IDs (links) to their corresponding PAKE
40  * options.</p>
41  *
42  * <p>Instances of this class are immutable. Use the {@link Builder} to create
43  * instances.</p>
44  *
45  * @hide
46  */
47 public final class PakeServerKeyManagerParameters implements ManagerFactoryParameters {
48     /**
49      * Returns a set of the links.
50      *
51      * @return The known links.
52      */
getLinks()53     public @NonNull Set<Link> getLinks() {
54         throw new RuntimeException("Stub!");
55     }
56 
57     /**
58      * Returns an unmodifiable list of PAKE options for the given {@link Link}.
59      *
60      * @param link The link for which to retrieve the options. Should have been obtained through
61      *             {@link #getLinks}.
62      * @return An unmodifiable list of PAKE options for the given link.
63      */
getOptions(@onNull Link link)64     public @NonNull List<PakeOption> getOptions(@NonNull Link link) {
65         throw new RuntimeException("Stub!");
66     }
67 
68     /**
69      * Returns an unmodifiable list of PAKE options for the given client-server pair.
70      *
71      * @param clientId The client identifier for the link.
72      * @param serverId The server identifier for the link.
73      * @return An unmodifiable list of PAKE options for the given link.
74      */
getOptions( @ullable byte[] clientId, @Nullable byte[] serverId)75     public @NonNull List<PakeOption> getOptions(
76             @Nullable byte[] clientId, @Nullable byte[] serverId) {
77         throw new RuntimeException("Stub!");
78     }
79 
80     /**
81      * A PAKE link class combining the client and server IDs.
82      *
83      * @hide
84      */
85     public static final class Link {
86         /**
87          * Constructs a {@code Link} object.
88          *
89          * @param clientId The client identifier for the link.
90          * @param serverId The server identifier for the link.
91          */
Link(@ullable byte[] clientId, @Nullable byte[] serverId)92         private Link(@Nullable byte[] clientId, @Nullable byte[] serverId) {
93             throw new RuntimeException("Stub!");
94         }
95 
96         /**
97          * Returns the client identifier for the link.
98          *
99          * @return The client identifier for the link.
100          */
getClientId()101         public @Nullable byte[] getClientId() {
102             throw new RuntimeException("Stub!");
103         }
104 
105         /**
106          * Returns the server identifier for the link.
107          *
108          * @return The server identifier for the link.
109          */
getServerId()110         public @Nullable byte[] getServerId() {
111             throw new RuntimeException("Stub!");
112         }
113 
114         @Override
equals(Object o)115         public boolean equals(Object o) {
116             throw new RuntimeException("Stub!");
117         }
118 
119         @Override
hashCode()120         public int hashCode() {
121             throw new RuntimeException("Stub!");
122         }
123     }
124 
125     /**
126      * A builder for creating {@link PakeServerKeyManagerParameters} instances.
127      *
128      * @hide
129      */
130     public static final class Builder {
131         /**
132          * Adds PAKE options for the given client and server IDs.
133          * Only the first link for SPAKE2PLUS_PRERELEASE will be used.
134          *
135          * @param clientId The client ID.
136          * @param serverId The server ID.
137          * @param options The list of PAKE options to add.
138          * @return This builder.
139          * @throws InvalidParameterException If the provided options are invalid.
140          */
setOptions(@ullable byte[] clientId, @Nullable byte[] serverId, @NonNull List<PakeOption> options)141         public @NonNull Builder setOptions(@Nullable byte[] clientId, @Nullable byte[] serverId,
142                 @NonNull List<PakeOption> options) {
143             throw new RuntimeException("Stub!");
144         }
145 
146         /**
147          * Builds a new {@link PakeServerKeyManagerParameters} instance.
148          *
149          * @return A new {@link PakeServerKeyManagerParameters} instance.
150          * @throws InvalidParameterException If no links are provided.
151          */
build()152         public @NonNull PakeServerKeyManagerParameters build() {
153             throw new RuntimeException("Stub!");
154         }
155     }
156 }
157