ffead.server.doc
SecurityHandler.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * SecurityHandler.h
18  *
19  * Created on: Jun 17, 2012
20  * Author: Sumeet
21  */
22 
23 #ifndef SECURITYHANDLER_H_
24 #define SECURITYHANDLER_H_
25 #include "FileAuthController.h"
26 #include "Reflector.h"
27 #include "HttpRequest.h"
28 #include "HttpResponse.h"
29 #include "Logger.h"
30 
31 typedef ClassInfo (*FunPtr) ();
32 
34 {
35 public:
36  string path;
37  string role;
38 };
39 
40 class Security
41 {
42  Logger logger;
43 public:
44  Security();
45  ~Security();
46  vector<SecureAspect> secures;
47  string loginProvider;
48  string loginUrl;
49  string welocmeFile;
50  long sessTimeout;
51  bool isLoginConfigured()
52  {
53  return (loginProvider!="" && loginUrl!="");
54  }
55  bool isSecureConfigured()
56  {
57  return secures.size()!=0;
58  }
59  bool isLoginUrl(string url, string actUrl)
60  {
61  return (actUrl==(url+"/_ffead_security_cntxt_login_url"));
62  }
63  bool isLoginPage(string url, string actUrl)
64  {
65  return (actUrl==(url+"/"+loginUrl));
66  }
67  SecureAspect matchesPath(string url);
68 };
69 
70 
72  static Logger logger;
73 public:
75  virtual ~SecurityHandler();
76  static bool handle(string ip_addr, HttpRequest* req, HttpResponse& res, map<string, Security> securityObjectMap,
77  long sessionTimeout, void* dlib, map<string, string> cntMap);
78 };
79 
80 #endif /* SECURITYHANDLER_H_ */