SsoPlugin.h
5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef __SSO_PLUGIN_H__
#define __SSO_PLUGIN_H__
#include "vmsys.h"
#define SSO_PLUGIN_NAME_SIZE 64
#define SSO_PLUGIN_URL_SIZE 256
#define SSO_PLUGIN_ACCESS_TOKEN 512
#define SSO_PLUGIN_REFRESH_TOKEN 256
#define SSO_PLUGIN_SCOPE 128
#define SSO_PLUGIN_EXTENSION 256
#define SSO_PLUGIN_EXT_YAHOO_COOKIE 512
#define SSO_PLUGIN_EXT_YAHOO_CRUMB 256
typedef enum
{
SSO_PLUGIN_OK,
SSO_PLUGIN_UNKNOWN_ERROR = -9999,
SSO_PLUGIN_CONNECTION_FAIL,
SSO_PLUGIN_INCORRECT_ID_PW,
SSO_PLUGIN_NOT_FULL_EMAIL,
} sso_plugin_result;
typedef enum {
SSO_PLUGIN_ICON_45,
SSO_PLUGIN_ICON_32,
SSO_PLUGIN_ICON_24,
SSO_PLUGIN_ICON_20,
SSO_PLUGIN_ICON_TOTAL,
} sso_plugin_icon_enum;
typedef struct sso_plugin_provider
{
VMUINT32 id;
void *icon_data[SSO_PLUGIN_ICON_TOTAL];
VMUINT32 icon_size[SSO_PLUGIN_ICON_TOTAL];
VMWCHAR name[SSO_PLUGIN_NAME_SIZE];
VMWCHAR signup_url[SSO_PLUGIN_URL_SIZE];
} sso_plugin_provider_struct;
typedef enum
{
SSO_PLUGIN_CREDENTIAL_OAUTH,
SSO_PLUGIN_CREDENTIAL_USERPASS,
SSO_PLUGIN_CREDENTIAL_YAHOO,
} sso_plugin_credential_enum;
typedef struct sso_plugin_credential
{
sso_plugin_credential_enum type;
union
{
struct
{
VMCHAR access_token[SSO_PLUGIN_ACCESS_TOKEN];
VMCHAR refresh_token[SSO_PLUGIN_REFRESH_TOKEN];
VMCHAR scope[SSO_PLUGIN_SCOPE];
VMCHAR extension[SSO_PLUGIN_EXTENSION];
} oauth;
struct
{
VMCHAR username[SSO_PLUGIN_NAME_SIZE];
VMCHAR password[SSO_PLUGIN_NAME_SIZE];
} userpass;
struct
{
VMCHAR security_token[SSO_PLUGIN_ACCESS_TOKEN];
VMCHAR ycookie[SSO_PLUGIN_EXT_YAHOO_COOKIE];
VMCHAR tcookie[SSO_PLUGIN_EXT_YAHOO_COOKIE];
VMCHAR crumb[SSO_PLUGIN_EXT_YAHOO_CRUMB];
} yahoo;
} value;
} sso_plugin_credential_struct;
typedef struct sso_plugin_account
{
VMWCHAR *username;
sso_plugin_credential_struct *credential;
} sso_plugin_account_struct;
typedef void (*sso_plugin_account_cb)(VMUINT32 req_id, sso_plugin_result result, sso_plugin_account_struct *account);
typedef void (*sso_plugin_result_cb)(VMUINT32 req_id, sso_plugin_result result);
/**
* @see sso_plugin_manifest
*/
typedef void (*sso_plugin_manifest_func)(sso_plugin_provider_struct *);
/**
* called during bootup for sso plugin discovery
* @param [out] buffer plugin has to fill this buffer with correct data to identify itself
*/
void sso_plugin_manifest(sso_plugin_provider_struct *buffer);
/**
* @see sso_plugin_login
*/
typedef void (*sso_plugin_login_func)(VMUINT32, VMWSTR, VMWSTR, sso_plugin_account_cb);
/**
* show a screen for user to login
* @param [in] req_id identifer provided by caller and must be kept by plugin so that caller can cancel the login process
* @param [in] username username of the account
* @param [in] password password of the account
* @param [in] callback will be called when log-in is done, no matter success or failure
*/
void sso_plugin_login(VMUINT32 req_id, VMWSTR username, VMWSTR password, sso_plugin_account_cb callback);
/**
* @see sso_plugin_logout
*/
typedef void (*sso_plugin_logout_func)(VMUINT32, VMWSTR, sso_plugin_credential_struct *, sso_plugin_result_cb);
/**
* depending on the service provider, might need to do server-side logout
* @param [in] req_id identifer provided by caller and must be kept by plugin so that caller can cancel the login process
* @param [in] username username of the account
* @param [in] credential credential of the account
* @param [in] callback will be called when log-out is done, no matter success or failure
*/
void sso_plugin_logout(VMUINT32 req_id, VMWSTR username, sso_plugin_credential_struct *credential, sso_plugin_result_cb callback);
/**
* @see sso_plugin_refresh
*/
typedef void (*sso_plugin_refresh_func)(VMUINT32, VMWSTR, sso_plugin_credential_struct *, sso_plugin_result_cb);
/**
* refresh access token by using refresh token or extension
* if fails to refresh, prompt user to enter password again to get a new access token
* @param [in] req_id identifer provided by caller and must be kept by plugin so that caller can cancel the login process
* @param [in] username in case of refresh failure, show this read-only username and ask user to enter password again
* @param [in,out] credential tokens maybe updated to new ones or just re-validate on server side
* @param [in] callback will be called when log-out is done, no matter success or failure
*/
void sso_plugin_refresh(VMUINT32 req_id, VMWSTR username, sso_plugin_credential_struct *credential, sso_plugin_result_cb callback);
/**
* @see sso_plugin_cancel
*/
typedef void (*sso_plugin_cancel_func)(VMUINT32);
/**
* cancel the running process identified by req_id
* @param [in] req_id identifer passed along async requests
*/
void sso_plugin_cancel(VMUINT32 req_id);
static S32 sso_check_ready(void);
#endif