|
| 1 | +/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | +
|
| 3 | +This program is free software; you can redistribute it and/or modify |
| 4 | +it under the terms of the GNU General Public License as published by |
| 5 | +the Free Software Foundation; version 2 of the License. |
| 6 | +
|
| 7 | +This program is distributed in the hope that it will be useful, |
| 8 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | +GNU General Public License for more details. |
| 11 | +
|
| 12 | +You should have received a copy of the GNU General Public License |
| 13 | +along with this program; if not, write to the Free Software |
| 14 | +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */ |
| 15 | + |
| 16 | +#ifndef SECURITY_CONTEXT_IMP_H |
| 17 | +#define SECURITY_CONTEXT_IMP_H |
| 18 | + |
| 19 | +#include <mysql/components/services/security_context.h> |
| 20 | +#include <mysql/components/service_implementation.h> |
| 21 | + |
| 22 | +/** |
| 23 | + An implementation of security_context service methods |
| 24 | +*/ |
| 25 | +class mysql_security_context_imp |
| 26 | +{ |
| 27 | +public: |
| 28 | + /** |
| 29 | + Gets the security context for the thread. |
| 30 | +
|
| 31 | + @sa mysql_thd_security_context::get() |
| 32 | + */ |
| 33 | + static DEFINE_BOOL_METHOD(get, |
| 34 | + (void *_thd, Security_context_handle *out_ctx)); |
| 35 | + |
| 36 | + /** |
| 37 | + Sets a new security context for the thread. |
| 38 | +
|
| 39 | + @sa mysql_thd_security_context::set() |
| 40 | + */ |
| 41 | + static DEFINE_BOOL_METHOD(set, |
| 42 | + (void *_thd, Security_context_handle in_ctx)); |
| 43 | + |
| 44 | + /** |
| 45 | + Creates a new security context and initializes it with the defaults |
| 46 | + (no access, no user etc). |
| 47 | +
|
| 48 | + @sa mysql_security_context_factory::create() |
| 49 | + */ |
| 50 | + static DEFINE_BOOL_METHOD(create, |
| 51 | + (Security_context_handle *out_ctx)); |
| 52 | + |
| 53 | + /** |
| 54 | + Deallocates a security context. |
| 55 | +
|
| 56 | + @sa mysql_security_context_factory::destroy() |
| 57 | + */ |
| 58 | + static DEFINE_BOOL_METHOD(destroy, |
| 59 | + (Security_context_handle ctx)); |
| 60 | + |
| 61 | + /** |
| 62 | + Duplicates a security context. |
| 63 | +
|
| 64 | + @sa mysql_security_context_factory::copy() |
| 65 | + */ |
| 66 | + static DEFINE_BOOL_METHOD(copy, |
| 67 | + (Security_context_handle in_ctx, Security_context_handle *out_ctx)); |
| 68 | + |
| 69 | + /** |
| 70 | + Looks up in the defined user accounts. |
| 71 | +
|
| 72 | + @sa mysql_account_database_security_context_lookup::lookup() |
| 73 | + */ |
| 74 | + static DEFINE_BOOL_METHOD(lookup, |
| 75 | + (Security_context_handle ctx, const char *user, const char *host, |
| 76 | + const char *ip, const char *db)); |
| 77 | + |
| 78 | + /** |
| 79 | + Reads a named security context attribute and retuns its value. |
| 80 | +
|
| 81 | + @sa mysql_security_context_options::get() |
| 82 | + */ |
| 83 | + static DEFINE_BOOL_METHOD(get, |
| 84 | + (Security_context_handle ctx, const char *name, void *inout_pvalue)); |
| 85 | + |
| 86 | + /** |
| 87 | + Sets a value for a named security context attribute |
| 88 | +
|
| 89 | + @sa mysql_security_context_options::set() |
| 90 | + */ |
| 91 | + static DEFINE_BOOL_METHOD(set, |
| 92 | + (Security_context_handle ctx, const char *name, void *pvalue)); |
| 93 | +}; |
| 94 | +#endif /* SECURITY_CONTEXT_IMP_H */ |
0 commit comments