Refresh upstream 2.1.0 release
[profile/ivi/libgsignon-glib.git] / libgsignon-glib / signon-internals.h
1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
4  * This file is part of libgsignon-glib
5  *
6  * Copyright (C) 2009-2010 Nokia Corporation.
7  * Copyright (C) 2012 Canonical Ltd.
8  * Copyright (C) 2012 Intel Corporation.
9  *
10  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
11  * Contact: Jussi Laako <jussi.laako@linux.intel.com>
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public License
15  * version 2.1 as published by the Free Software Foundation.
16  *
17  * This library is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25  * 02110-1301 USA
26  */
27
28 #ifndef _SIGNONINTERNALS_H_
29 #define _SIGNONINTERNALS_H_
30
31 #include "signon-security-context.h"
32
33 #ifndef SIGNON_TRACE
34 #define SIGNON_TRACE
35 #endif
36
37 #ifdef SIGNON_TRACE
38     #define DEBUG(format...) g_debug (G_STRLOC ": " format)
39 #else
40     #define DEBUG(...) do {} while (0)
41 #endif
42
43 /*
44  * Common DBUS definitions
45  * */
46 #define SIGNOND_SERVICE_PREFIX     "com.google.code.AccountsSSO.gSingleSignOn"
47 #define SIGNOND_SERVICE            SIGNOND_SERVICE_PREFIX
48
49 #define SIGNOND_DAEMON_OBJECTPATH  "/com/google/code/AccountsSSO/gSingleSignOn"
50 #define SIGNOND_DAEMON_INTERFACE       SIGNOND_SERVICE_PREFIX ".AuthService"
51 #define SIGNOND_IDENTITY_INTERFACE     SIGNOND_SERVICE_PREFIX ".Identity"
52 #define SIGNOND_AUTH_SESSION_INTERFACE SIGNOND_SERVICE_PREFIX ".AuthSession"
53
54 #define SIGNOND_ERR_PREFIX SIGNOND_SERVICE_PREFIX ".Error."
55
56 /*
57  * Common server/client identity info strings
58  * */
59 #define SIGNOND_IDENTITY_INFO_ID                    "Id"
60 #define SIGNOND_IDENTITY_INFO_USERNAME              "UserName"
61 #define SIGNOND_IDENTITY_INFO_SECRET                "Secret"
62 #define SIGNOND_IDENTITY_INFO_STORESECRET           "StoreSecret"
63 #define SIGNOND_IDENTITY_INFO_CAPTION               "Caption"
64 #define SIGNOND_IDENTITY_INFO_REALMS                "Realms"
65 #define SIGNOND_IDENTITY_INFO_AUTHMETHODS           "AuthMethods"
66 #define SIGNOND_IDENTITY_INFO_OWNER                 "Owner"
67 #define SIGNOND_IDENTITY_INFO_ACL                   "ACL"
68 #define SIGNOND_IDENTITY_INFO_TYPE                  "Type"
69 #define SIGNOND_IDENTITY_INFO_REFCOUNT              "RefCount"
70 #define SIGNOND_IDENTITY_INFO_VALIDATED             "Validated"
71 #define SIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET    "UserNameSecret"
72
73 /*
74  * Common server/client sides error names and messages
75  * */
76 #define SIGNOND_UNKNOWN_ERR_NAME SIGNOND_ERR_PREFIX "Unknown"
77 #define SIGNOND_INTERNAL_SERVER_ERR_NAME SIGNOND_ERR_PREFIX "InternalServer"
78 #define SIGNOND_INTERNAL_COMMUNICATION_ERR_NAME \
79     SIGNOND_ERR_PREFIX "InternalCommunication"
80 #define SIGNOND_PERMISSION_DENIED_ERR_NAME \
81     SIGNOND_ERR_PREFIX "PermissionDenied"
82 #define SIGNOND_METHOD_OR_MECHANISM_NOT_ALLOWED_ERR_NAME \
83     SIGNOND_ERR_PREFIX "MethodOrMechanismNotAllowed"
84 #define SIGNOND_ENCRYPTION_FAILED_ERR_NAME \
85     SIGNOND_ERR_PREFIX "EncryptionFailed"
86 #define SIGNOND_METHOD_NOT_KNOWN_ERR_NAME SIGNOND_ERR_PREFIX "MethodNotKnown"
87 #define SIGNOND_SERVICE_NOT_AVAILABLE_ERR_NAME \
88     SIGNOND_ERR_PREFIX "ServiceNotAvailable"
89 #define SIGNOND_INVALID_QUERY_ERR_NAME SIGNOND_ERR_PREFIX "InvalidQuery"
90 #define SIGNOND_METHOD_NOT_AVAILABLE_ERR_NAME \
91     SIGNOND_ERR_PREFIX "MethodNotAvailable"
92 #define SIGNOND_IDENTITY_NOT_FOUND_ERR_NAME \
93     SIGNOND_ERR_PREFIX "IdentityNotFound"
94 #define SIGNOND_STORE_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "StoreFailed"
95 #define SIGNOND_REMOVE_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "RemoveFailed"
96 #define SIGNOND_SIGNOUT_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "SignOutFailed"
97 #define SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME \
98     SIGNOND_ERR_PREFIX "IdentityOperationCanceled"
99 #define SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_NAME \
100     SIGNOND_ERR_PREFIX "CredentialsNotAvailable"
101 #define SIGNOND_REFERENCE_NOT_FOUND_ERR_NAME \
102     SIGNOND_ERR_PREFIX "ReferenceNotFound"
103 #define SIGNOND_MECHANISM_NOT_AVAILABLE_ERR_NAME \
104     SIGNOND_ERR_PREFIX "MechanismNotAvailable"
105 #define SIGNOND_MISSING_DATA_ERR_NAME SIGNOND_ERR_PREFIX "MissingData"
106 #define SIGNOND_INVALID_CREDENTIALS_ERR_NAME \
107     SIGNOND_ERR_PREFIX "InvalidCredentials"
108 #define SIGNOND_NOT_AUTHORIZED_ERR_NAME SIGNOND_ERR_PREFIX "NotAuthorized"
109 #define SIGNOND_WRONG_STATE_ERR_NAME SIGNOND_ERR_PREFIX "WrongState"
110 #define SIGNOND_OPERATION_NOT_SUPPORTED_ERR_NAME \
111     SIGNOND_ERR_PREFIX "OperationNotSupported"
112 #define SIGNOND_NO_CONNECTION_ERR_NAME SIGNOND_ERR_PREFIX "NoConnection"
113 #define SIGNOND_NETWORK_ERR_NAME SIGNOND_ERR_PREFIX "Network"
114 #define SIGNOND_SSL_ERR_NAME SIGNOND_ERR_PREFIX "Ssl"
115 #define SIGNOND_RUNTIME_ERR_NAME SIGNOND_ERR_PREFIX "Runtime"
116 #define SIGNOND_SESSION_CANCELED_ERR_NAME SIGNOND_ERR_PREFIX "SessionCanceled"
117 #define SIGNOND_TIMED_OUT_ERR_NAME SIGNOND_ERR_PREFIX "TimedOut"
118 #define SIGNOND_USER_INTERACTION_ERR_NAME SIGNOND_ERR_PREFIX "UserInteraction"
119 #define SIGNOND_OPERATION_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "OperationFailed"
120 #define SIGNOND_TOS_NOT_ACCEPTED_ERR_NAME SIGNOND_ERR_PREFIX "TOSNotAccepted"
121 #define SIGNOND_FORGOT_PASSWORD_ERR_NAME SIGNOND_ERR_PREFIX "ForgotPassword"
122 #define SIGNOND_INCORRECT_DATE_ERR_NAME SIGNOND_ERR_PREFIX "IncorrectDate"
123 #define SIGNOND_USER_ERROR_ERR_NAME SIGNOND_ERR_PREFIX "User"
124
125
126 #include "signon-identity-info.h"
127
128 G_BEGIN_DECLS
129
130 enum SignonAuthSessionState {
131     SIGNON_AUTH_SESSION_STATE_NOT_STARTED = 0,   /**< No message. */
132     SIGNON_AUTH_SESSION_STATE_RESOLVING_HOST,    /**< Resolving remote server
133                                                       host name. */
134     SIGNON_AUTH_SESSION_STATE_CONNECTING,        /**< Connecting to remote
135                                                       server. */
136     SIGNON_AUTH_SESSION_STATE_SENDING_DATA,      /**< Sending data to remote
137                                                       server. */
138     SIGNON_AUTH_SESSION_STATE_WAITING_REPLY,     /**< Waiting reply from remote
139                                                       server. */
140     SIGNON_AUTH_SESSION_STATE_USER_PENDING,      /**< Waiting response from
141                                                       user. */
142     SIGNON_AUTH_SESSION_STATE_UI_REFRESHING,     /**< Refreshing ui request. */
143     SIGNON_AUTH_SESSION_STATE_PROCESS_PENDING,   /**< Waiting another process
144                                                       to start. */
145     SIGNON_AUTH_SESSION_STATE_STARTED,           /**< Authentication session is
146                                                       started. */
147     SIGNON_AUTH_SESSION_STATE_PROCESS_CANCELING, /**< Canceling.current
148                                                       process. */
149     SIGNON_AUTH_SESSION_STATE_PROCESS_DONE,      /**< Authentication
150                                                       completed. */
151     SIGNON_AUTH_SESSION_STATE_CUSTOM,            /**< Custom message. */
152     SIGNON_AUTH_SESSION_STATE_LAST
153 };
154
155 struct _SignonIdentityInfo
156 {
157     gint id;
158     gchar *username;
159     gchar *secret;
160     gchar *caption;
161     gboolean store_secret;
162     GHashTable *methods;
163     gchar **realms;
164     SignonSecurityContext *owner;
165     SignonSecurityContextList *access_control_list;
166     gint type;
167 };
168
169 G_GNUC_INTERNAL
170 SignonIdentityInfo *
171 signon_identity_info_new_from_variant (GVariant *variant);
172
173 G_GNUC_INTERNAL
174 GVariant *
175 signon_identity_info_to_variant (const SignonIdentityInfo *self);
176
177 G_END_DECLS
178
179 #endif
180