]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 | 3 | |
7c673cae FG |
4 | /* |
5 | * Ceph - scalable distributed file system | |
6 | * | |
7 | * Copyright (C) 2013 eNovance SAS <licensing@enovance.com> | |
8 | * | |
9 | * This is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License version 2.1, as published by the Free Software | |
12 | * Foundation. See file COPYING. | |
13 | * | |
14 | */ | |
15 | ||
16 | #ifndef CEPH_RGW_CORS_SWIFT3_H | |
17 | #define CEPH_RGW_CORS_SWIFT3_H | |
18 | ||
19 | #include <map> | |
20 | #include <string> | |
21 | #include <vector> | |
22 | #include <include/types.h> | |
23 | #include <include/str_list.h> | |
24 | ||
25 | #include "rgw_cors.h" | |
26 | ||
7c673cae FG |
27 | class RGWCORSConfiguration_SWIFT : public RGWCORSConfiguration |
28 | { | |
29 | public: | |
30 | RGWCORSConfiguration_SWIFT() {} | |
31 | ~RGWCORSConfiguration_SWIFT() {} | |
32 | int create_update(const char *allow_origins, const char *allow_headers, | |
33 | const char *expose_headers, const char *max_age) { | |
34 | set<string> o, h, oc; | |
35 | list<string> e; | |
36 | unsigned long a = CORS_MAX_AGE_INVALID; | |
37 | uint8_t flags = RGW_CORS_ALL; | |
38 | ||
39 | string ao = allow_origins; | |
40 | get_str_set(ao, oc); | |
41 | if (oc.empty()) | |
42 | return -EINVAL; | |
43 | for(set<string>::iterator it = oc.begin(); it != oc.end(); ++it) { | |
44 | string host = *it; | |
45 | if (validate_name_string(host) != 0) | |
46 | return -EINVAL; | |
47 | o.insert(o.end(), host); | |
48 | } | |
49 | if (allow_headers) { | |
50 | string ah = allow_headers; | |
51 | get_str_set(ah, h); | |
52 | for(set<string>::iterator it = h.begin(); | |
53 | it != h.end(); ++it) { | |
54 | string s = (*it); | |
55 | if (validate_name_string(s) != 0) | |
56 | return -EINVAL; | |
57 | } | |
58 | } | |
59 | ||
60 | if (expose_headers) { | |
61 | string eh = expose_headers; | |
62 | get_str_list(eh, e); | |
63 | } | |
64 | if (max_age) { | |
65 | char *end = NULL; | |
66 | a = strtoul(max_age, &end, 10); | |
67 | if (a == ULONG_MAX) | |
68 | a = CORS_MAX_AGE_INVALID; | |
69 | } | |
70 | ||
71 | RGWCORSRule rule(o, h, e, flags, a); | |
72 | stack_rule(rule); | |
73 | return 0; | |
74 | } | |
75 | }; | |
76 | #endif /*CEPH_RGW_CORS_SWIFT3_H*/ |