BLPAPI C++ 3.26.5
Loading...
Searching...
No Matches
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
35
36#ifndef INCLUDED_BLPAPI_AUTHOPTIONS
37#define INCLUDED_BLPAPI_AUTHOPTIONS
38
80
81#include <blpapi_call.h>
82#include <blpapi_defs.h>
83#include <blpapi_exception.h>
84#include <blpapi_types.h>
85
86#include <stddef.h>
87
88#ifdef __cplusplus
89extern "C" {
90#endif
91
93
96
97BLPAPI_EXPORT
98int blpapi_AuthOptions_create_default(blpapi_AuthOptions_t **options);
99
100BLPAPI_EXPORT
101int blpapi_AuthOptions_create_forUserMode(
102 blpapi_AuthOptions_t **options, const blpapi_AuthUser_t *user);
103
104BLPAPI_EXPORT
105int blpapi_AuthOptions_create_forAppMode(
106 blpapi_AuthOptions_t **options, const blpapi_AuthApplication_t *app);
107
108BLPAPI_EXPORT
109int blpapi_AuthOptions_create_forUserAndAppMode(blpapi_AuthOptions_t **options,
110 const blpapi_AuthUser_t *user,
111 const blpapi_AuthApplication_t *app);
112
113BLPAPI_EXPORT
114int blpapi_AuthOptions_create_forToken(
115 blpapi_AuthOptions_t **options, const blpapi_AuthToken_t *token);
116
117BLPAPI_EXPORT
118int blpapi_AuthOptions_duplicate(
119 blpapi_AuthOptions_t **options, const blpapi_AuthOptions_t *dup);
120
121BLPAPI_EXPORT
122int blpapi_AuthOptions_copy(
123 blpapi_AuthOptions_t *lhs, const blpapi_AuthOptions_t *rhs);
124
125BLPAPI_EXPORT
126void blpapi_AuthOptions_destroy(blpapi_AuthOptions_t *options);
127
128BLPAPI_EXPORT
129int blpapi_AuthUser_createWithLogonName(blpapi_AuthUser_t **user);
130
131BLPAPI_EXPORT
132int blpapi_AuthUser_createWithActiveDirectoryProperty(
133 blpapi_AuthUser_t **user, const char *propertyName);
134
135BLPAPI_EXPORT
136int blpapi_AuthUser_createWithManualOptions(
137 blpapi_AuthUser_t **user, const char *userId, const char *ipAddress);
138
139BLPAPI_EXPORT
140int blpapi_AuthUser_duplicate(
141 blpapi_AuthUser_t **user, const blpapi_AuthUser_t *dup);
142
143BLPAPI_EXPORT
144int blpapi_AuthUser_copy(blpapi_AuthUser_t *lhs, const blpapi_AuthUser_t *rhs);
145
146BLPAPI_EXPORT
147void blpapi_AuthUser_destroy(blpapi_AuthUser_t *user);
148
149BLPAPI_EXPORT
150int blpapi_AuthApplication_create(
151 blpapi_AuthApplication_t **app, const char *appName);
152
153BLPAPI_EXPORT
154int blpapi_AuthApplication_duplicate(
155 blpapi_AuthApplication_t **app, const blpapi_AuthApplication_t *dup);
156
157BLPAPI_EXPORT
158int blpapi_AuthApplication_copy(
159 blpapi_AuthApplication_t *lhs, const blpapi_AuthApplication_t *rhs);
160
161BLPAPI_EXPORT
162void blpapi_AuthApplication_destroy(blpapi_AuthApplication_t *app);
163
164BLPAPI_EXPORT
165int blpapi_AuthToken_create(blpapi_AuthToken_t **token, const char *tokenStr);
166
167BLPAPI_EXPORT
168int blpapi_AuthToken_duplicate(
169 blpapi_AuthToken_t **token, const blpapi_AuthToken_t *dup);
170
171BLPAPI_EXPORT
172int blpapi_AuthToken_copy(
173 blpapi_AuthToken_t *lhs, const blpapi_AuthToken_t *rhs);
174
175BLPAPI_EXPORT
176void blpapi_AuthToken_destroy(blpapi_AuthToken_t *token);
177
180
181#ifdef __cplusplus
182}
183
190
191namespace BloombergLP {
192namespace blpapi {
193
194class AuthUser;
195class AuthApplication;
196class AuthToken;
197
198// =================
199// class AuthOptions
200// =================
201
211
212 blpapi_AuthOptions_t *d_handle_p;
213
214 public:
215 AuthOptions();
220
221 AuthOptions(const AuthUser& user);
229
230 AuthOptions(const AuthApplication& app);
234
235 AuthOptions(const AuthUser& user, const AuthApplication& app);
239
240 AuthOptions(const AuthToken& token);
244
245 explicit AuthOptions(blpapi_AuthOptions_t *handle);
249
250 AuthOptions(const AuthOptions& options);
254
255 ~AuthOptions();
259
260 AuthOptions& operator=(const AuthOptions& rhs);
265
266 blpapi_AuthOptions_t *handle() const;
270};
271
272// =======================
273// class AuthUser
274// =======================
275
282class AuthUser {
283
284 blpapi_AuthUser_t *d_handle_p;
285
286 public:
287 explicit AuthUser(blpapi_AuthUser_t *handle);
291
292 AuthUser(const AuthUser& user);
296
297 ~AuthUser();
301
302 AuthUser& operator=(const AuthUser& rhs);
307
313
315 const char *propertyName);
323
325 const char *userId, const char *ipAddress);
332
333 const blpapi_AuthUser_t *handle() const;
337};
338
339// ==============================
340// class AuthApplication
341// ==============================
342
350
351 blpapi_AuthApplication_t *d_handle_p;
352
353 public:
354 explicit AuthApplication(const char *appName);
361
362 explicit AuthApplication(blpapi_AuthApplication_t *handle);
366
371
376
382
383 const blpapi_AuthApplication_t *handle() const;
387};
388
389// ========================
390// class AuthToken
391// ========================
392
400
401 blpapi_AuthToken_t *d_handle_p;
402
403 public:
404 explicit AuthToken(const char *tokenStr);
411
412 explicit AuthToken(blpapi_AuthToken_t *handle);
416
417 AuthToken(const AuthToken& token);
421
422 ~AuthToken();
426
427 AuthToken& operator=(const AuthToken& rhs);
432
433 const blpapi_AuthToken_t *handle() const;
437};
438
441
442// ============================================================================
443// INLINE FUNCTION DEFINITIONS
444// ============================================================================
445
446// =================
447// class AuthOptions
448// =================
449
451{
453 BLPAPI_CALL(blpapi_AuthOptions_create_default)(&d_handle_p));
454}
455
457{
459 BLPAPI_CALL(blpapi_AuthOptions_create_forUserMode)(
460 &d_handle_p, user.handle()));
461}
462
464{
466 blpapi_AuthOptions_create_forAppMode)(&d_handle_p, app.handle()));
467}
468
470 const AuthUser& user, const AuthApplication& app)
471{
473 BLPAPI_CALL(blpapi_AuthOptions_create_forUserAndAppMode)(
474 &d_handle_p, user.handle(), app.handle()));
475}
476
478{
480 blpapi_AuthOptions_create_forToken)(&d_handle_p, token.handle()));
481}
482
483inline AuthOptions::AuthOptions(blpapi_AuthOptions_t *handle)
484 : d_handle_p(handle)
485{
486}
487
489{
490 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthOptions_duplicate)(
491 &d_handle_p, options.handle()));
492}
493
495{
496 BLPAPI_CALL_UNCHECKED(blpapi_AuthOptions_destroy)(d_handle_p);
497}
498
500{
502 BLPAPI_CALL(blpapi_AuthOptions_copy)(d_handle_p, rhs.handle()));
503
504 return *this;
505}
506
507inline blpapi_AuthOptions_t *AuthOptions::handle() const { return d_handle_p; }
508
509// =======================
510// class AuthUser
511// =======================
512
513inline AuthUser::AuthUser(blpapi_AuthUser_t *handle)
514 : d_handle_p(handle)
515{
516}
517
518inline AuthUser::AuthUser(const AuthUser& user)
519{
520 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthUser_duplicate)(
521 &d_handle_p, user.handle()));
522}
523
525{
526 BLPAPI_CALL_UNCHECKED(blpapi_AuthUser_destroy)(d_handle_p);
527}
528
530{
532 BLPAPI_CALL(blpapi_AuthUser_copy)(d_handle_p, rhs.handle()));
533
534 return *this;
535}
536
538{
539 blpapi_AuthUser_t *handle = NULL;
540
542 BLPAPI_CALL(blpapi_AuthUser_createWithLogonName)(&handle));
543
544 AuthUser user(handle);
545
546 return user;
547}
548
550 const char *propertyName)
551{
552 blpapi_AuthUser_t *handle = NULL;
553
555 BLPAPI_CALL(blpapi_AuthUser_createWithActiveDirectoryProperty)(
556 &handle, propertyName));
557
558 AuthUser user(handle);
559
560 return user;
561}
562
564 const char *userId, const char *ipAddress)
565{
566 blpapi_AuthUser_t *handle = NULL;
567
569 BLPAPI_CALL(blpapi_AuthUser_createWithManualOptions)(
570 &handle, userId, ipAddress));
571
572 AuthUser user(handle);
573
574 return user;
575}
576
577inline const blpapi_AuthUser_t *AuthUser::handle() const { return d_handle_p; }
578
579// ==============================
580// class AuthApplication
581// ==============================
582
583inline AuthApplication::AuthApplication(const char *name)
584{
586 BLPAPI_CALL(blpapi_AuthApplication_create)(&d_handle_p, name));
587}
588
589inline AuthApplication::AuthApplication(blpapi_AuthApplication_t *handle)
590 : d_handle_p(handle)
591{
592}
593
595{
596 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthApplication_duplicate)(
597 &d_handle_p, app.handle()));
598}
599
601{
602 BLPAPI_CALL_UNCHECKED(blpapi_AuthApplication_destroy)(d_handle_p);
603}
604
606{
607 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthApplication_copy)(
608 d_handle_p, rhs.handle()));
609
610 return *this;
611}
612
613inline const blpapi_AuthApplication_t *AuthApplication::handle() const
614{
615 return d_handle_p;
616}
617
618// ========================
619// class AuthToken
620// ========================
621
622inline AuthToken::AuthToken(const char *tokenStr)
623{
625 BLPAPI_CALL(blpapi_AuthToken_create)(&d_handle_p, tokenStr));
626}
627
628inline AuthToken::AuthToken(blpapi_AuthToken_t *handle)
629 : d_handle_p(handle)
630{
631}
632
633inline AuthToken::AuthToken(const AuthToken& token)
634{
635 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthToken_duplicate)(
636 &d_handle_p, token.handle()));
637}
638
640{
641 BLPAPI_CALL_UNCHECKED(blpapi_AuthToken_destroy)(d_handle_p);
642}
643
645{
647 BLPAPI_CALL(blpapi_AuthToken_copy)(d_handle_p, rhs.handle()));
648
649 return *this;
650}
651
652inline const blpapi_AuthToken_t *AuthToken::handle() const
653{
654 return d_handle_p;
655}
656
657} // close namespace blpapi
658} // close namespace BloombergLP
659
660#endif // #ifdef __cplusplus
661#endif // #ifndef INCLUDED_BLPAPI_AUTHOPTIONS
Provide functions for dispatchtbl.
#define BLPAPI_CALL_UNCHECKED(FUNCNAME)
Definition blpapi_call.h:362
#define BLPAPI_CALL(FUNCNAME)
Definition blpapi_call.h:361
Common definitions used by the library.
Defines Exceptions that can be thrown by the blpapi library.
Provide BLPAPI types.
Definition blpapi_authoptions.h:349
AuthApplication(const char *appName)
Definition blpapi_authoptions.h:583
AuthApplication & operator=(const AuthApplication &rhs)
Definition blpapi_authoptions.h:605
const blpapi_AuthApplication_t * handle() const
Definition blpapi_authoptions.h:613
~AuthApplication()
Definition blpapi_authoptions.h:600
AuthOptions & operator=(const AuthOptions &rhs)
Definition blpapi_authoptions.h:499
blpapi_AuthOptions_t * handle() const
Definition blpapi_authoptions.h:507
AuthOptions()
Definition blpapi_authoptions.h:450
~AuthOptions()
Definition blpapi_authoptions.h:494
Definition blpapi_authoptions.h:399
AuthToken & operator=(const AuthToken &rhs)
Definition blpapi_authoptions.h:644
const blpapi_AuthToken_t * handle() const
Definition blpapi_authoptions.h:652
AuthToken(const char *tokenStr)
Definition blpapi_authoptions.h:622
~AuthToken()
Definition blpapi_authoptions.h:639
Definition blpapi_authoptions.h:282
const blpapi_AuthUser_t * handle() const
Definition blpapi_authoptions.h:577
AuthUser & operator=(const AuthUser &rhs)
Definition blpapi_authoptions.h:529
static AuthUser createWithActiveDirectoryProperty(const char *propertyName)
Definition blpapi_authoptions.h:549
static AuthUser createWithLogonName()
Definition blpapi_authoptions.h:537
static AuthUser createWithManualOptions(const char *userId, const char *ipAddress)
Definition blpapi_authoptions.h:563
~AuthUser()
Definition blpapi_authoptions.h:524
AuthUser(blpapi_AuthUser_t *handle)
Definition blpapi_authoptions.h:513
static void throwOnError(int errorCode)
Definition blpapi_exception.h:541
Definition blpapi_abstractsession.h:212
Definition blpapi_abstractsession.h:211