[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [2862] Moved `SecurityToken' in a separate file.
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [2862] Moved `SecurityToken' in a separate file. |
Date: |
Fri, 03 Oct 2008 22:08:55 +0000 |
Revision: 2862
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2862
Author: gscrivano
Date: 2008-10-03 22:08:55 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
Moved `SecurityToken' in a separate file. It requires additional refactoring.
Modified Paths:
--------------
branches/myserver_sec_new/include/conf/security/Makefile.am
branches/myserver_sec_new/include/conf/security/security_manager.h
branches/myserver_sec_new/src/conf/security/Makefile.am
branches/myserver_sec_new/src/conf/security/security_manager.cpp
Added Paths:
-----------
branches/myserver_sec_new/include/conf/security/security_token.h
branches/myserver_sec_new/src/conf/security/security_token.cpp
Modified: branches/myserver_sec_new/include/conf/security/Makefile.am
===================================================================
--- branches/myserver_sec_new/include/conf/security/Makefile.am 2008-10-03
12:53:13 UTC (rev 2861)
+++ branches/myserver_sec_new/include/conf/security/Makefile.am 2008-10-03
22:08:55 UTC (rev 2862)
@@ -1,4 +1,4 @@
securityincludedir=$(includedir)/myserver/include/conf/security
-securityinclude_HEADERS = auth_domain.h auth_method.h auth_method_factory.h
security_cache.h security_domain.h security_manager.h validator.h
validator_factory.h xml_validator.h
+securityinclude_HEADERS = auth_domain.h auth_method.h auth_method_factory.h
security_cache.h security_domain.h security_manager.h security_token.h
validator.h validator_factory.h xml_validator.h
SUBDIRS =
Modified: branches/myserver_sec_new/include/conf/security/security_manager.h
===================================================================
--- branches/myserver_sec_new/include/conf/security/security_manager.h
2008-10-03 12:53:13 UTC (rev 2861)
+++ branches/myserver_sec_new/include/conf/security/security_manager.h
2008-10-03 22:08:55 UTC (rev 2862)
@@ -20,6 +20,7 @@
#define SECURITY_MANAGER_H
#include "stdafx.h"
+#include <include/conf/security/security_token.h>
#include <include/connection/connection.h>
#include <include/base/xml/xml_parser.h>
#include <include/protocol/http/http_headers.h>
@@ -42,80 +43,22 @@
*/
enum PERMISSION_MASK
{
- /*! Current user can read the file. */
+ /*! Current user can read the file. */
MYSERVER_PERMISSION_READ = (1<<0),
- /*! Current user can write to the file. */
+ /*! Current user can write to the file. */
MYSERVER_PERMISSION_WRITE = (1<<1),
- /*! Current user can execute the file. */
+ /*! Current user can execute the file. */
MYSERVER_PERMISSION_EXECUTE = (1<<2),
- /*! Current user can remove the file. */
+ /*! Current user can remove the file. */
MYSERVER_PERMISSION_DELETE = (1<<3),
-/*! Current user can browse the directory content. */
+/*! Current user can browse the directory content. */
MYSERVER_PERMISSION_BROWSE = (1<<4)
};
-struct SecurityToken
-{
- SecurityToken();
- void reset();
-
- /*! User to check for. */
- string user;
-
- /*! Password provided by the user. */
- string password;
-
- /*! Directory that the user is in. */
- string *directory;
-
- /*! System directory for the host. */
- string *sysdirectory;
-
- /*! Resource that the user tried to access. */
- string *resource;
-
- /*! Permission mask. */
- int mask;
-
- /*!
- *Password that the user should provide to have access.
- *This is used in authorization schemes like the HTTP digest,
- *where the password is not sent in clear on the network.
- */
- string neededPassword;
-
- /*! The provided password is correct. */
- bool authenticated;
-
- /*! The obtained mask if password were correct. */
- int providedMask;
-
- /*! Stored values. */
- HashMap<string,string*> values;
-
- /*! If it is true the security manager will use the cached values. */
- bool done;
-
- /*! Server instance. */
- Server* server;
-
- /*! VHost. */
- Vhost* vhost;
-
-
- ///////OLD NOT USED////////////
- char* requiredPassword;
- const char* filename;
- struct HttpThreadContext* td;
- char* authType;
- int authTypeLen;
- int throttlingRate;
-};
-
class SecurityManager
{
public:
Added: branches/myserver_sec_new/include/conf/security/security_token.h
===================================================================
--- branches/myserver_sec_new/include/conf/security/security_token.h
(rev 0)
+++ branches/myserver_sec_new/include/conf/security/security_token.h
2008-10-03 22:08:55 UTC (rev 2862)
@@ -0,0 +1,104 @@
+/* -*- mode: c++ -*- */
+/*
+MyServer
+Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SECURITY_TOKEN_H
+#define SECURITY_TOKEN_H
+
+#include "stdafx.h"
+#include <include/base/hash_map/hash_map.h>
+
+#include <string>
+
+using namespace std;
+
+class Server;
+class Vhost;
+
+enum SECURITY_RING
+{
+ /*! Security file configuration. */
+ MYSERVER_SECURITY_CONF = (1<<0),
+
+ /*! Virtual host configuration. */
+ MYSERVER_VHOST_CONF = (1<<1),
+
+ /*! Global server configuration. */
+ MYSERVER_SERVER_CONF = (1<<2),
+};
+
+struct SecurityToken
+{
+ SecurityToken();
+ void reset();
+ const char* getHashedData(const char* name, int domains);
+
+
+ /*! User to check for. */
+ string user;
+
+ /*! Password provided by the user. */
+ string password;
+
+ /*! Directory that the user is in. */
+ string *directory;
+
+ /*! System directory for the host. */
+ string *sysdirectory;
+
+ /*! Resource that the user tried to access. */
+ string *resource;
+
+ /*! Permission mask. */
+ int mask;
+
+ /*!
+ *Password that the user should provide to have access.
+ *This is used in authorization schemes like the HTTP digest,
+ *where the password is not sent in clear on the network.
+ */
+ string neededPassword;
+
+ /*! The provided password is correct. */
+ bool authenticated;
+
+ /*! The obtained mask if password were correct. */
+ int providedMask;
+
+ /*! Stored values. */
+ HashMap<string,string*> values;
+
+ /*! If it is true the security manager will use the cached values. */
+ bool done;
+
+ /*! Server instance. */
+ Server* server;
+
+ /*! VHost. */
+ Vhost* vhost;
+
+
+ ///////OLD NOT USED////////////
+ char* requiredPassword;
+ const char* filename;
+ struct HttpThreadContext* td;
+ char* authType;
+ int authTypeLen;
+ int throttlingRate;
+};
+
+#endif
Modified: branches/myserver_sec_new/src/conf/security/Makefile.am
===================================================================
--- branches/myserver_sec_new/src/conf/security/Makefile.am 2008-10-03
12:53:13 UTC (rev 2861)
+++ branches/myserver_sec_new/src/conf/security/Makefile.am 2008-10-03
22:08:55 UTC (rev 2862)
@@ -1,4 +1,4 @@
lib_LIBRARIES = libsecurity.a
-libsecurity_a_SOURCES = auth_domain.cpp auth_method.cpp
auth_method_factory.cpp security_cache.cpp security_domain.cpp
security_manager.cpp validator.cpp validator_factory.cpp xml_validator.cpp
+libsecurity_a_SOURCES = auth_domain.cpp auth_method.cpp
auth_method_factory.cpp security_cache.cpp security_domain.cpp
security_manager.cpp security_token.cpp validator.cpp validator_factory.cpp
xml_validator.cpp
SUBDIRS =
INCLUDES = $(all_includes)
Modified: branches/myserver_sec_new/src/conf/security/security_manager.cpp
===================================================================
--- branches/myserver_sec_new/src/conf/security/security_manager.cpp
2008-10-03 12:53:13 UTC (rev 2861)
+++ branches/myserver_sec_new/src/conf/security/security_manager.cpp
2008-10-03 22:08:55 UTC (rev 2862)
@@ -28,39 +28,8 @@
using namespace std;
-/*!
- *Create the object.
- */
-SecurityToken::SecurityToken ()
-{
- reset ();
-}
-
-/*!
- *Reset every structure member.
- */
-void SecurityToken::reset ()
-{
- mask = 0;
- done = false;
- server = NULL;
- vhost = NULL;
-
- directory = NULL;
- sysdirectory = NULL;
- resource = NULL;
-
-}
-
SecurityManager::SecurityManager (ValidatorFactory* vf, AuthMethodFactory* amf)
{
- /*
- HashMap<string, Validator*>::Iterator it = validators.begin ();
-
- for (;it != validators.end (); it++)
- {
- delete *it;
- }*/
validatorFactory = vf;
authMethodFactory = amf;
}
Added: branches/myserver_sec_new/src/conf/security/security_token.cpp
===================================================================
--- branches/myserver_sec_new/src/conf/security/security_token.cpp
(rev 0)
+++ branches/myserver_sec_new/src/conf/security/security_token.cpp
2008-10-03 22:08:55 UTC (rev 2862)
@@ -0,0 +1,91 @@
+/*
+MyServer
+Copyright (C) 2002-2008 Free Software Foundation, Inc.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include <include/conf/security/security_token.h>
+#include <include/conf/vhost/vhost.h>
+#include <include/server/server.h>
+
+#include <string>
+#include <sstream>
+#include <memory>
+
+using namespace std;
+
+/*!
+ *Create the object.
+ */
+SecurityToken::SecurityToken ()
+{
+ reset ();
+}
+
+/*!
+ *Reset every structure member.
+ */
+void SecurityToken::reset ()
+{
+ mask = 0;
+ done = false;
+ server = NULL;
+ vhost = NULL;
+
+ directory = NULL;
+ sysdirectory = NULL;
+ resource = NULL;
+
+}
+
+/*!
+ *Get the value for the variable using the specified domains.
+ *\param name Variable name.
+ *\param domains Domains where to look. They are looked in this order:
+ *\li Security configuration file.
+ *\li Virtual host configuration file.
+ *\li Global security file.
+ */
+const char* SecurityToken::getHashedData (const char* name, int domains)
+{
+ if (domains & MYSERVER_SECURITY_CONF)
+ {
+ string strName (name);
+ string *ret = values.get (strName);
+
+ if (ret)
+ return ret->c_str ();
+
+ }
+
+ if (vhost && (domains & MYSERVER_VHOST_CONF))
+ {
+ const char* ret = vhost->getHashedData (name);
+
+ if (ret)
+ return ret;
+ }
+
+ if (server && (domains & MYSERVER_SERVER_CONF))
+ {
+ const char* ret = server->getHashedData (name);
+
+ if (ret)
+ return ret;
+ }
+
+
+ return NULL;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [2862] Moved `SecurityToken' in a separate file.,
Giuseppe Scrivano <=