CUBRID Engine  latest
client_credentials.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 //
20 // clientid.hpp -
21 //
22 
23 #ifndef _CLIENT_CREDENTIALS_HPP_
24 #define _CLIENT_CREDENTIALS_HPP_
25 
26 #include "dbtype_def.h"
27 #include "db_client_type.hpp"
28 #include "packable_object.hpp"
29 
30 #include <string>
31 
32 /* BOOT_CLIENT_TYPE : needed for legacy code */
34 
36 
37 typedef struct clientids CLIENTIDS;
39 {
40  public:
42  std::string client_info;
43  std::string db_user;
44  std::string program_name;
45  std::string login_name;
46  std::string host_name;
48 
49  clientids ();
50  ~clientids () override;
51 
52  const char *get_client_info () const;
53  const char *get_db_user () const;
54  const char *get_program_name () const;
55  const char *get_login_name () const;
56  const char *get_host_name () const;
57 
58  void set_ids (db_client_type type, const char *client_info, const char *db_user, const char *program_name,
59  const char *login_name, const char *host_name, int process_id);
60  void set_ids (const clientids &other);
61  void set_user (const char *db_user);
62 
63  void set_system_internal ();
64  void set_system_internal_with_user (const char *db_user);
65  void reset ();
66 
67  // packable_object
68  virtual size_t get_packed_size (cubpacking::packer &serializator, std::size_t start_offset = 0) const override;
69  virtual void pack (cubpacking::packer &serializator) const override;
70  virtual void unpack (cubpacking::unpacker &deserializator) override;
71 
72  static const char *UNKNOWN_ID;
73 
74  private:
75  void set_client_info (const char *client_info);
76  void set_program_name (const char *program_name);
77  void set_login_name (const char *login_name);
78  void set_host_name (const char *host_name);
79 };
80 
83 {
84  std::string db_name; /* DB_MAX_IDENTIFIER_LENGTH */
85  std::string db_password; /* DB_MAX_PASSWORD_LENGTH */
86  char *preferred_hosts; /* LINE_MAX */
88 
90  ~boot_client_credential () override;
91 
92  const char *get_db_name () const;
93  const char *get_db_password () const;
94 
95  // packable_object
96  virtual size_t get_packed_size (cubpacking::packer &serializator, std::size_t start_offset = 0) const override;
97  virtual void pack (cubpacking::packer &serializator) const override;
98  virtual void unpack (cubpacking::unpacker &deserializator) override;
99 };
100 
101 #endif // !_CLIENT_CREDENTIALS_HPP_
void set_system_internal_with_user(const char *db_user)
enum db_client_type BOOT_CLIENT_TYPE
const char * get_host_name() const
void set_program_name(const char *program_name)
virtual void unpack(cubpacking::unpacker &deserializator) override
void set_user(const char *db_user)
db_client_type client_type
const char * get_program_name() const
static const char * UNKNOWN_ID
~clientids() override
void set_client_info(const char *client_info)
const char * get_client_info() const
std::string client_info
void set_system_internal()
std::string db_user
virtual void pack(cubpacking::packer &serializator) const override
db_client_type
std::string program_name
virtual size_t get_packed_size(cubpacking::packer &serializator, std::size_t start_offset=0) const override
const char * get_login_name() const
const char * get_db_user() const
const size_t LOG_USERNAME_MAX
void set_host_name(const char *host_name)
std::string host_name
void set_ids(db_client_type type, const char *client_info, const char *db_user, const char *program_name, const char *login_name, const char *host_name, int process_id)
std::string login_name
#define DB_MAX_USER_LENGTH
Definition: dbtype_def.h:498
void set_login_name(const char *login_name)