BLPAPI C++  3.24.10
blpapi_authoptions.h
Go to the documentation of this file.
1 /* Copyright 2019. Bloomberg Finance L.P.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions: The above
9  * copyright notice and this permission notice shall be included in all copies
10  * or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18  * IN THE SOFTWARE.
19  */
20 
28 #ifndef INCLUDED_BLPAPI_AUTHOPTIONS
29 #define INCLUDED_BLPAPI_AUTHOPTIONS
30 
73 #include <blpapi_call.h>
74 #include <blpapi_defs.h>
75 #include <blpapi_exception.h>
76 #include <blpapi_types.h>
77 
78 #include <stddef.h>
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
86 
89  blpapi_AuthOptions_t **options, const blpapi_AuthUser_t *user);
90 
93  blpapi_AuthOptions_t **options, const blpapi_AuthApplication_t *app);
94 
97  const blpapi_AuthUser_t *user,
98  const blpapi_AuthApplication_t *app);
99 
102  blpapi_AuthOptions_t **options, const blpapi_AuthToken_t *token);
103 
106  blpapi_AuthOptions_t **options, const blpapi_AuthOptions_t *dup);
107 
110  blpapi_AuthOptions_t *lhs, const blpapi_AuthOptions_t *rhs);
111 
114 
117 
120  blpapi_AuthUser_t **user, const char *propertyName);
121 
124  blpapi_AuthUser_t **user, const char *userId, const char *ipAddress);
125 
128  blpapi_AuthUser_t **user, const blpapi_AuthUser_t *dup);
129 
132 
135 
138  blpapi_AuthApplication_t **app, const char *appName);
139 
143 
147 
150 
152 int blpapi_AuthToken_create(blpapi_AuthToken_t **token, const char *tokenStr);
153 
156  blpapi_AuthToken_t **token, const blpapi_AuthToken_t *dup);
157 
160  blpapi_AuthToken_t *lhs, const blpapi_AuthToken_t *rhs);
161 
164 
165 #ifdef __cplusplus
166 }
167 
175 namespace BloombergLP {
176 namespace blpapi {
177 
178 class AuthUser;
179 class AuthApplication;
180 class AuthToken;
181 
182 // =================
183 // class AuthOptions
184 // =================
185 
194 class AuthOptions {
195 
196  blpapi_AuthOptions_t *d_handle_p;
197 
198  public:
199  AuthOptions();
205  AuthOptions(const AuthUser& user);
214  AuthOptions(const AuthApplication& app);
219  AuthOptions(const AuthUser& user, const AuthApplication& app);
224  AuthOptions(const AuthToken& token);
234  AuthOptions(const AuthOptions& options);
239  ~AuthOptions();
244  AuthOptions& operator=(const AuthOptions& rhs);
250  blpapi_AuthOptions_t *handle() const;
254 };
255 
256 // =======================
257 // class AuthUser
258 // =======================
259 
266 class AuthUser {
267 
268  blpapi_AuthUser_t *d_handle_p;
269 
270  public:
271  explicit AuthUser(blpapi_AuthUser_t *handle);
276  AuthUser(const AuthUser& user);
281  ~AuthUser();
286  AuthUser& operator=(const AuthUser& rhs);
292  static AuthUser createWithLogonName();
299  const char *propertyName);
309  const char *userId, const char *ipAddress);
317  const blpapi_AuthUser_t *handle() const;
321 };
322 
323 // ==============================
324 // class AuthApplication
325 // ==============================
326 
334 
335  blpapi_AuthApplication_t *d_handle_p;
336 
337  public:
338  explicit AuthApplication(const char *appName);
351  AuthApplication(const AuthApplication& app);
367  const blpapi_AuthApplication_t *handle() const;
371 };
372 
373 // ========================
374 // class AuthToken
375 // ========================
376 
383 class AuthToken {
384 
385  blpapi_AuthToken_t *d_handle_p;
386 
387  public:
388  explicit AuthToken(const char *tokenStr);
401  AuthToken(const AuthToken& token);
406  ~AuthToken();
411  AuthToken& operator=(const AuthToken& rhs);
417  const blpapi_AuthToken_t *handle() const;
421 };
422 
426 // ============================================================================
427 // INLINE FUNCTION DEFINITIONS
428 // ============================================================================
429 
430 // =================
431 // class AuthOptions
432 // =================
433 
435 {
438 }
439 
441 {
444  &d_handle_p, user.handle()));
445 }
446 
448 {
450  blpapi_AuthOptions_create_forAppMode)(&d_handle_p, app.handle()));
451 }
452 
454  const AuthUser& user, const AuthApplication& app)
455 {
458  &d_handle_p, user.handle(), app.handle()));
459 }
460 
462 {
464  blpapi_AuthOptions_create_forToken)(&d_handle_p, token.handle()));
465 }
466 
468  : d_handle_p(handle)
469 {
470 }
471 
472 inline AuthOptions::AuthOptions(const AuthOptions& options)
473 {
475  &d_handle_p, options.handle()));
476 }
477 
479 {
481 }
482 
484 {
486  BLPAPI_CALL(blpapi_AuthOptions_copy)(d_handle_p, rhs.handle()));
487 
488  return *this;
489 }
490 
491 inline blpapi_AuthOptions_t *AuthOptions::handle() const { return d_handle_p; }
492 
493 // =======================
494 // class AuthUser
495 // =======================
496 
498  : d_handle_p(handle)
499 {
500 }
501 
502 inline AuthUser::AuthUser(const AuthUser& user)
503 {
505  &d_handle_p, user.handle()));
506 }
507 
509 {
511 }
512 
514 {
516  BLPAPI_CALL(blpapi_AuthUser_copy)(d_handle_p, rhs.handle()));
517 
518  return *this;
519 }
520 
522 {
523  blpapi_AuthUser_t *handle = NULL;
524 
527 
528  AuthUser user(handle);
529 
530  return user;
531 }
532 
534  const char *propertyName)
535 {
536  blpapi_AuthUser_t *handle = NULL;
537 
540  &handle, propertyName));
541 
542  AuthUser user(handle);
543 
544  return user;
545 }
546 
548  const char *userId, const char *ipAddress)
549 {
550  blpapi_AuthUser_t *handle = NULL;
551 
554  &handle, userId, ipAddress));
555 
556  AuthUser user(handle);
557 
558  return user;
559 }
560 
561 inline const blpapi_AuthUser_t *AuthUser::handle() const { return d_handle_p; }
562 
563 // ==============================
564 // class AuthApplication
565 // ==============================
566 
567 inline AuthApplication::AuthApplication(const char *name)
568 {
570  BLPAPI_CALL(blpapi_AuthApplication_create)(&d_handle_p, name));
571 }
572 
574  : d_handle_p(handle)
575 {
576 }
577 
579 {
581  &d_handle_p, app.handle()));
582 }
583 
585 {
587 }
588 
590 {
592  d_handle_p, rhs.handle()));
593 
594  return *this;
595 }
596 
598 {
599  return d_handle_p;
600 }
601 
602 // ========================
603 // class AuthToken
604 // ========================
605 
606 inline AuthToken::AuthToken(const char *tokenStr)
607 {
609  BLPAPI_CALL(blpapi_AuthToken_create)(&d_handle_p, tokenStr));
610 }
611 
613  : d_handle_p(handle)
614 {
615 }
616 
617 inline AuthToken::AuthToken(const AuthToken& token)
618 {
620  &d_handle_p, token.handle()));
621 }
622 
624 {
626 }
627 
629 {
631  BLPAPI_CALL(blpapi_AuthToken_copy)(d_handle_p, rhs.handle()));
632 
633  return *this;
634 }
635 
637 {
638  return d_handle_p;
639 }
640 
641 } // close namespace blpapi
642 } // close namespace BloombergLP
643 
644 #endif // #ifdef __cplusplus
645 #endif // #ifndef INCLUDED_BLPAPI_AUTHOPTIONS
BLPAPI_EXPORT int blpapi_AuthUser_createWithManualOptions(blpapi_AuthUser_t **user, const char *userId, const char *ipAddress)
struct blpapi_AuthUser blpapi_AuthUser_t
Definition: blpapi_types.h:206
Common definitions used by the library.
BLPAPI_EXPORT int blpapi_AuthOptions_create_default(blpapi_AuthOptions_t **options)
AuthToken & operator=(const AuthToken &rhs)
Definition: blpapi_authoptions.h:628
static AuthUser createWithLogonName()
Definition: blpapi_authoptions.h:521
Definition: blpapi_abstractsession.h:187
struct blpapi_AuthToken blpapi_AuthToken_t
Definition: blpapi_types.h:212
BLPAPI_EXPORT int blpapi_AuthUser_createWithActiveDirectoryProperty(blpapi_AuthUser_t **user, const char *propertyName)
#define BLPAPI_CALL(FUNCNAME)
Definition: blpapi_call.h:353
Definition: blpapi_authoptions.h:333
~AuthToken()
Definition: blpapi_authoptions.h:623
const blpapi_AuthToken_t * handle() const
Definition: blpapi_authoptions.h:636
Definition: blpapi_authoptions.h:194
const blpapi_AuthUser_t * handle() const
Definition: blpapi_authoptions.h:561
BLPAPI_EXPORT int blpapi_AuthOptions_create_forAppMode(blpapi_AuthOptions_t **options, const blpapi_AuthApplication_t *app)
~AuthApplication()
Definition: blpapi_authoptions.h:584
~AuthUser()
Definition: blpapi_authoptions.h:508
BLPAPI_EXPORT void blpapi_AuthToken_destroy(blpapi_AuthToken_t *token)
AuthOptions & operator=(const AuthOptions &rhs)
Definition: blpapi_authoptions.h:483
AuthUser & operator=(const AuthUser &rhs)
Definition: blpapi_authoptions.h:513
BLPAPI_EXPORT int blpapi_AuthApplication_duplicate(blpapi_AuthApplication_t **app, const blpapi_AuthApplication_t *dup)
blpapi_AuthOptions_t * handle() const
Definition: blpapi_authoptions.h:491
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
AuthOptions()
Definition: blpapi_authoptions.h:434
BLPAPI_EXPORT int blpapi_AuthOptions_duplicate(blpapi_AuthOptions_t **options, const blpapi_AuthOptions_t *dup)
BLPAPI_EXPORT int blpapi_AuthApplication_copy(blpapi_AuthApplication_t *lhs, const blpapi_AuthApplication_t *rhs)
struct blpapi_AuthOptions blpapi_AuthOptions_t
Definition: blpapi_types.h:203
const blpapi_AuthApplication_t * handle() const
Definition: blpapi_authoptions.h:597
BLPAPI_EXPORT void blpapi_AuthApplication_destroy(blpapi_AuthApplication_t *app)
BLPAPI_EXPORT int blpapi_AuthOptions_create_forUserAndAppMode(blpapi_AuthOptions_t **options, const blpapi_AuthUser_t *user, const blpapi_AuthApplication_t *app)
BLPAPI_EXPORT void blpapi_AuthOptions_destroy(blpapi_AuthOptions_t *options)
static AuthUser createWithActiveDirectoryProperty(const char *propertyName)
Definition: blpapi_authoptions.h:533
BLPAPI_EXPORT int blpapi_AuthUser_duplicate(blpapi_AuthUser_t **user, const blpapi_AuthUser_t *dup)
BLPAPI_EXPORT int blpapi_AuthOptions_create_forUserMode(blpapi_AuthOptions_t **options, const blpapi_AuthUser_t *user)
static AuthUser createWithManualOptions(const char *userId, const char *ipAddress)
Definition: blpapi_authoptions.h:547
AuthApplication(const char *appName)
Definition: blpapi_authoptions.h:567
BLPAPI_EXPORT int blpapi_AuthUser_createWithLogonName(blpapi_AuthUser_t **user)
AuthToken(const char *tokenStr)
Definition: blpapi_authoptions.h:606
BLPAPI_EXPORT int blpapi_AuthOptions_copy(blpapi_AuthOptions_t *lhs, const blpapi_AuthOptions_t *rhs)
BLPAPI_EXPORT int blpapi_AuthUser_copy(blpapi_AuthUser_t *lhs, const blpapi_AuthUser_t *rhs)
BLPAPI_EXPORT int blpapi_AuthApplication_create(blpapi_AuthApplication_t **app, const char *appName)
Defines Exceptions that can be thrown by the blpapi library.
BLPAPI_EXPORT void blpapi_AuthUser_destroy(blpapi_AuthUser_t *user)
AuthUser(blpapi_AuthUser_t *handle)
Definition: blpapi_authoptions.h:497
#define BLPAPI_CALL_UNCHECKED(FUNCNAME)
Definition: blpapi_call.h:354
AuthApplication & operator=(const AuthApplication &rhs)
Definition: blpapi_authoptions.h:589
BLPAPI_EXPORT int blpapi_AuthToken_copy(blpapi_AuthToken_t *lhs, const blpapi_AuthToken_t *rhs)
~AuthOptions()
Definition: blpapi_authoptions.h:478
struct blpapi_AuthApplication blpapi_AuthApplication_t
Definition: blpapi_types.h:209
Definition: blpapi_authoptions.h:383
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
BLPAPI_EXPORT int blpapi_AuthOptions_create_forToken(blpapi_AuthOptions_t **options, const blpapi_AuthToken_t *token)
Provide functions for dispatchtbl.
Provide BLPAPI types.
Definition: blpapi_authoptions.h:266
BLPAPI_EXPORT int blpapi_AuthToken_duplicate(blpapi_AuthToken_t **token, const blpapi_AuthToken_t *dup)
BLPAPI_EXPORT int blpapi_AuthToken_create(blpapi_AuthToken_t **token, const char *tokenStr)