00001 /* 00002 * 00003 * Copyright (C) 2008-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Author: Michael Onken 00015 * 00016 * Module: dcmnet 00017 * 00018 * Purpose: 00019 * User Identity Negotiation for A-ASSOCIATE (Supp. 99) 00020 * 00021 * Last Update: $Author: joergr $ 00022 * Update Date: $Date: 2010-10-14 13:17:22 $ 00023 * CVS/RCS Revision: $Revision: 1.7 $ 00024 * Status: $State: Exp $ 00025 * 00026 * CVS/RCS Log at end of file 00027 * 00028 */ 00029 00030 #ifndef DCUSERID_H 00031 #define DCUSERID_H 00032 00033 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00034 #include "dcmtk/ofstd/ofcond.h" 00035 00037 #define DUL_TYPENEGOTIATIONOFUSERIDENTITY (unsigned char)0x58 00038 00040 enum T_ASC_UserIdentityNegotiationMode 00041 { 00042 ASC_USER_IDENTITY_NONE = 0, 00043 ASC_USER_IDENTITY_USER = 1, 00044 ASC_USER_IDENTITY_USER_PASSWORD = 2, 00045 ASC_USER_IDENTITY_KERBEROS = 3, 00046 ASC_USER_IDENTITY_SAML = 4, 00047 ASC_USER_IDENTITY_UNKNOWN 00048 }; 00049 00050 00053 class UserIdentityNegotiationSubItem { 00054 00055 public: 00056 00059 UserIdentityNegotiationSubItem(); 00060 00065 virtual unsigned char pduType() const =0; 00066 00070 virtual unsigned char getItemType() const {return m_itemType;} 00071 00076 virtual unsigned char getReserved() const {return m_reserved;} 00077 00082 virtual OFCondition streamedLength(unsigned long& length) const = 0; 00083 00092 virtual OFCondition parseFromBuffer(unsigned char *readBuffer, 00093 unsigned long& bytesRead, 00094 unsigned long availData) =0; 00095 00101 virtual OFCondition stream(unsigned char *targetBuffer, 00102 unsigned long& lengthWritten) const =0; 00103 00107 virtual void clear() =0; 00108 00113 virtual void dump(STD_NAMESPACE ostream& outstream) const =0; 00114 00117 virtual ~UserIdentityNegotiationSubItem() {} 00118 00119 private: 00120 00123 const unsigned char m_itemType; 00124 00126 const unsigned char m_reserved; 00127 00128 }; 00129 00130 00133 class UserIdentityNegotiationSubItemRQ : public UserIdentityNegotiationSubItem { 00134 00135 public: 00136 00139 UserIdentityNegotiationSubItemRQ(); 00140 00144 unsigned char pduType() const; 00145 00149 virtual void clear(); 00150 00156 void setIdentityType(const T_ASC_UserIdentityNegotiationMode& mode); 00157 00162 T_ASC_UserIdentityNegotiationMode getIdentityType(); 00163 00169 void setPrimField(const char *buffer, 00170 const Uint16& length); 00171 00177 void setSecField(const char *buffer, 00178 const Uint16& length); 00179 00187 Uint16 getPrimField(char*& resultBuf, 00188 Uint16& resultLen) const; 00189 00197 Uint16 getSecField(char*& resultBuf, 00198 Uint16& resultLen) const; 00199 00204 void setReqPosResponse(const OFBool& reqPosRsp); 00205 00206 00210 OFBool isPosResponseRequested() 00211 { 00212 return (m_posRspRequested != 0) ? OFTrue: OFFalse; 00213 } 00214 00221 OFCondition stream(unsigned char *targetBuffer, 00222 unsigned long& lengthWritten) const; 00223 00228 OFCondition streamedLength(unsigned long& length) const; 00229 00238 OFCondition parseFromBuffer(unsigned char *readBuffer, 00239 unsigned long &bytesRead, 00240 unsigned long availData); 00241 00246 void dump(STD_NAMESPACE ostream& outstream) const; 00247 00252 UserIdentityNegotiationSubItemRQ& operator= (const UserIdentityNegotiationSubItemRQ& rhs); 00253 00258 UserIdentityNegotiationSubItemRQ(const UserIdentityNegotiationSubItemRQ& rhs); 00259 00262 ~UserIdentityNegotiationSubItemRQ(); 00263 00264 private: 00265 00267 T_ASC_UserIdentityNegotiationMode m_userIdentityType; 00269 unsigned char m_posRspRequested; 00271 char* m_primField; 00273 Uint16 m_primFieldLength; 00275 char* m_secField; 00277 Uint16 m_secFieldLength; 00278 }; 00279 00280 00281 class UserIdentityNegotiationSubItemAC : public UserIdentityNegotiationSubItem { 00282 00283 public: 00284 00287 UserIdentityNegotiationSubItemAC(); 00288 00292 unsigned char pduType() const; 00293 00297 virtual void clear(); 00298 00304 void setServerResponse(const char* rsp, 00305 const Uint16& rspLen); 00306 00314 Uint16 getServerResponse(char*& targetBuffer, 00315 Uint16& resultLen) const; 00316 00321 OFCondition streamedLength(unsigned long& length) const; 00322 00328 OFCondition stream(unsigned char *targetBuffer, 00329 unsigned long& lengthWritten) const; 00330 00339 OFCondition parseFromBuffer(unsigned char *readBuffer, 00340 unsigned long &bytesRead, 00341 unsigned long availData); 00342 00347 void dump(STD_NAMESPACE ostream& outstream) const; 00348 00353 UserIdentityNegotiationSubItemAC& operator= (const UserIdentityNegotiationSubItemAC& rhs); 00354 00359 UserIdentityNegotiationSubItemAC(const UserIdentityNegotiationSubItemAC& rhs); 00360 00363 ~UserIdentityNegotiationSubItemAC(); 00364 00365 private: 00366 00368 char* m_serverRsp; 00370 Uint16 m_rspLength; 00371 00372 }; 00373 00374 #endif // DCUSERID_H 00375 00376 /* 00377 ** CVS/RCS Log: 00378 ** $Log: dcuserid.h,v $ 00379 ** Revision 1.7 2010-10-14 13:17:22 joergr 00380 ** Updated copyright header. Added reference to COPYRIGHT file. 00381 ** 00382 ** Revision 1.6 2010-10-05 11:01:04 uli 00383 ** Removed a unused copy-constructor and a unused operator=. 00384 ** 00385 ** Revision 1.5 2010-09-14 11:42:14 uli 00386 ** Verify the length fields in the PDUs that we receive. 00387 ** 00388 ** Revision 1.4 2009-09-29 14:34:16 uli 00389 ** Include only the needed headers in dcuserid.h and not dctk.h. 00390 ** 00391 ** Revision 1.3 2008-10-07 09:08:13 onken 00392 ** Fixed possible memory leak in user identity classes and added code for 00393 ** accessing user identity from the server's side. Thanks to "Pim" 00394 ** 00395 ** Revision 1.2 2008-04-17 16:09:32 onken 00396 ** Added some const definitions to functions. 00397 ** 00398 ** Revision 1.1 2008-04-17 15:28:33 onken 00399 ** Reworked and extended User Identity Negotiation code. 00400 ** 00401 */