odil
AssociationParameters.h
1 /*************************************************************************
2  * odil - Copyright (C) Universite de Strasbourg
3  * Distributed under the terms of the CeCILL-B license, as published by
4  * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5  * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6  * for details.
7  ************************************************************************/
8 
9 #ifndef _061fafd4_982e_4a7e_9eb0_29e06443ebf3
10 #define _061fafd4_982e_4a7e_9eb0_29e06443ebf3
11 
12 #include <cstdint>
13 #include <string>
14 #include <vector>
15 
16 #include "odil/pdu/AAssociateAC.h"
17 #include "odil/pdu/AAssociateRQ.h"
18 
19 namespace odil
20 {
21 
24 {
25 public:
31  {
32  enum class Result
33  {
34  Acceptance = 0,
35  UserRejection = 1,
36  NoReason = 2,
37  AbstractSyntaxNotSupported = 3,
38  TransferSyntaxesNotSupported = 4,
39  };
40 
41  uint8_t id;
42  std::string abstract_syntax;
43  std::vector<std::string> transfer_syntaxes;
44  bool scu_role_support;
45  bool scp_role_support;
46  Result result;
47 
49  bool operator==(PresentationContext const & other) const;
50  };
51 
53  struct UserIdentity
54  {
55  enum class Type
56  {
57  None = 0,
58  Username = 1,
59  UsernameAndPassword = 2,
60  Kerberos = 3,
61  SAML = 4
62  };
63 
64  Type type;
65  std::string primary_field;
66  std::string secondary_field;
67 
69  bool operator==(UserIdentity const & other) const;
70  };
71 
74 
76  AssociationParameters(pdu::AAssociateRQ const & pdu);
77 
80  pdu::AAssociateAC const & pdu, AssociationParameters const & request);
81 
83  std::string const & get_called_ae_title() const;
84 
91  AssociationParameters & set_called_ae_title(std::string const & value);
92 
94  std::string const & get_calling_ae_title() const;
95 
102  AssociationParameters & set_calling_ae_title(std::string const & value);
103 
105  std::vector<PresentationContext> const & get_presentation_contexts() const;
106 
109  set_presentation_contexts(std::vector<PresentationContext> const & value);
110 
112  UserIdentity const & get_user_identity() const;
113 
116 
119  set_user_identity_to_username(std::string const & username);
120 
124  std::string const & username, std::string const & password);
125 
128  set_user_identity_to_kerberos(std::string const & ticket);
129 
132  set_user_identity_to_saml(std::string const & assertion);
133 
135  uint32_t get_maximum_length() const;
136 
141  AssociationParameters & set_maximum_length(uint32_t value);
142 
144  pdu::AAssociateRQ as_a_associate_rq() const;
145 
147  pdu::AAssociateAC as_a_associate_ac() const;
148 
150  bool operator==(AssociationParameters const & other) const;
151 
152 private:
153  std::string _called_ae_title;
154  std::string _calling_ae_title;
155  std::vector<PresentationContext> _presentation_contexts;
156  UserIdentity _user_identity;
157  uint32_t _maximum_length;
158 
160  AssociationParameters & _set_user_identity(UserIdentity const & value);
161 };
162 
163 }
164 
165 #endif // _061fafd4_982e_4a7e_9eb0_29e06443ebf3
bool operator==(PresentationContext const &other) const
Member-wise equality.
Definition: AssociationParameters.cpp:32
AssociationParameters & set_calling_ae_title(std::string const &value)
Set the calling AE title.
Definition: AssociationParameters.cpp:269
AssociationParameters()
Constructor.
Definition: AssociationParameters.cpp:74
AssociationParameters & set_presentation_contexts(std::vector< PresentationContext > const &value)
Set the presentation contexts. All ids must be odd and unique.
Definition: AssociationParameters.cpp:289
AssociationParameters & set_user_identity_to_kerberos(std::string const &ticket)
Authenticate user using a Kerberos ticket.
Definition: AssociationParameters.cpp:343
Definition: Association.cpp:39
AssociationParameters & set_user_identity_to_username_and_password(std::string const &username, std::string const &password)
Authenticate user using a username and a password.
Definition: AssociationParameters.cpp:334
AssociationParameters & set_user_identity_to_username(std::string const &username)
Authenticate user using only a username.
Definition: AssociationParameters.cpp:326
uint32_t get_maximum_length() const
Return the maximum length of a PDU, default to 16384.
Definition: AssociationParameters.cpp:357
Encapsulate association parameters.
Definition: AssociationParameters.h:23
AssociationParameters & set_user_identity_to_saml(std::string const &assertion)
Authenticate user using a SAML assertion.
Definition: AssociationParameters.cpp:350
std::string const & get_calling_ae_title() const
Return the calling AE title, default to empty.
Definition: AssociationParameters.cpp:262
std::string const & get_called_ae_title() const
Return the called AE title, default to empty.
Definition: AssociationParameters.cpp:242
pdu::AAssociateAC as_a_associate_ac() const
Create an A-ASSOCIATE-AC PDU.
Definition: AssociationParameters.cpp:440
std::vector< PresentationContext > const & get_presentation_contexts() const
Return the presentation contexts, default to empty.
Definition: AssociationParameters.cpp:282
Presentation Context, cf. PS 3.8, 9.3.2.2, PS 3.8, 9.3.3.2, PS 3.7, D.3.3.4.1 and PS 3...
Definition: AssociationParameters.h:30
AssociationParameters & set_maximum_length(uint32_t value)
Set the maximum length of a PDU, the value 0 meaning no maximum length.
Definition: AssociationParameters.cpp:364
AssociationParameters & set_called_ae_title(std::string const &value)
Set the called AE title.
Definition: AssociationParameters.cpp:249
User Identity, cf. PS3.8 D.3.3.7.
Definition: AssociationParameters.h:53
UserIdentity const & get_user_identity() const
Return the user identity, default to None.
Definition: AssociationParameters.cpp:312
AssociationParameters & set_user_identity_to_none()
Do no authenticate user.
Definition: AssociationParameters.cpp:319
pdu::AAssociateRQ as_a_associate_rq() const
Create an A-ASSOCIATE-RQ PDU.
Definition: AssociationParameters.cpp:372