* @brief initializes plugin configuration. * @param argc number of plugin parameters * @param argv plugin parameters */
| 167 | * @param argv plugin parameters |
| 168 | */ |
| 169 | bool |
| 170 | AccessControlConfig::init(int argc, char *argv[]) |
| 171 | { |
| 172 | static const struct option longopt[] = { |
| 173 | {const_cast<char *>("invalid-syntax-status-code"), optional_argument, nullptr, 'a'}, |
| 174 | {const_cast<char *>("invalid-signature-status-code"), optional_argument, nullptr, 'b'}, |
| 175 | {const_cast<char *>("invalid-timing-status-code"), optional_argument, nullptr, 'c'}, |
| 176 | {const_cast<char *>("invalid-scope-status-code"), optional_argument, nullptr, 'd'}, |
| 177 | {const_cast<char *>("invalid-origin-response"), optional_argument, nullptr, 'e'}, |
| 178 | {const_cast<char *>("internal-error-status-code"), optional_argument, nullptr, 'f'}, |
| 179 | {const_cast<char *>("check-cookie"), optional_argument, nullptr, 'g'}, |
| 180 | {const_cast<char *>("symmetric-keys-map"), optional_argument, nullptr, 'h'}, |
| 181 | {const_cast<char *>("reject-invalid-token-requests"), optional_argument, nullptr, 'i'}, |
| 182 | {const_cast<char *>("extract-subject-to-header"), optional_argument, nullptr, 'j'}, |
| 183 | {const_cast<char *>("extract-tokenid-to-header"), optional_argument, nullptr, 'k'}, |
| 184 | {const_cast<char *>("extract-status-to-header"), optional_argument, nullptr, 'l'}, |
| 185 | {const_cast<char *>("token-response-header"), optional_argument, nullptr, 'm'}, |
| 186 | {const_cast<char *>("use-redirects"), optional_argument, nullptr, 'n'}, |
| 187 | {const_cast<char *>("include-uri-paths-file"), optional_argument, nullptr, 'o'}, |
| 188 | {const_cast<char *>("exclude-uri-paths-file"), optional_argument, nullptr, 'p'}, |
| 189 | {nullptr, 0, nullptr, 0 } |
| 190 | }; |
| 191 | |
| 192 | bool status = true; |
| 193 | optind = 0; |
| 194 | |
| 195 | /* argv contains the "to" and "from" URLs. Skip the first so that the second one poses as the program name. */ |
| 196 | argc--; |
| 197 | argv++; |
| 198 | |
| 199 | for (;;) { |
| 200 | int opt; |
| 201 | opt = getopt_long(argc, (char *const *)argv, "", longopt, nullptr); |
| 202 | |
| 203 | if (opt == -1) { |
| 204 | break; |
| 205 | } |
| 206 | AccessControlDebug("processing %s", argv[optind - 1]); |
| 207 | |
| 208 | switch (opt) { |
| 209 | case 'a': /* invalid-syntax-status-code */ |
| 210 | { |
| 211 | _invalidSignature = static_cast<TSHttpStatus>(string2int(optarg)); |
| 212 | } break; |
| 213 | case 'b': /* invalid-signature-status-code */ |
| 214 | { |
| 215 | _invalidSignature = static_cast<TSHttpStatus>(string2int(optarg)); |
| 216 | } break; |
| 217 | case 'c': /* invalid-timing-status-code */ |
| 218 | { |
| 219 | _invalidTiming = static_cast<TSHttpStatus>(string2int(optarg)); |
| 220 | } break; |
| 221 | case 'd': /* invalid-scope-status-code */ |
| 222 | { |
| 223 | _invalidScope = static_cast<TSHttpStatus>(string2int(optarg)); |
| 224 | } break; |
| 225 | case 'e': /* invalid-origin-response */ |
| 226 | { |
no test coverage detected