blob: 91ab12e6c14c05af195359db4c1ab0bd5eb6d0e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// **********************************************************************
//
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <IceGrid/FileUserAccountMapperI.h>
#include <fstream>
using namespace std;
using namespace IceGrid;
FileUserAccountMapperI::FileUserAccountMapperI(const string& filename)
{
ifstream file(filename.c_str());
if(!file)
{
throw "cannot open `" + filename + "' for reading: " + strerror(errno);
}
while(true)
{
string user;
file >> user;
if(!file)
{
break;
}
string account;
file >> account;
if(!file)
{
break;
}
assert(!user.empty());
assert(!account.empty());
_accounts.insert(make_pair(user, account));
}
}
string
FileUserAccountMapperI::getUserAccount(const string& user, const Ice::Current&)
{
map<string, string>::const_iterator p = _accounts.find(user);
if(p == _accounts.end())
{
throw UserAccountNotFoundException();
}
return p->second;
}
|