|
| 1 | +package net.continuumsecurity.proxy; |
| 2 | + |
| 3 | +import net.continuumsecurity.proxy.model.User; |
| 4 | +import org.zaproxy.clientapi.core.ClientApiException; |
| 5 | + |
| 6 | +import java.io.IOException; |
| 7 | +import java.io.UnsupportedEncodingException; |
| 8 | +import java.util.List; |
| 9 | +import java.util.Map; |
| 10 | + |
| 11 | +public interface Authentication { |
| 12 | + /** |
| 13 | + * Returns the supported authentication methods by ZAP. |
| 14 | + * @return list of supported authentication methods. |
| 15 | + * @throws ClientApiException |
| 16 | + */ |
| 17 | + List<String> getSupportedAuthenticationMethods() throws ClientApiException; |
| 18 | + |
| 19 | + /** |
| 20 | + * Returns logged in indicator pattern for the given context. |
| 21 | + * @param contextId Id of the context. |
| 22 | + * @return Logged in indicator for the given context. |
| 23 | + * @throws ClientApiException |
| 24 | + */ |
| 25 | + String getLoggedInIndicator(String contextId) throws ClientApiException; |
| 26 | + |
| 27 | + /** |
| 28 | + * Returns logged out indicator pattern for the given context. |
| 29 | + * @param contextId Id of the context. |
| 30 | + * @return Logged out indicator for the given context. |
| 31 | + * @throws ClientApiException |
| 32 | + */ |
| 33 | + String getLoggedOutIndicator(String contextId) throws ClientApiException; |
| 34 | + |
| 35 | + /** |
| 36 | + * Sets the logged in indicator to a given context. |
| 37 | + * @param contextId Id of a context. |
| 38 | + * @param loggedInIndicatorRegex Regex pattern for logged in indicator. |
| 39 | + * @throws ClientApiException |
| 40 | + */ |
| 41 | + void setLoggedInIndicator(String contextId, String loggedInIndicatorRegex) throws ClientApiException; |
| 42 | + |
| 43 | + /** |
| 44 | + * Sets the logged out indicator to a given context. |
| 45 | + * @param contextId Id of a context. |
| 46 | + * @param loggedOutIndicatorRegex Regex pattern for logged out indicator. |
| 47 | + * @throws ClientApiException |
| 48 | + */ |
| 49 | + void setLoggedOutIndicator(String contextId, String loggedOutIndicatorRegex) throws ClientApiException; |
| 50 | + |
| 51 | + /** |
| 52 | + * Returns authentication method for a given context. |
| 53 | + * @param contextId Id of a context. |
| 54 | + * @return Authentication method details for the given context id. |
| 55 | + * @throws ClientApiException |
| 56 | + */ |
| 57 | + Map<String, String> getAuthenticationMethodInfo(String contextId) throws ClientApiException; |
| 58 | + |
| 59 | + /** |
| 60 | + * Returns the list of authentication config parameters. |
| 61 | + * Each config parameter is a map with keys "name" and "mandatory", holding the values name of the configuration parameter and whether it is mandatory/optional respectively. |
| 62 | + * @param authMethod Valid authentication method name. |
| 63 | + * @return List of configuration parameters for the given authentication method name. |
| 64 | + * @throws ClientApiException |
| 65 | + */ |
| 66 | + List<Map<String, String>> getAuthMethodConfigParameters(String authMethod) throws ClientApiException; |
| 67 | + |
| 68 | + /** |
| 69 | + * Sets the authentication method for a given context with given configuration parameters. |
| 70 | + * @param contextId Id of a context. |
| 71 | + * @param authMethodName Valid authentication method name. |
| 72 | + * @param authMethodConfigParams Authentication method configuration parameters such as loginUrl, loginRequestData formBasedAuthentication method, and hostName, port, realm for httpBasedAuthentication method. |
| 73 | + * @throws ClientApiException |
| 74 | + */ |
| 75 | + void setAuthenticationMethod(String contextId, String authMethodName, String authMethodConfigParams) throws ClientApiException; |
| 76 | + |
| 77 | + /** |
| 78 | + * Sets the formBasedAuthentication to given context id with the loginUrl and loginRequestData. |
| 79 | + * Example loginRequestData: "username={%username%}&password={%password%}" |
| 80 | + * @param contextId Id of the context. |
| 81 | + * @param loginUrl Login URL. |
| 82 | + * @param loginRequestData Login request data with form field names for username and password. |
| 83 | + * @throws ClientApiException |
| 84 | + * @throws UnsupportedEncodingException |
| 85 | + */ |
| 86 | + void setFormBasedAuthentication(String contextId, String loginUrl, String loginRequestData) throws ClientApiException, UnsupportedEncodingException; |
| 87 | + |
| 88 | + /** |
| 89 | + * Sets the HTTP/NTLM authentication to given context id with hostname, realm and port. |
| 90 | + * @param contextId Id of the context. |
| 91 | + * @param hostname Hostname. |
| 92 | + * @param realm Realm. |
| 93 | + * @param portNumber Port number. |
| 94 | + * @throws ClientApiException |
| 95 | + */ |
| 96 | + void setHttpAuthentication(String contextId, String hostname, String realm, String portNumber) throws ClientApiException, UnsupportedEncodingException; |
| 97 | + |
| 98 | + /** |
| 99 | + * Sets the HTTP/NTLM authentication to given context id with hostname, realm. |
| 100 | + * @param contextId Id of the context. |
| 101 | + * @param hostname Hostname. |
| 102 | + * @param realm Realm. |
| 103 | + * @throws ClientApiException |
| 104 | + */ |
| 105 | + void setHttpAuthentication(String contextId, String hostname, String realm) throws ClientApiException, UnsupportedEncodingException; |
| 106 | + |
| 107 | + /** |
| 108 | + * Sets the manual authentication to the given context id. |
| 109 | + * @param contextId Id of the context. |
| 110 | + * @throws ClientApiException |
| 111 | + */ |
| 112 | + void setManualAuthentication(String contextId) throws ClientApiException; |
| 113 | + |
| 114 | + /** |
| 115 | + * Sets the script based authentication to the given context id with the script name and config parameters. |
| 116 | + * @param contextId Id of the context. |
| 117 | + * @param scriptName Name of the script. |
| 118 | + * @param scriptConfigParams Script config parameters. |
| 119 | + * @throws ClientApiException |
| 120 | + */ |
| 121 | + void setScriptBasedAuthentication(String contextId, String scriptName, String scriptConfigParams) throws ClientApiException, UnsupportedEncodingException; |
| 122 | + |
| 123 | + /** |
| 124 | + * Returns list of {@link User}s for a given context. |
| 125 | + * @param contextId Id of the context. |
| 126 | + * @return List of {@link User}s |
| 127 | + * @throws ClientApiException |
| 128 | + * @throws IOException |
| 129 | + */ |
| 130 | + List<User> getUsersList(String contextId) throws ClientApiException, IOException; |
| 131 | + |
| 132 | + /** |
| 133 | + * Returns the {@link User} info for a given context id and user id. |
| 134 | + * @param contextId Id of a context. |
| 135 | + * @param userId Id of a user. |
| 136 | + * @return {@link User} info. |
| 137 | + * @throws ClientApiException |
| 138 | + * @throws IOException |
| 139 | + */ |
| 140 | + User getUserById(String contextId, String userId) throws ClientApiException, IOException; |
| 141 | + |
| 142 | + /** |
| 143 | + * Returns list of config parameters of authentication credentials for a given context id. |
| 144 | + * Each item in the list is a map with keys "name" and "mandatory". |
| 145 | + * @param contextId Id of a context. |
| 146 | + * @return List of authentication credentials configuration parameters. |
| 147 | + * @throws ClientApiException |
| 148 | + */ |
| 149 | + List<Map<String, String>> getAuthenticationCredentialsConfigParams(String contextId) throws ClientApiException; |
| 150 | + |
| 151 | + /** |
| 152 | + * Returns the authentication credentials as a map with key value pairs for a given context id and user id. |
| 153 | + * @param contextId Id of a context. |
| 154 | + * @param userId Id of a user. |
| 155 | + * @return Authentication credentials. |
| 156 | + * @throws ClientApiException |
| 157 | + */ |
| 158 | + Map<String, String> getAuthenticationCredentials(String contextId, String userId) throws ClientApiException; |
| 159 | + |
| 160 | + /** |
| 161 | + * Creates a new {@link User} for a given context and returns the user id. |
| 162 | + * @param contextId Id of a context. |
| 163 | + * @param name Name of the user. |
| 164 | + * @return User id. |
| 165 | + * @throws ClientApiException |
| 166 | + */ |
| 167 | + String newUser(String contextId, String name) throws ClientApiException; |
| 168 | + |
| 169 | + /** |
| 170 | + * Removes a {@link User} using the given context id and user id. |
| 171 | + * @param contextId Id of a {@link net.continuumsecurity.proxy.model.Context} |
| 172 | + * @param userId Id of a {@link User} |
| 173 | + * @throws ClientApiException |
| 174 | + */ |
| 175 | + void removeUser(String contextId, String userId) throws ClientApiException; |
| 176 | + |
| 177 | + /** |
| 178 | + * Sets the authCredentialsConfigParams to the given context and user. |
| 179 | + * Bu default, authCredentialsConfigParams uses key value separator "=" and key value pair separator "&". |
| 180 | + * Make sure that values provided for authCredentialsConfigParams are URL encoded using "UTF-8". |
| 181 | + * @param contextId Id of the context. |
| 182 | + * @param userId Id of the user. |
| 183 | + * @param authCredentialsConfigParams Authentication credentials config parameters. |
| 184 | + * @throws ClientApiException |
| 185 | + */ |
| 186 | + void setAuthenticationCredentials(String contextId, String userId, String authCredentialsConfigParams) throws ClientApiException; |
| 187 | + |
| 188 | + /** |
| 189 | + * Enables a {@link User} for a given {@link net.continuumsecurity.proxy.model.Context} id and user id. |
| 190 | + * @param contextId Id of a {@link net.continuumsecurity.proxy.model.Context} |
| 191 | + * @param userId Id of a {@link User} |
| 192 | + * @param enabled Boolean value to enable/disable the user. |
| 193 | + * @throws ClientApiException |
| 194 | + */ |
| 195 | + void setUserEnabled(String contextId, String userId, boolean enabled) throws ClientApiException; |
| 196 | + |
| 197 | + /** |
| 198 | + * Sets a name to the user for the given context id and user id. |
| 199 | + * @param contextId Id of a {@link net.continuumsecurity.proxy.model.Context} |
| 200 | + * @param userId Id of a {@link User} |
| 201 | + * @param name User name. |
| 202 | + * @throws ClientApiException |
| 203 | + */ |
| 204 | + void setUserName(String contextId, String userId, String name) throws ClientApiException; |
| 205 | + |
| 206 | + /** |
| 207 | + * Returns the forced user id for a given context. |
| 208 | + * @param contextId Id of a context. |
| 209 | + * @return Id of a forced {@link User} |
| 210 | + * @throws ClientApiException |
| 211 | + */ |
| 212 | + String getForcedUserId(String contextId) throws ClientApiException; |
| 213 | + |
| 214 | + /** |
| 215 | + * Returns true if forced user mode is enabled. Otherwise returns false. |
| 216 | + * @return true if forced user mode is enabled. |
| 217 | + * @throws ClientApiException |
| 218 | + */ |
| 219 | + boolean isForcedUserModeEnabled() throws ClientApiException; |
| 220 | + |
| 221 | + /** |
| 222 | + * Enables/disables the forced user mode. |
| 223 | + * @param forcedUserModeEnabled flag to enable/disable forced user mode. |
| 224 | + * @throws ClientApiException |
| 225 | + */ |
| 226 | + void setForcedUserModeEnabled(boolean forcedUserModeEnabled) throws ClientApiException; |
| 227 | + |
| 228 | + /** |
| 229 | + * Sets a {@link User} id as forced user for the given {@link net.continuumsecurity.proxy.model.Context} |
| 230 | + * @param contextId Id of a context. |
| 231 | + * @param userId Id of a user. |
| 232 | + * @throws ClientApiException |
| 233 | + */ |
| 234 | + void setForcedUser(String contextId, String userId) throws ClientApiException; |
| 235 | + |
| 236 | + /** |
| 237 | + * Returns list of supported session management methods. |
| 238 | + * @return List of supported session management methods. |
| 239 | + * @throws ClientApiException |
| 240 | + */ |
| 241 | + List<String> getSupportedSessionManagementMethods() throws ClientApiException; |
| 242 | + |
| 243 | + /** |
| 244 | + * Returns session management method selected for the given context. |
| 245 | + * @param contextId Id of a context. |
| 246 | + * @return Session management method for a given context. |
| 247 | + * @throws ClientApiException |
| 248 | + */ |
| 249 | + String getSessionManagementMethod(String contextId) throws ClientApiException; |
| 250 | + |
| 251 | + /** |
| 252 | + * Sets the given session management method and config params for a given context. |
| 253 | + * @param contextId Id of a context. |
| 254 | + * @param sessionManagementMethodName Session management method name. |
| 255 | + * @param methodConfigParams Session management method config parameters. |
| 256 | + * @throws ClientApiException |
| 257 | + */ |
| 258 | + void setSessionManagementMethod(String contextId, String sessionManagementMethodName, String methodConfigParams) throws ClientApiException; |
| 259 | +} |
0 commit comments