~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/simple_user_policy/policy.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#pragma once
22
22
 
23
 
#include <iostream>
 
23
#include <iosfwd>
24
24
 
25
25
#include <drizzled/plugin/authorization.h>
26
26
 
27
27
namespace simple_user_policy
28
28
{
29
29
 
 
30
extern std::string remap_dot_to;
 
31
 
30
32
class Policy :
31
33
  public drizzled::plugin::Authorization
32
34
{
33
35
public:
34
36
  Policy() :
35
 
    drizzled::plugin::Authorization("Simple User Policy")
 
37
    drizzled::plugin::Authorization("simple_user_policy")
36
38
  { }
37
39
 
38
40
  virtual bool restrictSchema(const drizzled::identifier::User &user_ctx,
39
 
                              drizzled::identifier::Schema::const_reference schema);
 
41
                              const drizzled::identifier::Schema& schema);
40
42
 
41
43
  virtual bool restrictProcess(const drizzled::identifier::User &user_ctx,
42
44
                               const drizzled::identifier::User &session_ctx);
43
45
};
44
46
 
45
47
inline bool Policy::restrictSchema(const drizzled::identifier::User &user_ctx,
46
 
                                   drizzled::identifier::Schema::const_reference schema)
 
48
                                   const drizzled::identifier::Schema& schema)
47
49
{
48
50
  if ((user_ctx.username() == "root")
49
51
      || schema.compare("data_dictionary")
52
54
    return false;
53
55
  }
54
56
 
55
 
  return not schema.compare(user_ctx.username());
 
57
  std::string username(user_ctx.username());
 
58
  size_t found;
 
59
 
 
60
  found=username.find_first_of('.');
 
61
  while (found!=std::string::npos)
 
62
  {
 
63
    username.replace(found, 1, remap_dot_to);
 
64
    found=username.find_first_of('.',found+1);
 
65
  }
 
66
 
 
67
  return not schema.compare(username);
56
68
}
57
69
 
58
70
inline bool Policy::restrictProcess(const drizzled::identifier::User &user_ctx,