Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
krb-name-mapping-test.cc
Go to the documentation of this file.
1 #include "krb-name-mapper.h"
2 
3 #include "common/logging.h"
4 
5 #include <boost/foreach.hpp>
6 
7 using namespace std;
8 using namespace impala;
9 
10 
11 
12 int main(int argc, char** argv) {
13  vector<string> rules;
14  rules.push_back("RULE:[1:$1@$0](.*@YAHOO\\.COM)s/@.*//");
15  rules.push_back("RULE:[2:$1](johndoe)s/^.*$/guest/");
16  rules.push_back("RULE:[2:$1;$2](^.*;admin$)s/;admin$//");
17  rules.push_back("RULE:[2:$2](root)");
18  rules.push_back("DEFAULT");
19 
20  FLAGS_kerberos_default_realm = "CLOUDERA.COM";
21  KrbNameMapper k(rules);
22  vector<string> principals;
23  principals.push_back("omalley@CLOUDERA.COM");
24  principals.push_back("hdfs/10.0.0.1@CLOUDERA.COM");
25  principals.push_back("johndoe/zoo@FOO.COM");
26  principals.push_back("joe/admin@FOO.COM");
27  principals.push_back("joe/root@FOO.COM");
28 
29  BOOST_FOREACH(const string& principal, principals) {
30  string out;
31  if (k.PrincipalToLocal(principal, &out)) {
32  LOG(INFO) << "Mapped: " << principal << " to: " << out;
33  } else {
34  LOG(INFO) << "Mapping for: " << principal << " failed!";
35  }
36  }
37 }
int main(int argc, char **argv)