~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/simple_user_policy/policy.h

  • Committer: Brian Aker
  • Date: 2010-12-18 05:18:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2009.
  • Revision ID: brian@tangent.org-20101218051830-lswb13hfiqbia74o
Adding user identifier that makes use of a shared ptr to handle concurrency
issues around looking at the state of a connection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    drizzled::plugin::Authorization("Simple User Policy")
37
37
  { }
38
38
 
39
 
  virtual bool restrictSchema(const drizzled::SecurityContext &user_ctx,
 
39
  virtual bool restrictSchema(const drizzled::identifier::User &user_ctx,
40
40
                              drizzled::SchemaIdentifier::const_reference schema);
41
41
 
42
 
  virtual bool restrictProcess(const drizzled::SecurityContext &user_ctx,
43
 
                               const drizzled::SecurityContext &session_ctx);
 
42
  virtual bool restrictProcess(const drizzled::identifier::User &user_ctx,
 
43
                               const drizzled::identifier::User &session_ctx);
44
44
};
45
45
 
46
 
inline bool Policy::restrictSchema(const drizzled::SecurityContext &user_ctx,
 
46
inline bool Policy::restrictSchema(const drizzled::identifier::User &user_ctx,
47
47
                                   drizzled::SchemaIdentifier::const_reference schema)
48
48
{
49
 
  if ((user_ctx.getUser() == "root")
 
49
  if ((user_ctx.username() == "root")
50
50
      || schema.compare("data_dictionary")
51
51
      || schema.compare("information_schema"))
52
52
    return false;
53
 
  return not schema.compare(user_ctx.getUser());
 
53
  return not schema.compare(user_ctx.username());
54
54
}
55
55
 
56
 
inline bool Policy::restrictProcess(const drizzled::SecurityContext &user_ctx,
57
 
                                    const drizzled::SecurityContext &session_ctx)
 
56
inline bool Policy::restrictProcess(const drizzled::identifier::User &user_ctx,
 
57
                                    const drizzled::identifier::User &session_ctx)
58
58
{
59
 
  if (user_ctx.getUser() == "root")
 
59
  if (user_ctx.username() == "root")
60
60
    return false;
61
 
  return user_ctx.getUser() != session_ctx.getUser();
 
61
 
 
62
  return user_ctx.username() != session_ctx.username();
62
63
}
63
64
 
64
65
} /* namespace simple_user_policy */