BLPAPI C++ 3.26.6
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
37
38#ifndef INCLUDED_BLPAPI_AUTHOPTIONS
39#define INCLUDED_BLPAPI_AUTHOPTIONS
40
81
82#include <blpapi_call.h>
83#include <blpapi_defs.h>
84#include <blpapi_exception.h>
85#include <blpapi_types.h>
86
87#include <stddef.h>
88
89#ifdef __cplusplus
90extern "C" {
91#endif
92
94
97
110BLPAPI_EXPORT
111int blpapi_AuthOptions_create_default(blpapi_AuthOptions_t **options);
112
129BLPAPI_EXPORT
130int blpapi_AuthOptions_create_forUserMode(
131 blpapi_AuthOptions_t **options, const blpapi_AuthUser_t *user);
132
148BLPAPI_EXPORT
149int blpapi_AuthOptions_create_forAppMode(
150 blpapi_AuthOptions_t **options, const blpapi_AuthApplication_t *app);
151
169BLPAPI_EXPORT
170int blpapi_AuthOptions_create_forUserAndAppMode(blpapi_AuthOptions_t **options,
171 const blpapi_AuthUser_t *user,
172 const blpapi_AuthApplication_t *app);
173
190BLPAPI_EXPORT
191int blpapi_AuthOptions_create_forToken(
192 blpapi_AuthOptions_t **options, const blpapi_AuthToken_t *token);
193
207BLPAPI_EXPORT
208int blpapi_AuthOptions_duplicate(
209 blpapi_AuthOptions_t **options, const blpapi_AuthOptions_t *dup);
210
221BLPAPI_EXPORT
222int blpapi_AuthOptions_copy(
223 blpapi_AuthOptions_t *lhs, const blpapi_AuthOptions_t *rhs);
224
234BLPAPI_EXPORT
235void blpapi_AuthOptions_destroy(blpapi_AuthOptions_t *options);
236
249BLPAPI_EXPORT
250int blpapi_AuthUser_createWithLogonName(blpapi_AuthUser_t **user);
251
267BLPAPI_EXPORT
268int blpapi_AuthUser_createWithActiveDirectoryProperty(
269 blpapi_AuthUser_t **user, const char *propertyName);
270
289BLPAPI_EXPORT
290int blpapi_AuthUser_createWithManualOptions(
291 blpapi_AuthUser_t **user, const char *userId, const char *ipAddress);
292
305BLPAPI_EXPORT
306int blpapi_AuthUser_duplicate(
307 blpapi_AuthUser_t **user, const blpapi_AuthUser_t *dup);
308
319BLPAPI_EXPORT
320int blpapi_AuthUser_copy(blpapi_AuthUser_t *lhs, const blpapi_AuthUser_t *rhs);
321
330BLPAPI_EXPORT
331void blpapi_AuthUser_destroy(blpapi_AuthUser_t *user);
332
348BLPAPI_EXPORT
349int blpapi_AuthApplication_create(
350 blpapi_AuthApplication_t **app, const char *appName);
351
365BLPAPI_EXPORT
366int blpapi_AuthApplication_duplicate(
367 blpapi_AuthApplication_t **app, const blpapi_AuthApplication_t *dup);
368
379BLPAPI_EXPORT
380int blpapi_AuthApplication_copy(
381 blpapi_AuthApplication_t *lhs, const blpapi_AuthApplication_t *rhs);
382
392BLPAPI_EXPORT
393void blpapi_AuthApplication_destroy(blpapi_AuthApplication_t *app);
394
409BLPAPI_EXPORT
410int blpapi_AuthToken_create(blpapi_AuthToken_t **token, const char *tokenStr);
411
425BLPAPI_EXPORT
426int blpapi_AuthToken_duplicate(
427 blpapi_AuthToken_t **token, const blpapi_AuthToken_t *dup);
428
439BLPAPI_EXPORT
440int blpapi_AuthToken_copy(
441 blpapi_AuthToken_t *lhs, const blpapi_AuthToken_t *rhs);
442
451BLPAPI_EXPORT
452void blpapi_AuthToken_destroy(blpapi_AuthToken_t *token);
453
456
457#ifdef __cplusplus
458}
459
460namespace BloombergLP {
461namespace blpapi {
468
469class AuthUser;
470class AuthApplication;
471class AuthToken;
472
473// =================
474// class AuthOptions
475// =================
476
486
487 blpapi_AuthOptions_t *d_handle_p;
488
489 public:
490 AuthOptions();
495
496 AuthOptions(const AuthUser& user);
504
505 AuthOptions(const AuthApplication& app);
509
510 AuthOptions(const AuthUser& user, const AuthApplication& app);
514
515 AuthOptions(const AuthToken& token);
519
520 explicit AuthOptions(blpapi_AuthOptions_t *handle);
524
525 AuthOptions(const AuthOptions& options);
529
530 ~AuthOptions();
534
535 AuthOptions& operator=(const AuthOptions& rhs);
540
542 blpapi_AuthOptions_t *handle() const;
547};
548
549// =======================
550// class AuthUser
551// =======================
552
559class AuthUser {
560
561 blpapi_AuthUser_t *d_handle_p;
562
563 public:
564 explicit AuthUser(blpapi_AuthUser_t *handle);
568
569 AuthUser(const AuthUser& user);
573
574 ~AuthUser();
578
579 AuthUser& operator=(const AuthUser& rhs);
584
590
592 const char *propertyName);
600
602 const char *userId, const char *ipAddress);
609
611 const blpapi_AuthUser_t *handle() const;
616};
617
618// ==============================
619// class AuthApplication
620// ==============================
621
629
630 blpapi_AuthApplication_t *d_handle_p;
631
632 public:
633 explicit AuthApplication(const char *appName);
640
641 explicit AuthApplication(blpapi_AuthApplication_t *handle);
645
650
655
661
663 const blpapi_AuthApplication_t *handle() const;
668};
669
670// ========================
671// class AuthToken
672// ========================
673
681
682 blpapi_AuthToken_t *d_handle_p;
683
684 public:
685 explicit AuthToken(const char *tokenStr);
692
693 explicit AuthToken(blpapi_AuthToken_t *handle);
697
698 AuthToken(const AuthToken& token);
702
703 ~AuthToken();
707
708 AuthToken& operator=(const AuthToken& rhs);
713
715 const blpapi_AuthToken_t *handle() const;
720};
721
724
725// ============================================================================
726// INLINE FUNCTION DEFINITIONS
727// ============================================================================
728
729// =================
730// class AuthOptions
731// =================
732
734{
736 BLPAPI_CALL(blpapi_AuthOptions_create_default)(&d_handle_p));
737}
738
740{
742 BLPAPI_CALL(blpapi_AuthOptions_create_forUserMode)(
743 &d_handle_p, user.handle()));
744}
745
747{
748 ExceptionUtil::throwOnError(BLPAPI_CALL(
749 blpapi_AuthOptions_create_forAppMode)(&d_handle_p, app.handle()));
750}
751
753 const AuthUser& user, const AuthApplication& app)
754{
756 BLPAPI_CALL(blpapi_AuthOptions_create_forUserAndAppMode)(
757 &d_handle_p, user.handle(), app.handle()));
758}
759
761{
762 ExceptionUtil::throwOnError(BLPAPI_CALL(
763 blpapi_AuthOptions_create_forToken)(&d_handle_p, token.handle()));
764}
765
766inline AuthOptions::AuthOptions(blpapi_AuthOptions_t *handle)
767 : d_handle_p(handle)
768{
769}
770
772{
773 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthOptions_duplicate)(
774 &d_handle_p, options.handle()));
775}
776
778{
779 BLPAPI_CALL_UNCHECKED(blpapi_AuthOptions_destroy)(d_handle_p);
780}
781
783{
785 BLPAPI_CALL(blpapi_AuthOptions_copy)(d_handle_p, rhs.handle()));
786
787 return *this;
788}
789
791inline blpapi_AuthOptions_t *AuthOptions::handle() const { return d_handle_p; }
793
794// =======================
795// class AuthUser
796// =======================
797
798inline AuthUser::AuthUser(blpapi_AuthUser_t *handle)
799 : d_handle_p(handle)
800{
801}
802
803inline AuthUser::AuthUser(const AuthUser& user)
804{
805 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthUser_duplicate)(
806 &d_handle_p, user.handle()));
807}
808
810{
811 BLPAPI_CALL_UNCHECKED(blpapi_AuthUser_destroy)(d_handle_p);
812}
813
815{
817 BLPAPI_CALL(blpapi_AuthUser_copy)(d_handle_p, rhs.handle()));
818
819 return *this;
820}
821
823{
824 blpapi_AuthUser_t *handle = NULL;
825
827 BLPAPI_CALL(blpapi_AuthUser_createWithLogonName)(&handle));
828
829 AuthUser user(handle);
830
831 return user;
832}
833
835 const char *propertyName)
836{
837 blpapi_AuthUser_t *handle = NULL;
838
840 BLPAPI_CALL(blpapi_AuthUser_createWithActiveDirectoryProperty)(
841 &handle, propertyName));
842
843 AuthUser user(handle);
844
845 return user;
846}
847
849 const char *userId, const char *ipAddress)
850{
851 blpapi_AuthUser_t *handle = NULL;
852
854 BLPAPI_CALL(blpapi_AuthUser_createWithManualOptions)(
855 &handle, userId, ipAddress));
856
857 AuthUser user(handle);
858
859 return user;
860}
861
863inline const blpapi_AuthUser_t *AuthUser::handle() const { return d_handle_p; }
865
866// ==============================
867// class AuthApplication
868// ==============================
869
870inline AuthApplication::AuthApplication(const char *name)
871{
873 BLPAPI_CALL(blpapi_AuthApplication_create)(&d_handle_p, name));
874}
875
876inline AuthApplication::AuthApplication(blpapi_AuthApplication_t *handle)
877 : d_handle_p(handle)
878{
879}
880
882{
883 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthApplication_duplicate)(
884 &d_handle_p, app.handle()));
885}
886
888{
889 BLPAPI_CALL_UNCHECKED(blpapi_AuthApplication_destroy)(d_handle_p);
890}
891
893{
894 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthApplication_copy)(
895 d_handle_p, rhs.handle()));
896
897 return *this;
898}
899
901inline const blpapi_AuthApplication_t *AuthApplication::handle() const
902{
903 return d_handle_p;
904}
906
907// ========================
908// class AuthToken
909// ========================
910
911inline AuthToken::AuthToken(const char *tokenStr)
912{
914 BLPAPI_CALL(blpapi_AuthToken_create)(&d_handle_p, tokenStr));
915}
916
917inline AuthToken::AuthToken(blpapi_AuthToken_t *handle)
918 : d_handle_p(handle)
919{
920}
921
922inline AuthToken::AuthToken(const AuthToken& token)
923{
924 ExceptionUtil::throwOnError(BLPAPI_CALL(blpapi_AuthToken_duplicate)(
925 &d_handle_p, token.handle()));
926}
927
929{
930 BLPAPI_CALL_UNCHECKED(blpapi_AuthToken_destroy)(d_handle_p);
931}
932
934{
936 BLPAPI_CALL(blpapi_AuthToken_copy)(d_handle_p, rhs.handle()));
937
938 return *this;
939}
940
942inline const blpapi_AuthToken_t *AuthToken::handle() const
943{
944 return d_handle_p;
945}
947
948} // close namespace blpapi
949} // close namespace BloombergLP
950
951#endif // #ifdef __cplusplus
952#endif // #ifndef INCLUDED_BLPAPI_AUTHOPTIONS
Provide functions for dispatchtbl.
Common definitions used by the library.
Defines Exceptions that can be thrown by the blpapi library.
Provide BLPAPI types.
Definition blpapi_authoptions.h:628
AuthApplication(const char *appName)
Definition blpapi_authoptions.h:870
AuthApplication & operator=(const AuthApplication &rhs)
Definition blpapi_authoptions.h:892
~AuthApplication()
Definition blpapi_authoptions.h:887
AuthOptions & operator=(const AuthOptions &rhs)
Definition blpapi_authoptions.h:782
AuthOptions()
Definition blpapi_authoptions.h:733
~AuthOptions()
Definition blpapi_authoptions.h:777
Definition blpapi_authoptions.h:680
AuthToken & operator=(const AuthToken &rhs)
Definition blpapi_authoptions.h:933
AuthToken(const char *tokenStr)
Definition blpapi_authoptions.h:911
~AuthToken()
Definition blpapi_authoptions.h:928
Definition blpapi_authoptions.h:559
AuthUser & operator=(const AuthUser &rhs)
Definition blpapi_authoptions.h:814
static AuthUser createWithActiveDirectoryProperty(const char *propertyName)
Definition blpapi_authoptions.h:834
static AuthUser createWithLogonName()
Definition blpapi_authoptions.h:822
static AuthUser createWithManualOptions(const char *userId, const char *ipAddress)
Definition blpapi_authoptions.h:848
~AuthUser()
Definition blpapi_authoptions.h:809
AuthUser(blpapi_AuthUser_t *handle)
Definition blpapi_authoptions.h:798
static void throwOnError(int errorCode)
Definition blpapi_exception.h:556
Definition blpapi_abstractsession.h:452
Definition blpapi_abstractsession.h:451