~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/simple_user_policy/policy.h

  • Committer: Monty Taylor
  • Date: 2008-09-16 00:00:48 UTC
  • mto: This revision was merged to the branch mainline in revision 391.
  • Revision ID: monty@inaugust.com-20080916000048-3rvrv3gv9l0ad3gs
Fixed copyright headers in drizzled/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2010 Monty Taylor <mordred@inaugust.com>
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
 
21
 
#ifndef PLUGIN_SIMPLE_USER_POLICY_POLICY_H
22
 
#define PLUGIN_SIMPLE_USER_POLICY_POLICY_H
23
 
 
24
 
#include <iostream>
25
 
 
26
 
#include <drizzled/plugin/authorization.h>
27
 
 
28
 
namespace simple_user_policy
29
 
{
30
 
 
31
 
class Policy :
32
 
  public drizzled::plugin::Authorization
33
 
{
34
 
public:
35
 
  Policy() :
36
 
    drizzled::plugin::Authorization("Simple User Policy")
37
 
  { }
38
 
 
39
 
  virtual bool restrictSchema(const drizzled::identifier::User &user_ctx,
40
 
                              drizzled::identifier::Schema::const_reference schema);
41
 
 
42
 
  virtual bool restrictProcess(const drizzled::identifier::User &user_ctx,
43
 
                               const drizzled::identifier::User &session_ctx);
44
 
};
45
 
 
46
 
inline bool Policy::restrictSchema(const drizzled::identifier::User &user_ctx,
47
 
                                   drizzled::identifier::Schema::const_reference schema)
48
 
{
49
 
  if ((user_ctx.username() == "root")
50
 
      || schema.compare("data_dictionary")
51
 
      || schema.compare("information_schema"))
52
 
  {
53
 
    return false;
54
 
  }
55
 
 
56
 
  return not schema.compare(user_ctx.username());
57
 
}
58
 
 
59
 
inline bool Policy::restrictProcess(const drizzled::identifier::User &user_ctx,
60
 
                                    const drizzled::identifier::User &session_ctx)
61
 
{
62
 
  if (user_ctx.username() == "root")
63
 
    return false;
64
 
 
65
 
  return user_ctx.username() != session_ctx.username();
66
 
}
67
 
 
68
 
} /* namespace simple_user_policy */
69
 
 
70
 
#endif /* PLUGIN_SIMPLE_USER_POLICY_POLICY_H */