odil
C++11libraryfortheDICOMstandard
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 #include "odil/pdu/SOPClassCommonExtendedNegotiation.h"
19 #include "odil/pdu/SOPClassExtendedNegotiation.h"
20 
21 namespace odil
22 {
23 
26 {
27 public:
33  {
35  enum class Result
36  {
37  Acceptance = 0,
38  UserRejection = 1,
39  NoReason = 2,
40  AbstractSyntaxNotSupported = 3,
41  TransferSyntaxesNotSupported = 4,
42  };
43 
45  uint8_t id,
46  std::string const & abstract_syntax,
47  std::vector<std::string> const & transfer_syntaxes,
49  Result result=Result::NoReason);
50 
52  uint8_t id;
53 
55  std::string abstract_syntax;
56 
58  std::vector<std::string> transfer_syntaxes;
59 
62 
65 
68 
70  bool operator==(PresentationContext const & other) const;
71  };
72 
74  struct UserIdentity
75  {
77  enum class Type
78  {
79  None = 0,
80  Username = 1,
81  UsernameAndPassword = 2,
82  Kerberos = 3,
83  SAML = 4
84  };
85 
86  UserIdentity();
87 
89  Type type, std::string const & primary_field,
90  std::string const & secondary_field);
91 
94 
96  std::string primary_field;
97 
99  std::string secondary_field;
100 
102  bool operator==(UserIdentity const & other) const;
103  };
104 
107 
109  AssociationParameters(pdu::AAssociateRQ const & pdu);
110 
113  pdu::AAssociateAC const & pdu, AssociationParameters const & request);
114 
116  std::string const & get_called_ae_title() const;
117 
124  AssociationParameters & set_called_ae_title(std::string const & value);
125 
127  std::string const & get_calling_ae_title() const;
128 
135  AssociationParameters & set_calling_ae_title(std::string const & value);
136 
138  std::vector<PresentationContext> const & get_presentation_contexts() const;
139 
142  set_presentation_contexts(std::vector<PresentationContext> const & value);
143 
145  UserIdentity const & get_user_identity() const;
146 
149 
152  set_user_identity_to_username(std::string const & username);
153 
157  std::string const & username, std::string const & password);
158 
161  set_user_identity_to_kerberos(std::string const & ticket);
162 
165  set_user_identity_to_saml(std::string const & assertion);
166 
168  uint32_t get_maximum_length() const;
169 
174  AssociationParameters & set_maximum_length(uint32_t value);
175 
177  uint16_t get_maximum_number_operations_invoked() const;
178 
184 
187 
193 
195  std::vector<pdu::SOPClassExtendedNegotiation>
197 
203  std::vector<pdu::SOPClassExtendedNegotiation> const & value);
204 
206  std::vector<pdu::SOPClassCommonExtendedNegotiation>
208 
214  std::vector<pdu::SOPClassCommonExtendedNegotiation> const & value);
215 
217  pdu::AAssociateRQ as_a_associate_rq() const;
218 
220  pdu::AAssociateAC as_a_associate_ac() const;
221 
223  bool operator==(AssociationParameters const & other) const;
224 
225 private:
226  std::string _called_ae_title;
227  std::string _calling_ae_title;
228  std::vector<PresentationContext> _presentation_contexts;
229  UserIdentity _user_identity;
230  uint32_t _maximum_length;
231  uint16_t _maximum_number_operations_invoked;
232  uint16_t _maximum_number_operations_performed;
233  std::vector<pdu::SOPClassExtendedNegotiation>
234  _sop_class_extended_negotiation;
235  std::vector<pdu::SOPClassCommonExtendedNegotiation>
236  _sop_class_common_extended_negotiation;
237 
239  AssociationParameters & _set_user_identity(UserIdentity const & value);
240 };
241 
242 }
243 
244 #endif // _061fafd4_982e_4a7e_9eb0_29e06443ebf3
AssociationParameters & set_calling_ae_title(std::string const &value)
Set the calling AE title.
Definition: AssociationParameters.cpp:318
AssociationParameters()
Constructor.
Definition: AssociationParameters.cpp:106
std::string const & get_called_ae_title() const
Return the called AE title, default to empty.
Definition: AssociationParameters.cpp:291
uint16_t get_maximum_number_operations_performed() const
Return the maximum number of outstanding operations performed.
Definition: AssociationParameters.cpp:436
std::string abstract_syntax
Proposed abstract syntax.
Definition: AssociationParameters.h:55
AssociationParameters & set_presentation_contexts(std::vector< PresentationContext > const &value)
Set the presentation contexts. All ids must be odd and unique.
Definition: AssociationParameters.cpp:338
uint8_t id
Identifier of the presentation context, must be odd.
Definition: AssociationParameters.h:52
AssociationParameters & set_user_identity_to_kerberos(std::string const &ticket)
Authenticate user using a Kerberos ticket.
Definition: AssociationParameters.cpp:392
bool scu_role_support
Support for SCU role.
Definition: AssociationParameters.h:61
void set_sop_class_common_extended_negotiation(std::vector< pdu::SOPClassCommonExtendedNegotiation > const &value)
Set the list of SOP Class Common Extend Negotiation items, default to an empty list.
Definition: AssociationParameters.cpp:473
bool scp_role_support
Support for SCP role.
Definition: AssociationParameters.h:64
pdu::AAssociateRQ as_a_associate_rq() const
Create an A-ASSOCIATE-RQ PDU.
Definition: AssociationParameters.cpp:481
bool operator==(PresentationContext const &other) const
Member-wise equality.
Definition: AssociationParameters.cpp:48
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:383
AssociationParameters & set_user_identity_to_username(std::string const &username)
Authenticate user using only a username.
Definition: AssociationParameters.cpp:375
UserIdentity const & get_user_identity() const
Return the user identity, default to None.
Definition: AssociationParameters.cpp:361
Encapsulate association parameters.
Definition: AssociationParameters.h:25
AssociationParameters & set_user_identity_to_saml(std::string const &assertion)
Authenticate user using a SAML assertion.
Definition: AssociationParameters.cpp:399
uint32_t get_maximum_length() const
Return the maximum length of a PDU, default to 16384.
Definition: AssociationParameters.cpp:406
Result
Result of the presentation context negotiation.
Definition: AssociationParameters.h:35
std::vector< PresentationContext > const & get_presentation_contexts() const
Return the presentation contexts, default to empty.
Definition: AssociationParameters.cpp:331
Type
User identity type.
Definition: AssociationParameters.h:77
AssociationParameters & set_maximum_number_operations_performed(uint16_t value)
Set the maximum number of outstanding operations performed, default to 1.
Definition: AssociationParameters.cpp:443
std::vector< pdu::SOPClassExtendedNegotiation > get_sop_class_extended_negotiation() const
Return the list of SOP Class Extended Negotiation items.
Definition: AssociationParameters.cpp:451
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:32
std::string secondary_field
Secondary identity field.
Definition: AssociationParameters.h:99
AssociationParameters & set_maximum_length(uint32_t value)
Set the maximum length of a PDU, the value 0 meaning no maximum length.
Definition: AssociationParameters.cpp:413
pdu::AAssociateAC as_a_associate_ac() const
Create an A-ASSOCIATE-AC PDU.
Definition: AssociationParameters.cpp:565
std::string const & get_calling_ae_title() const
Return the calling AE title, default to empty.
Definition: AssociationParameters.cpp:311
Type type
Identity type.
Definition: AssociationParameters.h:93
Result result
Result of the negotiation.
Definition: AssociationParameters.h:67
std::string primary_field
Primary identity field.
Definition: AssociationParameters.h:96
AssociationParameters & set_maximum_number_operations_invoked(uint16_t value)
Set the maximum number of outstanding operations invoked, default to 1.
Definition: AssociationParameters.cpp:428
uint16_t get_maximum_number_operations_invoked() const
Return the maximum number of outstanding operations invoked.
Definition: AssociationParameters.cpp:421
AssociationParameters & set_called_ae_title(std::string const &value)
Set the called AE title.
Definition: AssociationParameters.cpp:298
User Identity, cf. PS3.8 D.3.3.7.
Definition: AssociationParameters.h:74
std::vector< pdu::SOPClassCommonExtendedNegotiation > get_sop_class_common_extended_negotiation() const
Return the list of SOP Class Extended Negotiation items.
Definition: AssociationParameters.cpp:466
void set_sop_class_extended_negotiation(std::vector< pdu::SOPClassExtendedNegotiation > const &value)
Set the list of SOP Class Extended Negotiation items, default to an empty list.
Definition: AssociationParameters.cpp:458
std::vector< std::string > transfer_syntaxes
Proposed transfer syntaxes or accepted transfer syntax.
Definition: AssociationParameters.h:58
AssociationParameters & set_user_identity_to_none()
Do no authenticate user.
Definition: AssociationParameters.cpp:368