Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.2:Staging:F
libsignon-glib
libsignon-glib-2.1.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File libsignon-glib-2.1.obscpio of Package libsignon-glib
07070100000000000081A4000003E800000064000000015BDC2CEA00000756000000000000000000000000000000000000002200000000libsignon-glib-2.1/.gitlab-ci.ymlimage: ubuntu:bionic cache: key: apt-cache paths: - apt-cache/ variables: LIB_PKGS: "meson gtk-doc-tools libglib2.0-dev python3" GIT_PKGS: "gobject-introspection libgirepository1.0-dev python3-gi python-gi-dev valac" COVERAGE_PKGS: "signon-plugin-ssotest check dbus-test-runner lcov gcovr" DAEMON_PKGS: "qt5-qmake qtbase5-dev qtchooser pkg-config libqt5sql5-sqlite doxygen libdbus-1-dev curl" CI_TOOLS_PKGS: "unzip git" GIT_SUBMODULE_STRATEGY: recursive before_script: - export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR - export PKG_CONFIG_PATH=/usr/lib64/pkgconfig - apt-get update -yq && apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -yq $LIB_PKGS $GIT_PKGS - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -yq $COVERAGE_PKGS $DAEMON_PKGS $CI_TOOLS_PKGS - cd .. - git clone https://gitlab.com/accounts-sso/signond.git - cd signond - curl --header "PRIVATE-TOKEN:$PRIVATE_TOKEN" "https://gitlab.com/api/v4/projects/accounts-sso%2Fsignond/jobs/artifacts/master/download?job=build_amd64" -L -o artifacts.zip - unzip artifacts.zip - cd build - make install - cd ../../libsignon-glib build_amd64: stage: build script: - export PYTHON=python3 - meson build -Ddebugging=true -Ddocumentation=true -Db_coverage=true - ninja -C build artifacts: paths: - ./ test_amd64: stage: test script: - ninja -C build test || (cat tests/test-suite.log && /bin/false) - ninja -C build coverage-html - ninja -C build libsignon-glib-doc dependencies: - build_amd64 artifacts: paths: - ./ pages: stage: deploy script: - mkdir public - cp -a build/meson-logs/coveragereport public/coverage - cp -a build/docs/reference/html/* public/ dependencies: - test_amd64 artifacts: paths: - public only: - master 07070100000001000081A4000003E800000064000000015BDC2CEA0000008F000000000000000000000000000000000000001F00000000libsignon-glib-2.1/.gitmodules[submodule "libsignon-glib/interfaces"] path = libsignon-glib/interfaces url = https://gitlab.com/accounts-sso/signon-dbus-specification.git 07070100000002000081A4000003E800000064000000015BDC2CEA0000001C000000000000000000000000000000000000001B00000000libsignon-glib-2.1/AUTHORSalberto.mardegan@nokia.com 07070100000003000081A4000003E800000064000000015BDC2CEA00006742000000000000000000000000000000000000001B00000000libsignon-glib-2.1/COPYING GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. <signature of Ty Coon>, 1 April 1990 Ty Coon, President of Vice That's all there is to it! 07070100000004000081A4000003E800000064000000015BDC2CEA00000D98000000000000000000000000000000000000001800000000libsignon-glib-2.1/NEWSlibsignon-glib NEWS Version 2.0 ----------- * Support new signond 8.60 * New SignonSecurityContext with system and application contexts * Add signon_list_available_mechanisms() method * Remove a couple of obsolete methods * Use the GTask API * Build: switch to Meson build system * Tests: increase code coverage Version 1.15 ------------ * Do not build-depend on signond * Update to the new signond D-Bus api with application context * Create the Vala file at build time * Handle the case where signond objects have been unregistered * Respect thread affinity in callbacks * Fix a memory leak * Tests: make tests more robust Version 1.14 ------------ * Migrate to GTask * Fix memory leaks reported by valgrind * Enable CI in gitlab.com * Build: add test coverage reporting * Build: fix parallel builds and out-of-tree builds * Tests: add a test for signon_auth_session_process_async() * Tests: allow running tests with valgrind Version 1.13 ------------ * Build: don't emit a build error on deprecations * Build: ignore deprecations of GSimpleAsyncResult * pkg-config: remove unused variable Fixes: https://gitlab.com/accounts-sso/libsignon-glib/issues/1 * Tests: do not count on mechanisms being ordered * Introspection: mark ACL and realms as string lists, update Vala bindings Version 1.12 ------------ * Introspection: fix transfer type of some methods * Update VALA bindings Version 1.11 ------------ * Disconnect from signals when the remote AuthSession dies http://code.google.com/p/accounts-sso/issues/detail?id=229 * Avoid unreferencing a NULL GVariant * Fix the linking problem when using check Version 1.10 ------------ * Temporarily disable GTKDOC_CHECK, it tries to write a log to /usr/bin * Tests: do not access invalidated objects * Remove calls to g_type_init() * Doc: mention that Identity::signout() clears password and tokens * Check that NEWS has been updated Version 1.9 ----------- * Invoke the callback when errors occur * Add NOCONFIGURE logic to autogen.sh * Fix the check for pyoverridesdir for python3 * Fix a memory leak Version 1.8 ----------- * Add signon_auth_session_process_async http://code.google.com/p/accounts-sso/issues/detail?id=115 * Fix all memory leaks detected by valgrind * Set ID before invoking the client callback http://code.google.com/p/accounts-sso/issues/detail?id=132 * Make tests optional at configure time http://code.google.com/p/accounts-sso/issues/detail?id=124 * Documentation and build system improvements Version 1.7 ----------- * Support GValues of type GVariant http://code.google.com/p/accounts-sso/issues/detail?id=121 Version 1.6 ----------- * Be Python 3 compatible Version 1.5 ----------- * Add workaround for missing GStrv support in PyGObject * Port from dbus-glib to GDBus Version 1.4 ----------- * Update licence is tests Version 1.3 ----------- * AuthSession: let the callback unreference "self" http://code.google.com/p/accounts-sso/issues/detail?id=121 * Several improvements to tests * Distribute Vala bindings * Add Requires.private to pkg-config files Version 1.2 ----------- * Depend on latest signond * Remove support for old D-Bus API * Improve creation of GError instances * Use dbus-test-runner for running tests if available * Support new signond D-Bus API * Several API reference documentation improvements * Add GObject-Introspection for bindings * Add GType information to enums * Tidy public includes * Define SignonIdentityInfo as a new boxed type 07070100000005000081A4000003E800000064000000015BDC2CEA00000393000000000000000000000000000000000000001D00000000libsignon-glib-2.1/README.mdSingle signon authentication library for GLib applications ========================================================== This project is a library for managing single signon credentials which can be used from GLib applications. It is effectively a GLib binding for the D-Bus API provided by [signond][]. It is part of the accounts-sso project: https://gitlab.com/groups/accounts-sso Dependencies ------------ The project depends on GLib (including GIO and GObject), [signond][] and [check][]. Licence ------- The library is licensed under the GNU LGPL version 2.1. Resources --------- [API reference documentation](http://accounts-sso.gitlab.io/libsignon-glib/) [Source code repository](https://gitlab.com/accounts-sso/libsignon-glib) [Source code coverage](http://accounts-sso.gitlab.io/libsignon-glib/coverage/) [signond]: https://gitlab.com/accounts-sso/signond [check]: https://github.com/libcheck/check07070100000006000041ED000003E800000064000000025BDC2CEA00000000000000000000000000000000000000000000001D00000000libsignon-glib-2.1/build-aux07070100000007000081A4000003E800000064000000015BDC2CEA00000213000000000000000000000000000000000000002E00000000libsignon-glib-2.1/build-aux/gen-error-map.pyimport sys import re header = '''// File generated automatically -- DO NOT EDIT #include <gio/gio.h> #include "signon-errors.h" #include "signon-internals.h" static const GDBusErrorEntry signon_error_entries[] = { ''' footer = ''' }; ''' f = open(sys.argv[2], 'w') f.write(header) regex = re.compile(r'SIGNON_ERROR_([A-Z_0-9]*).*', re.IGNORECASE) for line in open(sys.argv[1], 'r'): if re.search(r'^ *SIGNON_ERROR_*', line): f.write(regex.sub(r'{ SIGNON_ERROR_\1, SIGNOND_\1_ERR_NAME },', line)) f.write(footer) 07070100000008000041ED000003E800000064000000035BDC2CEA00000000000000000000000000000000000000000000001800000000libsignon-glib-2.1/docs07070100000009000081A4000003E800000064000000015BDC2CEA00000014000000000000000000000000000000000000002400000000libsignon-glib-2.1/docs/meson.buildsubdir('reference') 0707010000000A000041ED000003E800000064000000025BDC2CEA00000000000000000000000000000000000000000000002200000000libsignon-glib-2.1/docs/reference0707010000000B000081A4000003E800000064000000015BDC2CEA00000DB0000000000000000000000000000000000000003A00000000libsignon-glib-2.1/docs/reference/libsignon-glib-docs.xml<?xml version="1.0"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [ <!ENTITY version SYSTEM "version.xml"> ]> <book id="index" xmlns:xi="http://www.w3.org/2003/XInclude"> <bookinfo> <title>libsignon-glib Reference Manual</title> <releaseinfo> This document is for libsignon-glib, version &version;. The latest version of this documentation can be built from the source code at <ulink role="online-location" url="https://gitlab.com/accounts-sso/libsignon-glib">https://gitlab.com/accounts-sso/libsignon-glib</ulink>. </releaseinfo> </bookinfo> <part id="libsignon-glib-overview"> <title>libsignon-glib Overview</title> <partintro> <para> libsignon-glib provides authorization and authentication management for GLib applications. </para> </partintro> </part> <part id="libsignon-glib-objects"> <title>libsignon-glib Objects</title> <chapter id="object-tree"> <title>Object Hierarchy</title> <xi:include href="xml/tree_index.sgml"/> </chapter> <chapter id="credential-management"> <title>Credential management</title> <xi:include href="xml/signon-auth-service.xml"/> <xi:include href="xml/signon-auth-session.xml"/> <xi:include href="xml/signon-errors.xml"/> <xi:include href="xml/signon-identity.xml"/> <xi:include href="xml/signon-identity-info.xml"/> <xi:include href="xml/signon-security-context.xml"/> </chapter> </part> <part id="signond-dbus-api"> <title>signond D-Bus API</title> <partintro> <para> The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. </para> </partintro> <xi:include href="../../libsignon-glib/sso-auth-service-gen-doc-com.google.code.AccountsSSO.SingleSignOn.AuthService.xml"/> <xi:include href="../../libsignon-glib/sso-auth-session-gen-doc-com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml"/> <xi:include href="../../libsignon-glib/sso-identity-gen-doc-com.google.code.AccountsSSO.SingleSignOn.Identity.xml"/> </part> <part id="migrating"> <title>Migrating from Previous Versions of libsignon-glib</title> <partintro> <para> This part describes what you need to change in programs which use older versions of libsignon-glib so that they can use the new features. </para> </partintro> <xi:include href="xml/migrating-1to2.xml" /> </part> <part id="appendices"> <title>Appendices</title> <index id="api-index-full"> <title>API Index</title> <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include> </index> <index id="api-index-deprecated" role="deprecated"> <title>Index of deprecated symbols</title> <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include> </index> <index id="api-index-2-0" role="2.0"> <title>Index of new symbols in 2.0</title> <xi:include href="xml/api-index-2.0.xml"><xi:fallback /></xi:include> </index> <index id="api-index-1-8" role="1.8"> <title>Index of new symbols in 1.8</title> <xi:include href="xml/api-index-1.8.xml"><xi:fallback /></xi:include> </index> <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> </part> </book> 0707010000000C000081A4000003E800000064000000015BDC2CEA00000F32000000000000000000000000000000000000003E00000000libsignon-glib-2.1/docs/reference/libsignon-glib-sections.txt<SECTION> <FILE>signon-auth-service</FILE> <TITLE>SignonAuthService</TITLE> SignonAuthService signon_auth_service_new signon_auth_service_get_mechanisms signon_auth_service_get_mechanisms_finish signon_auth_service_get_mechanisms_sync signon_auth_service_get_methods signon_auth_service_get_methods_finish signon_auth_service_get_methods_sync <SUBSECTION Private> SignonAuthServiceClass SignonAuthServicePrivate <SUBSECTION Standard> SIGNON_AUTH_SERVICE SIGNON_AUTH_SERVICE_CLASS SIGNON_AUTH_SERVICE_GET_CLASS SIGNON_IS_AUTH_SERVICE SIGNON_IS_AUTH_SERVICE_CLASS SIGNON_TYPE_AUTH_SERVICE signon_auth_service_get_type </SECTION> <SECTION> <FILE>signon-auth-session</FILE> <TITLE>SignonAuthSession</TITLE> SIGNON_SESSION_DATA_CAPTION SIGNON_SESSION_DATA_PROXY SIGNON_SESSION_DATA_REALM SIGNON_SESSION_DATA_RENEW_TOKEN SIGNON_SESSION_DATA_SECRET SIGNON_SESSION_DATA_TIMEOUT SIGNON_SESSION_DATA_UI_POLICY SIGNON_SESSION_DATA_USERNAME SIGNON_SESSION_DATA_WINDOW_ID SignonAuthSession SignonSessionDataUiPolicy signon_auth_session_new signon_auth_session_cancel signon_auth_session_get_method signon_auth_session_process signon_auth_session_process_finish <SUBSECTION Private> SignonAuthSessionClass SignonAuthSessionPrivate SIGNON_DEPRECATED SIGNON_DEPRECATED_FOR G_DEPRECATED G_DEPRECATED_FOR <SUBSECTION Standard> SIGNON_AUTH_SESSION SIGNON_AUTH_SESSION_CLASS SIGNON_AUTH_SESSION_GET_CLASS SIGNON_IS_AUTH_SESSION SIGNON_IS_AUTH_SESSION_CLASS SIGNON_TYPE_AUTH_SESSION SIGNON_TYPE_SESSION_DATA_UI_POLICY signon_auth_session_get_type signon_session_data_ui_policy_get_type </SECTION> <SECTION> <FILE>signon-errors</FILE> SignonError <SUBSECTION Private> signon_error_quark <SUBSECTION Standard> SIGNON_ERROR SIGNON_TYPE_ERROR signon_error_get_type </SECTION> <SECTION> <FILE>signon-identity</FILE> <TITLE>SignonIdentity</TITLE> SignonIdentity signon_identity_new signon_identity_new_from_db signon_identity_create_session signon_identity_get_last_error signon_identity_get_id signon_identity_query_info signon_identity_query_info_finish signon_identity_store_info signon_identity_store_info_finish signon_identity_verify_secret signon_identity_verify_secret_finish signon_identity_sign_out signon_identity_sign_out_finish signon_identity_remove signon_identity_remove_finish <SUBSECTION Private> SignonIdentityClass SignonIdentityPrivate <SUBSECTION Standard> SIGNON_IDENTITY SIGNON_IDENTITY_CLASS SIGNON_IDENTITY_GET_CLASS SIGNON_IS_IDENTITY SIGNON_IS_IDENTITY_CLASS SIGNON_TYPE_IDENTITY signon_identity_get_type </SECTION> <SECTION> <FILE>signon-identity-info</FILE> <TITLE>SignonIdentityInfo</TITLE> SignonIdentityInfo SignonIdentityType signon_identity_info_new signon_identity_info_copy signon_identity_info_free signon_identity_info_add_access_control signon_identity_info_get_access_control_list signon_identity_info_get_caption signon_identity_info_get_id signon_identity_info_get_identity_type signon_identity_info_get_methods signon_identity_info_get_realms signon_identity_info_get_storing_secret signon_identity_info_get_username signon_identity_info_remove_method signon_identity_info_set_access_control_list signon_identity_info_set_caption signon_identity_info_set_identity_type signon_identity_info_set_method signon_identity_info_set_realms signon_identity_info_set_secret signon_identity_info_set_username <SUBSECTION Standard> SIGNON_TYPE_IDENTITY_TYPE signon_identity_info_get_type </SECTION> <SECTION> <FILE>signon-security-context</FILE> <TITLE>SignonSecurityContext</TITLE> SignonSecurityContext signon_security_context_new signon_security_context_new_from_values signon_security_context_copy signon_security_context_free signon_security_context_get_application_context signon_security_context_get_system_context signon_security_context_set_application_context signon_security_context_set_system_context <SUBSECTION Standard> signon_security_context_get_type </SECTION> 0707010000000D000081A4000003E800000064000000015BDC2CEA000006B9000000000000000000000000000000000000002E00000000libsignon-glib-2.1/docs/reference/meson.buildversion_data = configuration_data() version_data.set('PACKAGE_VERSION', meson.project_version()) configure_file( input: 'version.xml.in', output: '@BASENAME@', configuration: version_data, ) glib_prefix = glib_dep.get_pkgconfig_variable('prefix') glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html') #FIXME: requires Meson 0.46 doc_content_files = [] if (meson.version().version_compare('>=0.46')) doc_content_files += dbus_auth_service_gen[2] doc_content_files += dbus_auth_session_gen[2] doc_content_files += dbus_identity_gen[2] endif gnome.gtkdoc( meson.project_name(), main_xml: meson.project_name() + '-docs.xml', src_dir: libsignon_glib_dir, dependencies: libsignon_glib_dep, ignore_headers: [ 'signon-auth-session-client-glib-gen.h', 'signon-client-glib-gen.h', 'signon-identity-glib-gen.h', 'signon-internals.h', 'signon-proxy.h', 'signon-utils.h', 'signon-marshal.h', 'sso-auth-service-gen.h', 'sso-auth-service.h', 'sso-auth-session-gen.h', 'sso-identity-gen.h', ], scan_args: [ '--rebuild-types', '--deprecated-guards="SIGNON_DISABLE_DEPRECATED"', ], mkdb_args: [ '--name-space=signon', ], gobject_typesfile: [ 'libsignon-glib.types', ], content_files: doc_content_files, expand_content_files: files( 'migrating-1to2.xml' ), fixxref_args: [ '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')), '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')), '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')), ], install: true, ) 0707010000000E000081A4000003E800000064000000015BDC2CEA00000EA0000000000000000000000000000000000000003500000000libsignon-glib-2.1/docs/reference/migrating-1to2.xml<?xml version="1.0"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> ]> <chapter id="signon-migrating-1-to-2"> <title>Migrating from libsignon-glib 1.x to libsignon-glib 2.x</title> <para> The whole API has been reworked to be easily usable with the GObject Introspection. It now fully uses the #GTask API internally and provides the expected asynchronous functions instead of relying on callbacks. </para> <para> This helps to keep the objects lifecycle sane across the projects. But it required some invasive changes in the API. </para> <section> <title>Changes in #SignonAuthService</title> <para> signon_auth_service_query_mechanisms() has been changed into signon_auth_service_get_mechanisms(). There is no more custom callback to use, only the #GAsyncResult API. Use signon_auth_service_get_mechanisms_finish() in your #GAsyncReadyCallback to get the mechanisms. </para> <para> In a same manner signon_auth_service_query_methods() has been changed to signon_auth_service_get_methods(). </para> <para> There are now synchronous methods to get the methods and mechanisms. </para> </section> <section> <title>Changes in #SignonAuthSession</title> <para> The long deprecated signon_auth_session_process() has been removed and the signon_auth_session_process_async() method has been renamed to signon_auth_session_process() as asynchronous methods are the default way to use this API. </para> <para> signon_auth_session_query_available_mechanisms() has been removed and can be replaced by signon_auth_service_get_mechanisms() with a manual filtering if needed. </para> </section> <section> <title>Changes in #SignonIdentity</title> <para> signon_identity_store_credentials_with_args() has been completely removed, only signon_identity_store_info() should be used. </para> <para> signon_identity_store_credentials_with_info() has been renamed to signon_identity_store_info() as #SignonIdentityInfo is the only way to get and set the identity informations. </para> <para> signon_identity_add_reference() and signon_identity_remove_reference() have been completely removed without replacement. </para> <para> The "id" property is now read-only and only settable at construction time. There is a new signon_identity_get_id() method to easily get the value of the property. The object now notifies when the property has changed with a property signal emition. </para> <para> The "signout" signal has been renamed to #SignonIdentity::signed-out to be more descriptive and avoid symbol collisions with the signon_identity_sign_out() method. </para> <para> The signon_identity_signout() has been renamed to signon_identity_sign_out() to avoid symbol collisions with the "signout" signal. </para> <para> All the methods have been modified to use the #GAsyncResult API. Use *_finish() in your #GAsyncReadyCallback to get the result of the operation. </para> <para> signon_identity_info_get_access_control_list() and signon_identity_info_set_access_control_list() now make use of the new #SignonSecurityContext structure that replaces the simple security context string. </para> </section> </chapter> 0707010000000F000081A4000003E800000064000000015BDC2CEA00000012000000000000000000000000000000000000003100000000libsignon-glib-2.1/docs/reference/version.xml.in@PACKAGE_VERSION@ 07070100000010000041ED000003E800000064000000035BDC2CEA00000000000000000000000000000000000000000000002200000000libsignon-glib-2.1/libsignon-glib07070100000011000081A4000003E800000064000000015BDC2CEA0000001D000000000000000000000000000000000000003600000000libsignon-glib-2.1/libsignon-glib/Signon-1.0.metadata*.*.cancellable default=null 07070100000012000081A4000003E800000064000000015BDC2CEA000013D2000000000000000000000000000000000000005B00000000libsignon-glib-2.1/libsignon-glib/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <!-- com.google.code.AccountsSSO.SingleSignOn.AuthService: @short_description: Manages Signon identities. The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. Query information on available authentication methods and mechanisms, as well as create identities and authentication sessions. --> <interface name="com.google.code.AccountsSSO.SingleSignOn.AuthService"> <!-- registerNewIdentity: @short_description: Create a new Identity. @applicationContext: the application security context @objectPath: the D-Bus object path of the new Identity Create a new (empty) Identity in the Signon database. --> <method name="registerNewIdentity"> <arg name="applicationContext" type="s" direction="in"/> <arg name="objectPath" type="o" direction="out"/> </method> <!-- getIdentity: @short_description: Get an Identity from the Signon database. @id: the ID of the Identity in the Signon database @applicationContext: the application security context @objectPath: the D-Bus object path for the Identity @identityData: the information associated with the Identity Get an Identity from the Signon database, creating it if it does not exist. --> <method name="getIdentity"> <arg name="id" type="u" direction="in"/> <arg name="applicationContext" type="s" direction="in"/> <arg name="objectPath" type="o" direction="out"/> <arg name="identityData" type="a{sv}" direction="out"/> </method> <!-- getAuthSessionObjectPath: @short_description: Get a D-Bus object path for an AuthSession. @path: the D-Bus object path @id: ID to use for the new AuthSession @applicationContext: the application security context @type: the authentication method to use for the new AuthSession Return a D-Bus object path for a newly-created AuthSession. --> <method name="getAuthSessionObjectPath"> <arg name="path" type="o" direction="out"/> <arg name="id" type="u" direction="in"/> <arg name="applicationContext" type="s" direction="in"/> <arg name="type" type="s" direction="in"/> </method> <!-- queryMethods: @short_description: List the available authentication methods. @methods: an array of the available authentication methods Query the list of all available authentication methods. --> <method name="queryMethods"> <arg name="methods" type="as" direction="out"/> <!-- queryMechanisms: @short_description: List the available authentication mechanisms. @mechanisms: an array of the available authentication mechanisms @method: the authentication method for which to query the available mechanisms Query the list of available authentication mechanisms for a given authentication method. --> </method> <method name="queryMechanisms"> <arg name="mechanisms" type="as" direction="out"/> <arg name="method" type="s" direction="in"/> </method> <!-- queryIdentities: @short_description: Request an array of stored identities. @filter: the filter to apply to the returned identities @applicationContext: the application security context @identites: the list of stored identities Request an array of identities which are stored in the Signon database. --> <method name="queryIdentities"> <arg name="filter" type="a{sv}" direction="in"/> <arg name="applicationContext" type="s" direction="in"/> <arg name="identities" type="aa{sv}" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> </method> <!-- clear: @short_description: Remove all identities from the Signon database. @success: whether the clear succeeded Clear the Signon database by removing all stored identities. --> <method name="clear"> <arg name="success" type="b" direction="out"/> </method> <!-- backupStarts: @short_description: TODO TODO --> <method name="backupStarts"> <arg type="y" direction="out"/> </method> <!-- backupFinished: @short_description: TODO TODO --> <method name="backupFinished"> <arg type="y" direction="out"/> </method> <!-- restoreStarts: @short_description: TODO TODO --> <method name="restoreStarts"> <arg type="y" direction="out"/> </method> <!-- restoreFinished: @short_description: TODO TODO --> <method name="restoreFinished"> <arg type="y" direction="out"/> </method> </interface> </node> 07070100000013000081A4000003E800000064000000015BDC2CEA00000ECC000000000000000000000000000000000000005B00000000libsignon-glib-2.1/libsignon-glib/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <!-- com.google.code.AccountsSSO.SingleSignOn.AuthSession: @short_description: An authentication session for an Identity. The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. Handle the client authentication process. --> <interface name="com.google.code.AccountsSSO.SingleSignOn.AuthSession"> <!-- stateChanged: @short_description: Emitted when the authentication state changes. @state: the current state of the AuthSession @message: a message associated with the state change Emitted when the current authentication state changed, such as when the Ideneity was signed out. --> <signal name="stateChanged"> <arg name="state" type="i" direction="out"/> <arg name="message" type="s" direction="out"/> </signal> <!-- unregistered: @short_description: Emitted when the AuthSession is removed. Emitted when the AuthSession is removed or destroyed, such as when using objectUnref. --> <signal name="unregistered"> </signal> <!-- queryAvailableMechanisms: @short_description: List the available authentication mechanisms for this AuthSession @mechanisms: the available authentication mechanisms @wantedMechanisms: the desired authentication mechanisms Query the available authentication mechanisms for this AuthSession. The result will be the intersection of the desired authentication mechanisms and those that are supported by the AuthSession. --> <method name="queryAvailableMechanisms"> <arg name="mechanisms" type="as" direction="out"/> <arg name="wantedMechanisms" type="as" direction="in"/> </method> <!-- process: @short_description: Perform one step of the authentication process. @sessionDataVa: the returned session data parameters @sessionDataVa: additional session data parameters @mechanism: the authentication mechanism to use Using the available parameters in the Identity or @sessionDataVa, start the authentication process by passing the parameters to the authentication plugin. --> <method name="process"> <arg name="sessionData" type="a{sv}" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> <arg name="sessionDataVa" type="a{sv}" direction="in"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> <arg name="mechanism" type="s" direction="in"/> </method> <!-- cancel: @short_description: Cancel the authentication session. Cancel the current authentication session --> <method name="cancel"> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <!-- setId: @short_description: Set the ID of the AuthSession. @id: the ID to set Set the ID of the AuthSession. --> <method name="setId"> <arg name="id" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <!-- objectUnref: @short_description: Remove the AuthSession. Forcibly remove the AuthSession. --> <method name="objectUnref"> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> <annotation name="org.freedesktop.DBus.Deprecated" value="true"/> </method> </interface> </node> 07070100000014000081A4000003E800000064000000015BDC2CEA0000134D000000000000000000000000000000000000005800000000libsignon-glib-2.1/libsignon-glib/com.google.code.AccountsSSO.SingleSignOn.Identity.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <!-- com.google.code.AccountsSSO.SingleSignOn.Identity: @short_description: Representation of a single identity. The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. A single credential stored in the Signon database. --> <interface name="com.google.code.AccountsSSO.SingleSignOn.Identity"> <!-- unregistered: @short_description: Emitted when the identity is removed Emitted when the Identity is removed from the Signon database. --> <signal name="unregistered"> </signal> <!-- infoUpdated: @short_description: Emitted when the Identity information has been updated. @type: the type of update that occurred Emitted when credentials information has been updated is the Signon database, such as when the credentials were updated or removed, or when the identity was signed out. --> <signal name="infoUpdated"> <arg name="type" type="i" direction="out"/> </signal> <!-- requestCredentialsUpdate: @short_description: Request that the user enters a new (updated) secret. @id: the ID of the Identity @message: message to be shown to the user Request that the user enters a new secret, which is then stored in the Signon database. --> <method name="requestCredentialsUpdate"> <arg name="id" type="u" direction="out"/> <arg name="message" type="s" direction="in"/> </method> <!-- getInfo: @short_description: Fetch additional information about the Identity. @info: a dictionary of additional information Fetch a large amount of additional information on the Identity, such as the username, type, method and so on. --> <method name="getInfo"> <arg name="info" type="a{sv}" direction="out"/> </method> <!-- verifyUser: @short_description: Verify the secret against a user-supplied secret. @valid: whether the supplied secret is valid @params: parameters to pass to the authentication plugin Request that the user enters a secret, and verify that against the secret stored in the Signon database. --> <method name="verifyUser"> <arg name="valid" type="b" direction="out"/> <arg name="params" type="a{sv}" direction="in"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="QVariantMap"/> </method> <!-- verifySecret: @short_description: Verify that the secret is valid. @valid: whether the secret is valid @secret: the secret to verify Verifies that the supplied secret is valid by comparing it to the secret stored in the Signon database. --> <method name="verifySecret"> <arg name="valid" type="b" direction="out"/> <arg name="secret" type="s" direction="in"/> </method> <!-- remove: @short_description: Remove the Identity. Remove the identity from the Signon database. --> <method name="remove"> </method> <!-- signOut: @short_description: Sign out the identity. Close all authentication sessions for the identity. --> <method name="signOut"> <arg type="b" direction="out"/> </method> <!-- store: @short_description: Store credentials in the identity. @id: a numeric ID for the identity in the database @info: information to store in the Identity Store the given credentials information in the identity, returning a numeric ID for the identity in the Signon database. --> <method name="store"> <arg name="id" type="u" direction="out"/> <arg name="info" type="a{sv}" direction="in"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="QVariantMap"/> </method> <!-- addReference: @short_description: Add a reference to the Identity. @id: the ID of the reference in the database @reference: a named reference to add Add a named reference to the Identity. --> <method name="addReference"> <arg name="id" type="i" direction="out"/> <arg name="reference" type="s" direction="in"/> </method> <!-- removeReference: @short_description: Remove a reference from the Identity. @id: the ID of the reference in the database @reference: a named reference to removed Remove a named reference from the Identity. --> <method name="removeReference"> <arg name="id" type="i" direction="out"/> <arg name="reference" type="s" direction="in"/> </method> </interface> </node> 07070100000015000041ED000003E800000064000000025BDC2CEA00000000000000000000000000000000000000000000002D00000000libsignon-glib-2.1/libsignon-glib/interfaces07070100000016000081A4000003E800000064000000015BDC2CEA00000276000000000000000000000000000000000000003700000000libsignon-glib-2.1/libsignon-glib/interfaces/README.mdSignon DBus Specification ========================= This repository contains the common Signon specification used across all projects > This project is made to allow anyone to chose the wanted daemon implementation. > Any library should work with any daemon. Content ------- * [com.google.code.AccountsSSO.SingleSignOn.AuthService.xml](com.google.code.AccountsSSO.SingleSignOn.AuthService.xml) * [com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml](com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml) * [com.google.code.AccountsSSO.SingleSignOn.Identity.xml](com.google.code.AccountsSSO.SingleSignOn.Identity.xml) 07070100000017000081A4000003E800000064000000015BDC2CEA000013D2000000000000000000000000000000000000006600000000libsignon-glib-2.1/libsignon-glib/interfaces/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <!-- com.google.code.AccountsSSO.SingleSignOn.AuthService: @short_description: Manages Signon identities. The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. Query information on available authentication methods and mechanisms, as well as create identities and authentication sessions. --> <interface name="com.google.code.AccountsSSO.SingleSignOn.AuthService"> <!-- registerNewIdentity: @short_description: Create a new Identity. @applicationContext: the application security context @objectPath: the D-Bus object path of the new Identity Create a new (empty) Identity in the Signon database. --> <method name="registerNewIdentity"> <arg name="applicationContext" type="s" direction="in"/> <arg name="objectPath" type="o" direction="out"/> </method> <!-- getIdentity: @short_description: Get an Identity from the Signon database. @id: the ID of the Identity in the Signon database @applicationContext: the application security context @objectPath: the D-Bus object path for the Identity @identityData: the information associated with the Identity Get an Identity from the Signon database, creating it if it does not exist. --> <method name="getIdentity"> <arg name="id" type="u" direction="in"/> <arg name="applicationContext" type="s" direction="in"/> <arg name="objectPath" type="o" direction="out"/> <arg name="identityData" type="a{sv}" direction="out"/> </method> <!-- getAuthSessionObjectPath: @short_description: Get a D-Bus object path for an AuthSession. @path: the D-Bus object path @id: ID to use for the new AuthSession @applicationContext: the application security context @type: the authentication method to use for the new AuthSession Return a D-Bus object path for a newly-created AuthSession. --> <method name="getAuthSessionObjectPath"> <arg name="path" type="o" direction="out"/> <arg name="id" type="u" direction="in"/> <arg name="applicationContext" type="s" direction="in"/> <arg name="type" type="s" direction="in"/> </method> <!-- queryMethods: @short_description: List the available authentication methods. @methods: an array of the available authentication methods Query the list of all available authentication methods. --> <method name="queryMethods"> <arg name="methods" type="as" direction="out"/> <!-- queryMechanisms: @short_description: List the available authentication mechanisms. @mechanisms: an array of the available authentication mechanisms @method: the authentication method for which to query the available mechanisms Query the list of available authentication mechanisms for a given authentication method. --> </method> <method name="queryMechanisms"> <arg name="mechanisms" type="as" direction="out"/> <arg name="method" type="s" direction="in"/> </method> <!-- queryIdentities: @short_description: Request an array of stored identities. @filter: the filter to apply to the returned identities @applicationContext: the application security context @identites: the list of stored identities Request an array of identities which are stored in the Signon database. --> <method name="queryIdentities"> <arg name="filter" type="a{sv}" direction="in"/> <arg name="applicationContext" type="s" direction="in"/> <arg name="identities" type="aa{sv}" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> </method> <!-- clear: @short_description: Remove all identities from the Signon database. @success: whether the clear succeeded Clear the Signon database by removing all stored identities. --> <method name="clear"> <arg name="success" type="b" direction="out"/> </method> <!-- backupStarts: @short_description: TODO TODO --> <method name="backupStarts"> <arg type="y" direction="out"/> </method> <!-- backupFinished: @short_description: TODO TODO --> <method name="backupFinished"> <arg type="y" direction="out"/> </method> <!-- restoreStarts: @short_description: TODO TODO --> <method name="restoreStarts"> <arg type="y" direction="out"/> </method> <!-- restoreFinished: @short_description: TODO TODO --> <method name="restoreFinished"> <arg type="y" direction="out"/> </method> </interface> </node> 07070100000018000081A4000003E800000064000000015BDC2CEA00000ECC000000000000000000000000000000000000006600000000libsignon-glib-2.1/libsignon-glib/interfaces/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <!-- com.google.code.AccountsSSO.SingleSignOn.AuthSession: @short_description: An authentication session for an Identity. The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. Handle the client authentication process. --> <interface name="com.google.code.AccountsSSO.SingleSignOn.AuthSession"> <!-- stateChanged: @short_description: Emitted when the authentication state changes. @state: the current state of the AuthSession @message: a message associated with the state change Emitted when the current authentication state changed, such as when the Ideneity was signed out. --> <signal name="stateChanged"> <arg name="state" type="i" direction="out"/> <arg name="message" type="s" direction="out"/> </signal> <!-- unregistered: @short_description: Emitted when the AuthSession is removed. Emitted when the AuthSession is removed or destroyed, such as when using objectUnref. --> <signal name="unregistered"> </signal> <!-- queryAvailableMechanisms: @short_description: List the available authentication mechanisms for this AuthSession @mechanisms: the available authentication mechanisms @wantedMechanisms: the desired authentication mechanisms Query the available authentication mechanisms for this AuthSession. The result will be the intersection of the desired authentication mechanisms and those that are supported by the AuthSession. --> <method name="queryAvailableMechanisms"> <arg name="mechanisms" type="as" direction="out"/> <arg name="wantedMechanisms" type="as" direction="in"/> </method> <!-- process: @short_description: Perform one step of the authentication process. @sessionDataVa: the returned session data parameters @sessionDataVa: additional session data parameters @mechanism: the authentication mechanism to use Using the available parameters in the Identity or @sessionDataVa, start the authentication process by passing the parameters to the authentication plugin. --> <method name="process"> <arg name="sessionData" type="a{sv}" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> <arg name="sessionDataVa" type="a{sv}" direction="in"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> <arg name="mechanism" type="s" direction="in"/> </method> <!-- cancel: @short_description: Cancel the authentication session. Cancel the current authentication session --> <method name="cancel"> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <!-- setId: @short_description: Set the ID of the AuthSession. @id: the ID to set Set the ID of the AuthSession. --> <method name="setId"> <arg name="id" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <!-- objectUnref: @short_description: Remove the AuthSession. Forcibly remove the AuthSession. --> <method name="objectUnref"> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> <annotation name="org.freedesktop.DBus.Deprecated" value="true"/> </method> </interface> </node> 07070100000019000081A4000003E800000064000000015BDC2CEA0000134D000000000000000000000000000000000000006300000000libsignon-glib-2.1/libsignon-glib/interfaces/com.google.code.AccountsSSO.SingleSignOn.Identity.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <!-- com.google.code.AccountsSSO.SingleSignOn.Identity: @short_description: Representation of a single identity. The signond D-Bus APIs are unstable, subject to change and should not be used by client applications, which should use libsignon-glib or libsignon-qt instead. A single credential stored in the Signon database. --> <interface name="com.google.code.AccountsSSO.SingleSignOn.Identity"> <!-- unregistered: @short_description: Emitted when the identity is removed Emitted when the Identity is removed from the Signon database. --> <signal name="unregistered"> </signal> <!-- infoUpdated: @short_description: Emitted when the Identity information has been updated. @type: the type of update that occurred Emitted when credentials information has been updated is the Signon database, such as when the credentials were updated or removed, or when the identity was signed out. --> <signal name="infoUpdated"> <arg name="type" type="i" direction="out"/> </signal> <!-- requestCredentialsUpdate: @short_description: Request that the user enters a new (updated) secret. @id: the ID of the Identity @message: message to be shown to the user Request that the user enters a new secret, which is then stored in the Signon database. --> <method name="requestCredentialsUpdate"> <arg name="id" type="u" direction="out"/> <arg name="message" type="s" direction="in"/> </method> <!-- getInfo: @short_description: Fetch additional information about the Identity. @info: a dictionary of additional information Fetch a large amount of additional information on the Identity, such as the username, type, method and so on. --> <method name="getInfo"> <arg name="info" type="a{sv}" direction="out"/> </method> <!-- verifyUser: @short_description: Verify the secret against a user-supplied secret. @valid: whether the supplied secret is valid @params: parameters to pass to the authentication plugin Request that the user enters a secret, and verify that against the secret stored in the Signon database. --> <method name="verifyUser"> <arg name="valid" type="b" direction="out"/> <arg name="params" type="a{sv}" direction="in"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="QVariantMap"/> </method> <!-- verifySecret: @short_description: Verify that the secret is valid. @valid: whether the secret is valid @secret: the secret to verify Verifies that the supplied secret is valid by comparing it to the secret stored in the Signon database. --> <method name="verifySecret"> <arg name="valid" type="b" direction="out"/> <arg name="secret" type="s" direction="in"/> </method> <!-- remove: @short_description: Remove the Identity. Remove the identity from the Signon database. --> <method name="remove"> </method> <!-- signOut: @short_description: Sign out the identity. Close all authentication sessions for the identity. --> <method name="signOut"> <arg type="b" direction="out"/> </method> <!-- store: @short_description: Store credentials in the identity. @id: a numeric ID for the identity in the database @info: information to store in the Identity Store the given credentials information in the identity, returning a numeric ID for the identity in the Signon database. --> <method name="store"> <arg name="id" type="u" direction="out"/> <arg name="info" type="a{sv}" direction="in"/> <annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="QVariantMap"/> </method> <!-- addReference: @short_description: Add a reference to the Identity. @id: the ID of the reference in the database @reference: a named reference to add Add a named reference to the Identity. --> <method name="addReference"> <arg name="id" type="i" direction="out"/> <arg name="reference" type="s" direction="in"/> </method> <!-- removeReference: @short_description: Remove a reference from the Identity. @id: the ID of the reference in the database @reference: a named reference to removed Remove a named reference from the Identity. --> <method name="removeReference"> <arg name="id" type="i" direction="out"/> <arg name="reference" type="s" direction="in"/> </method> </interface> </node> 0707010000001A000081A4000003E800000064000000015BDC2CEA00000029000000000000000000000000000000000000003500000000libsignon-glib-2.1/libsignon-glib/libsignon-glib.map{ global: signon_*; local: *; }; 0707010000001B000081A4000003E800000064000000015BDC2CEA0000136E000000000000000000000000000000000000002E00000000libsignon-glib-2.1/libsignon-glib/meson.buildlibsignon_glib_public_headers = files( 'signon-auth-service.h', 'signon-auth-session.h', 'signon-errors.h', 'signon-identity.h', 'signon-identity-info.h', 'signon-glib.h', 'signon-security-context.h', 'signon-types.h', ) libsignon_glib_private_headers = files( 'signon-internals.h', 'signon-proxy.h', 'sso-auth-service.h', ) libsignon_glib_public_sources = files( 'signon-auth-service.c', 'signon-auth-session.c', 'signon-errors.c', 'signon-identity.c', 'signon-identity-info.c', 'signon-security-context.c', ) libsignon_glib_sources = libsignon_glib_public_sources + files( 'signon-proxy.c', 'sso-auth-service.c', ) sso_interface_prefix = 'com.google.code.AccountsSSO.SingleSignOn.' dbus_auth_service_xml = join_paths('interfaces', 'com.google.code.AccountsSSO.SingleSignOn.AuthService.xml') dbus_auth_session_xml = join_paths('interfaces', 'com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml') dbus_identity_xml = join_paths('interfaces', 'com.google.code.AccountsSSO.SingleSignOn.Identity.xml') if (meson.version().version_compare('<0.47.2')) dbus_auth_service_xml = 'com.google.code.AccountsSSO.SingleSignOn.AuthService.xml' dbus_auth_session_xml = 'com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml' dbus_identity_xml = 'com.google.code.AccountsSSO.SingleSignOn.Identity.xml' endif dbus_auth_service_gen = gnome.gdbus_codegen( 'sso-auth-service-gen', dbus_auth_service_xml, interface_prefix: sso_interface_prefix, namespace: 'Sso', docbook: 'sso-auth-service-gen-doc', ) dbus_auth_session_gen = gnome.gdbus_codegen( 'sso-auth-session-gen', dbus_auth_session_xml, interface_prefix: sso_interface_prefix, namespace: 'Sso', docbook: 'sso-auth-session-gen-doc', ) dbus_identity_gen = gnome.gdbus_codegen( 'sso-identity-gen', dbus_identity_xml, interface_prefix: sso_interface_prefix, namespace: 'Sso', docbook: 'sso-identity-gen-doc', ) signon_marshal = gnome.genmarshal( 'signon-marshal', sources: 'signon-marshal.list', prefix: '_signon_marshal' ) signon_enum_types = gnome.mkenums_simple( 'signon-enum-types', sources: [ 'signon-errors.h', 'signon-identity-info.h', 'signon-auth-session.h', ], install_header: true, install_dir: join_paths(get_option('includedir'), meson.project_name()), ) python_exec = find_program(['python', 'python3']) gen_error_map = files(join_paths(meson.source_root (), 'build-aux', 'gen-error-map.py')) signon_errors_map = custom_target ( 'signon-errors-map.c', input: 'signon-errors.h', command: [python_exec, gen_error_map, '@INPUT@', '@OUTPUT@'], output: 'signon-errors-map.c' ) libsignon_glib_deps = [ gio_dep, gio_unix_dep, glib_dep, gobject_dep, ] symbols_map = 'libsignon-glib.map' libsignon_glib_lib = shared_library( 'signon-glib', libsignon_glib_public_headers, libsignon_glib_private_headers, libsignon_glib_sources, dbus_auth_service_gen, dbus_auth_session_gen, dbus_identity_gen, signon_marshal, signon_enum_types, signon_errors_map, dependencies: libsignon_glib_deps, include_directories: root_dir, link_args : [ '-Wl,--no-undefined', '-Wl,--version-script,' + join_paths(meson.current_source_dir(), symbols_map) ], link_depends : symbols_map, soversion: library_major, version: library_major + '.0.0', install: true, ) libsignon_glib_dir = include_directories('.') libsignon_glib_dep = declare_dependency( link_with: libsignon_glib_lib, dependencies: libsignon_glib_deps, include_directories: [root_dir, libsignon_glib_dir], sources: signon_enum_types[1], ) libsignon_glib_pkgs = [ 'gobject-2.0', 'glib-2.0', 'gio-2.0', 'gio-unix-2.0', ] install_headers( libsignon_glib_public_headers, subdir: meson.project_name(), ) pkg.generate( filebase: meson.project_name(), name: meson.project_name(), description: 'A low-level library for managing account credentials.', libraries: libsignon_glib_lib, requires: libsignon_glib_pkgs, version: meson.project_version(), ) if get_option('introspection') libsignon_glib_gir = gnome.generate_gir( libsignon_glib_lib, namespace: 'Signon', nsversion: library_major + '.0', sources: [ libsignon_glib_public_sources, libsignon_glib_public_headers, signon_enum_types, ], dependencies: libsignon_glib_deps, includes: ['GObject-2.0', 'Gio-2.0'], identifier_prefix: 'Signon', symbol_prefix: 'signon', header: 'libsignon-glib/signon-glib.h', extra_args: '--warn-all', install: true, ) gnome.generate_vapi('libsignon-glib', sources: libsignon_glib_gir[0], packages: libsignon_glib_pkgs, install: true, ) endif 0707010000001C000081A4000003E800000064000000015BDC2CEA00002678000000000000000000000000000000000000003800000000libsignon-glib-2.1/libsignon-glib/signon-auth-service.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * SECTION:signon-auth-service * @title: SignonAuthService * @short_description: The authorization service object * * The #SignonAuthService is the main object in this library. */ #include "signon-auth-service.h" #include "signon-errors.h" #include "signon-internals.h" #include "sso-auth-service.h" #include <gio/gio.h> #include <glib.h> G_DEFINE_TYPE (SignonAuthService, signon_auth_service, G_TYPE_OBJECT); struct _SignonAuthServicePrivate { SsoAuthService *proxy; }; #define SIGNON_AUTH_SERVICE_PRIV(obj) (SIGNON_AUTH_SERVICE(obj)->priv) static void signon_auth_service_init (SignonAuthService *auth_service) { SignonAuthServicePrivate *priv; priv = G_TYPE_INSTANCE_GET_PRIVATE (auth_service, SIGNON_TYPE_AUTH_SERVICE, SignonAuthServicePrivate); auth_service->priv = priv; /* Create the proxy */ priv->proxy = sso_auth_service_get_instance (); } static void signon_auth_service_dispose (GObject *object) { SignonAuthService *auth_service = SIGNON_AUTH_SERVICE (object); SignonAuthServicePrivate *priv = auth_service->priv; if (priv->proxy) { g_object_unref (priv->proxy); priv->proxy = NULL; } G_OBJECT_CLASS (signon_auth_service_parent_class)->dispose (object); } static void signon_auth_service_finalize (GObject *object) { G_OBJECT_CLASS (signon_auth_service_parent_class)->finalize (object); } static void signon_auth_service_class_init (SignonAuthServiceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof (SignonAuthServicePrivate)); object_class->dispose = signon_auth_service_dispose; object_class->finalize = signon_auth_service_finalize; } static void _signon_auth_service_finish_query_methods (GObject *source_object, GAsyncResult *res, gpointer user_data) { SsoAuthService *proxy = NULL; GTask *task = (GTask *)user_data; gchar **methods_array = NULL; GError *error = NULL; g_return_if_fail (SSO_IS_AUTH_SERVICE (source_object)); if (g_task_return_error_if_cancelled (task)) return; proxy = SSO_AUTH_SERVICE (source_object); if (sso_auth_service_call_query_methods_finish (proxy, &methods_array, res, &error)) { g_task_return_pointer (task, methods_array, NULL); } else { g_task_return_error (task, error); } } static void _signon_auth_service_finish_query_mechanisms (GObject *source_object, GAsyncResult *res, gpointer user_data) { SsoAuthService *proxy = NULL; GTask *task = (GTask *)user_data; gchar **mechanisms_array = NULL; GError *error = NULL; g_return_if_fail (SSO_IS_AUTH_SERVICE (source_object)); if (g_task_return_error_if_cancelled (task)) return; proxy = SSO_AUTH_SERVICE (source_object); if (sso_auth_service_call_query_mechanisms_finish (proxy, &mechanisms_array, res, &error)) { g_task_return_pointer (task, mechanisms_array, NULL); } else { g_task_return_error (task, error); } } /** * signon_auth_service_new: * * Create a new #SignonAuthService. * * Returns: an instance of an #SignonAuthService. */ SignonAuthService * signon_auth_service_new () { return g_object_new (SIGNON_TYPE_AUTH_SERVICE, NULL); } /** * signon_auth_service_get_methods: * @auth_service: a #SignonAuthService * @cancellable: (nullable): a #GCancellable or %NULL * @callback: a callback to execute upon completion * @user_data: closure data for @callback * * Lists all the available methods. * * Since: 2.0 */ void signon_auth_service_get_methods (SignonAuthService *auth_service, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SignonAuthServicePrivate *priv = NULL; GTask *task = NULL; g_return_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service)); priv = SIGNON_AUTH_SERVICE_PRIV (auth_service); task = g_task_new (auth_service, cancellable, callback, user_data); sso_auth_service_call_query_methods (priv->proxy, cancellable, _signon_auth_service_finish_query_methods, task); } /** * signon_auth_service_get_methods_finish: * @auth_service: a #SignonAuthService * @result: a #GAsyncResult * @error: a location for a #GError, or %NULL * * Completes an asynchronous request to signon_auth_service_get_methods(). * * Returns: (array zero-terminated=1) (transfer full): A list of available * methods. */ gchar ** signon_auth_service_get_methods_finish (SignonAuthService *auth_service, GAsyncResult *result, GError **error) { g_return_val_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service), NULL); return g_task_propagate_pointer (G_TASK (result), error); } /** * signon_auth_service_get_methods_sync: * @auth_service: a #SignonAuthService * @cancellable: (nullable): a #GCancellable or %NULL * @error: a location for a #GError, or %NULL * * Lists all the available methods. * This is a blocking version of signon_auth_service_get_methods(). * * Returns: (array zero-terminated=1) (transfer full): A list of available * methods. * * Since: 2.0 */ gchar ** signon_auth_service_get_methods_sync (SignonAuthService *auth_service, GCancellable *cancellable, GError **error) { SignonAuthServicePrivate *priv; gchar **methods_array = NULL; g_return_val_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service), NULL); priv = SIGNON_AUTH_SERVICE_PRIV (auth_service); sso_auth_service_call_query_methods_sync (priv->proxy, &methods_array, cancellable, error); return methods_array; } /** * signon_auth_service_get_mechanisms: * @auth_service: a #SignonAuthService * @method: the name of the method whose mechanisms must be retrieved. * @cancellable: (nullable): a #GCancellable or %NULL * @callback: a callback to execute upon completion * @user_data: closure data for @callback * * Lists all the available mechanisms. * * Since: 2.0 */ void signon_auth_service_get_mechanisms (SignonAuthService *auth_service, const gchar *method, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SignonAuthServicePrivate *priv = NULL; GTask *task = NULL; g_return_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service)); priv = SIGNON_AUTH_SERVICE_PRIV (auth_service); task = g_task_new (auth_service, cancellable, callback, user_data); sso_auth_service_call_query_mechanisms (priv->proxy, method, cancellable, _signon_auth_service_finish_query_mechanisms, task); } /** * signon_auth_service_get_mechanisms_finish: * @auth_service: a #SignonAuthService * @result: a #GAsyncResult * @error: a location for a #GError, or %NULL * * Completes an asynchronous request to signon_auth_service_get_mechanisms(). * * Returns: (array zero-terminated=1) (transfer full): A list of available * mechanisms. */ gchar ** signon_auth_service_get_mechanisms_finish (SignonAuthService *auth_service, GAsyncResult *result, GError **error) { g_return_val_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service), NULL); return g_task_propagate_pointer (G_TASK (result), error); } /** * signon_auth_service_get_mechanisms_sync: * @auth_service: a #SignonAuthService * @method: the name of the method whose mechanisms must be retrieved. * @cancellable: (nullable): a #GCancellable or %NULL * @error: a location for a #GError, or %NULL * * Lists all the available mechanisms. * This is a blocking version of signon_auth_service_get_mechanisms(). * * Returns: (array zero-terminated=1) (transfer full): A list of available * mechanisms. * * Since: 2.0 */ gchar ** signon_auth_service_get_mechanisms_sync (SignonAuthService *auth_service, const gchar *method, GCancellable *cancellable, GError **error) { SignonAuthServicePrivate *priv; gchar **mechanisms_array = NULL; g_return_val_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service), NULL); priv = SIGNON_AUTH_SERVICE_PRIV (auth_service); sso_auth_service_call_query_mechanisms_sync (priv->proxy, method, &mechanisms_array, cancellable, error); return mechanisms_array; } 0707010000001D000081A4000003E800000064000000015BDC2CEA00000FB4000000000000000000000000000000000000003800000000libsignon-glib-2.1/libsignon-glib/signon-auth-service.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SIGNON_AUTH_SERVICE_H_ #define _SIGNON_AUTH_SERVICE_H_ #include <glib-object.h> #include <gio/gio.h> G_BEGIN_DECLS #define SIGNON_TYPE_AUTH_SERVICE (signon_auth_service_get_type ()) #define SIGNON_AUTH_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_AUTH_SERVICE, SignonAuthService)) #define SIGNON_AUTH_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_AUTH_SERVICE, SignonAuthServiceClass)) #define SIGNON_IS_AUTH_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_AUTH_SERVICE)) #define SIGNON_IS_AUTH_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_AUTH_SERVICE)) #define SIGNON_AUTH_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_AUTH_SERVICE, SignonAuthServiceClass)) typedef struct _SignonAuthServiceClass SignonAuthServiceClass; typedef struct _SignonAuthServicePrivate SignonAuthServicePrivate; typedef struct _SignonAuthService SignonAuthService; /** * SignonAuthServiceClass: * * Opaque struct. Use the accessor functions below. */ struct _SignonAuthServiceClass { GObjectClass parent_class; }; /** * SignonAuthService: * * Opaque struct. Use the accessor functions below. */ struct _SignonAuthService { GObject parent_instance; SignonAuthServicePrivate *priv; }; GType signon_auth_service_get_type (void) G_GNUC_CONST; SignonAuthService *signon_auth_service_new (); void signon_auth_service_get_methods (SignonAuthService *auth_service, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gchar **signon_auth_service_get_methods_finish (SignonAuthService *auth_service, GAsyncResult *result, GError **error); gchar **signon_auth_service_get_methods_sync (SignonAuthService *auth_service, GCancellable *cancellable, GError **error); void signon_auth_service_get_mechanisms (SignonAuthService *auth_service, const gchar *method, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gchar **signon_auth_service_get_mechanisms_finish (SignonAuthService *auth_service, GAsyncResult *result, GError **error); gchar **signon_auth_service_get_mechanisms_sync (SignonAuthService *auth_service, const gchar *method, GCancellable *cancellable, GError **error); G_END_DECLS #endif /* _SIGNON_AUTH_SERVICE_H_ */ 0707010000001E000081A4000003E800000064000000015BDC2CEA000059BA000000000000000000000000000000000000003800000000libsignon-glib-2.1/libsignon-glib/signon-auth-session.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * SECTION:signon-auth-session * @title: SignonAuthSession * @short_description: Authentication session handler. * * The #SignonAuthSession object is responsible for handling the client * authentication. #SignonAuthSession objects can be created from existing * identities (via signon_identity_create_session() or by passing a non-zero ID * to signon_auth_session_new()), in which case the authentication data such as * username and password will be implicitly taken from the identity, or they * can be created with no existing identity bound to them, in which case all * the authentication data must be filled in by the client when * signon_auth_session_process() is called. */ #include "signon-internals.h" #include "signon-auth-session.h" #include "signon-errors.h" #include "signon-marshal.h" #include "signon-proxy.h" #include "sso-auth-service.h" #include "sso-auth-session-gen.h" static void signon_auth_session_proxy_if_init (SignonProxyInterface *iface); G_DEFINE_TYPE_WITH_CODE (SignonAuthSession, signon_auth_session, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SIGNON_TYPE_PROXY, signon_auth_session_proxy_if_init)) /* Signals */ enum { STATE_CHANGED, LAST_SIGNAL }; static guint auth_session_signals[LAST_SIGNAL] = { 0 }; static const gchar auth_session_process_pending_message[] = "The request is added to queue."; struct _SignonAuthSessionPrivate { SsoAuthSession *proxy; SsoAuthService *auth_service_proxy; GCancellable *cancellable; gint id; gchar *method_name; gboolean registering; gboolean busy; gboolean canceled; gboolean dispose_has_run; guint signal_state_changed; guint signal_unregistered; }; enum SignonAuthSessionState { SIGNON_AUTH_SESSION_STATE_NOT_STARTED = 0, /* No message. */ SIGNON_AUTH_SESSION_STATE_RESOLVING_HOST, /* Resolving remote server host name. */ SIGNON_AUTH_SESSION_STATE_CONNECTING, /* Connecting to remote server. */ SIGNON_AUTH_SESSION_STATE_SENDING_DATA, /* Sending data to remote server. */ SIGNON_AUTH_SESSION_STATE_WAITING_REPLY, /* Waiting reply from remote server. */ SIGNON_AUTH_SESSION_STATE_USER_PENDING, /* Waiting response from user. */ SIGNON_AUTH_SESSION_STATE_UI_REFRESHING, /* Refreshing ui request. */ SIGNON_AUTH_SESSION_STATE_PROCESS_PENDING, /* Waiting another process to start. */ SIGNON_AUTH_SESSION_STATE_STARTED, /* Authentication session is started. */ SIGNON_AUTH_SESSION_STATE_PROCESS_CANCELING, /* Canceling.current process. */ SIGNON_AUTH_SESSION_STATE_PROCESS_DONE, /* Authentication completed. */ SIGNON_AUTH_SESSION_STATE_CUSTOM, /* Custom message. */ SIGNON_AUTH_SESSION_STATE_LAST }; typedef struct _AuthSessionProcessData { GVariant *session_data; gchar *mechanism; } AuthSessionProcessData; #define SIGNON_AUTH_SESSION_PRIV(obj) (SIGNON_AUTH_SESSION(obj)->priv) #define SIGNON_AUTH_SESSION_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionPrivate)) static void auth_session_state_changed_cb (GDBusProxy *proxy, gint state, gchar *message, gpointer user_data); static void auth_session_remote_object_destroyed_cb (GDBusProxy *proxy, gpointer user_data); static gboolean auth_session_priv_init (SignonAuthSession *self, guint id, const gchar *method_name, GError **err); static void auth_session_set_id_ready_cb (gpointer object, const GError *error, gpointer user_data); static void auth_session_cancel_ready_cb (gpointer object, const GError *error, gpointer user_data); static void auth_session_check_remote_object(SignonAuthSession *self); static void auth_session_process_data_free (AuthSessionProcessData *process_data) { g_free (process_data->mechanism); g_variant_unref (process_data->session_data); g_slice_free (AuthSessionProcessData, process_data); } static void auth_session_process_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SignonAuthSession *self; SsoAuthSession *proxy = SSO_AUTH_SESSION (object); GTask *res_process = userdata; GVariant *reply; GError *error = NULL; g_return_if_fail (res_process != NULL); sso_auth_session_call_process_finish (proxy, &reply, res, &error); self = SIGNON_AUTH_SESSION (g_task_get_source_object (res_process)); self->priv->busy = FALSE; if (G_LIKELY (error == NULL)) { g_task_return_pointer (res_process, reply, (GDestroyNotify) g_variant_unref); } else { g_task_return_error (res_process, error); } g_object_unref (res_process); } static void auth_session_process_ready_cb (gpointer object, const GError *error, gpointer user_data) { SignonAuthSession *self = SIGNON_AUTH_SESSION (object); SignonAuthSessionPrivate *priv; GTask *res = G_TASK (user_data); AuthSessionProcessData *process_data; g_return_if_fail (self != NULL); priv = self->priv; if (error != NULL) { DEBUG ("AuthSessionError: %s", error->message); g_task_return_error (res, g_error_copy (error)); g_object_unref (res); return; } if (priv->canceled) { priv->busy = FALSE; priv->canceled = FALSE; g_task_return_new_error (res, signon_error_quark (), SIGNON_ERROR_SESSION_CANCELED, "Authentication session was canceled"); g_object_unref (res); return; } process_data = g_task_get_task_data (res); g_return_if_fail (process_data != NULL); sso_auth_session_call_process (priv->proxy, process_data->session_data, process_data->mechanism, g_task_get_cancellable (res), auth_session_process_reply, res); g_signal_emit (self, auth_session_signals[STATE_CHANGED], 0, SIGNON_AUTH_SESSION_STATE_PROCESS_PENDING, auth_session_process_pending_message); } static void destroy_proxy (SignonAuthSessionPrivate *priv) { g_signal_handler_disconnect (priv->proxy, priv->signal_state_changed); g_signal_handler_disconnect (priv->proxy, priv->signal_unregistered); g_object_unref (priv->proxy); priv->proxy = NULL; } static GQuark auth_session_object_quark () { static GQuark quark = 0; if (!quark) quark = g_quark_from_static_string ("auth_session_object_quark"); return quark; } static void signon_auth_session_proxy_setup (SignonProxy *proxy) { auth_session_check_remote_object (SIGNON_AUTH_SESSION (proxy)); } static void signon_auth_session_proxy_if_init (SignonProxyInterface *iface) { iface->setup = signon_auth_session_proxy_setup; } static void signon_auth_session_init (SignonAuthSession *self) { self->priv = SIGNON_AUTH_SESSION_GET_PRIV (self); self->priv->auth_service_proxy = sso_auth_service_get_instance (); self->priv->cancellable = g_cancellable_new (); } static void signon_auth_session_dispose (GObject *object) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (object)); SignonAuthSession *self = SIGNON_AUTH_SESSION (object); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); if (priv->dispose_has_run) return; if (priv->cancellable) { g_cancellable_cancel (priv->cancellable); g_object_unref (priv->cancellable); priv->cancellable = NULL; } if (priv->proxy) destroy_proxy (priv); if (priv->auth_service_proxy) { g_object_unref (priv->auth_service_proxy); priv->auth_service_proxy = NULL; } G_OBJECT_CLASS (signon_auth_session_parent_class)->dispose (object); priv->dispose_has_run = TRUE; } static void signon_auth_session_finalize (GObject *object) { g_return_if_fail (SIGNON_IS_AUTH_SESSION(object)); SignonAuthSession *self = SIGNON_AUTH_SESSION(object); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); g_free (priv->method_name); G_OBJECT_CLASS (signon_auth_session_parent_class)->finalize (object); } static void signon_auth_session_class_init (SignonAuthSessionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof (SignonAuthSessionPrivate)); /** * SignonAuthSession::state-changed: * @auth_session: the #SignonAuthSession * @state: the current state of the #SignonAuthSession * @message: the message associated with the state change * * Emitted when the state of the #SignonAuthSession changes. */ auth_session_signals[STATE_CHANGED] = g_signal_new ("state-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, NULL, NULL, _signon_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); object_class->dispose = signon_auth_session_dispose; object_class->finalize = signon_auth_session_finalize; } /** * signon_auth_session_new: * @id: the id of the #SignonIdentity to be used. Can be 0, if this session is * not bound to any stored identity. * @method_name: the name of the authentication method to be used. * @err: a pointer to a location which will contain the error, in case this * function fails. * * Creates a new #SignonAuthSession, which can be used to authenticate using * the specified method. * * Returns: a new #SignonAuthSession. */ SignonAuthSession * signon_auth_session_new (gint id, const gchar *method_name, GError **err) { SignonAuthSession *self = SIGNON_AUTH_SESSION(g_object_new (SIGNON_TYPE_AUTH_SESSION, NULL)); g_return_val_if_fail (self != NULL, NULL); if (!auth_session_priv_init(self, id, method_name, err)) { if (*err) g_warning ("%s returned error: %s", G_STRFUNC, (*err)->message); g_object_unref (self); return NULL; } return self; } static void auth_session_set_id_ready_cb (gpointer object, const GError *error, gpointer user_data) { if (error) { g_warning ("%s returned error: %s", G_STRFUNC, error->message); return; } g_return_if_fail (SIGNON_IS_AUTH_SESSION (object)); SignonAuthSession *self = SIGNON_AUTH_SESSION (object); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); gint id = GPOINTER_TO_INT(user_data); GError *err = NULL; sso_auth_session_call_set_id_sync (priv->proxy, id, priv->cancellable, &err); priv->id = id; if (err) g_warning ("%s returned error: %s", G_STRFUNC, err->message); g_clear_error(&err); } void signon_auth_session_set_id(SignonAuthSession* self, gint id) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (self)); g_return_if_fail (id >= 0); signon_proxy_call_when_ready (self, auth_session_object_quark(), auth_session_set_id_ready_cb, GINT_TO_POINTER(id)); } /** * signon_auth_session_get_method: * @self: the #SignonAuthSession. * * Get the current authentication method. * * Returns: the authentication method being used, or %NULL on failure. */ const gchar * signon_auth_session_get_method (SignonAuthSession *self) { g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), NULL); SignonAuthSessionPrivate *priv = self->priv; g_return_val_if_fail (priv != NULL, NULL); return priv->method_name; } /** * signon_auth_session_process: * @self: the #SignonAuthSession. * @session_data: (transfer floating): a dictionary of parameters. * @mechanism: the authentication mechanism to be used. * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore. * @callback: a callback which will be called when the * authentication reply is available. * @user_data: user data to be passed to the callback. * * Performs one step of the authentication process. If the #SignonAuthSession * object is bound to an existing identity, the identity properties such as * username and password will be also passed to the authentication plugin, so * there's no need to fill them into @session_data. * @session_data can be used to add additional authentication parameters to the * session, or to override the parameters otherwise taken from the identity. * * Since: 1.8 */ void signon_auth_session_process (SignonAuthSession *self, GVariant *session_data, const gchar *mechanism, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SignonAuthSessionPrivate *priv; AuthSessionProcessData *process_data; GTask *task = NULL; g_return_if_fail (SIGNON_IS_AUTH_SESSION (self)); priv = self->priv; g_return_if_fail (session_data != NULL); task = g_task_new (self, cancellable, callback, user_data); process_data = g_slice_new0 (AuthSessionProcessData); process_data->session_data = g_variant_ref_sink (session_data); process_data->mechanism = g_strdup (mechanism); g_task_set_task_data (task, process_data, (GDestroyNotify)auth_session_process_data_free); priv->busy = TRUE; signon_proxy_call_when_ready (self, auth_session_object_quark(), auth_session_process_ready_cb, task); } /** * signon_auth_session_process_finish: * @self: the #SignonAuthSession. * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to * signon_auth_session_process(). * @error: return location for error, or %NULL. * * Collect the result of the signon_auth_session_process() operation. * * Returns: a #GVariant of type %G_VARIANT_TYPE_VARDICT containing the * authentication reply. * * Since: 1.8 */ GVariant * signon_auth_session_process_finish (SignonAuthSession *self, GAsyncResult *res, GError **error) { GTask *task; g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), NULL); task = G_TASK (res); return g_task_propagate_pointer (task, error); } /** * signon_auth_session_cancel: * @self: the #SignonAuthSession. * * Cancel the authentication session. */ void signon_auth_session_cancel (SignonAuthSession *self) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (self)); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); if (!priv->busy) return; priv->canceled = TRUE; signon_proxy_call_when_ready (self, auth_session_object_quark(), auth_session_cancel_ready_cb, NULL); } static void auth_session_get_object_path_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SsoAuthService *proxy = SSO_AUTH_SERVICE (object); gchar *object_path = NULL; GError *error = NULL; sso_auth_service_call_get_auth_session_object_path_finish (proxy, &object_path, res, &error); if (error != NULL && error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED) { g_error_free (error); return; } g_return_if_fail (SIGNON_IS_AUTH_SESSION (userdata)); SignonAuthSession *self = SIGNON_AUTH_SESSION (userdata); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); priv->registering = FALSE; if (!g_strcmp0(object_path, "") || error) { if (error) DEBUG ("Error message is %s", error->message); else error = g_error_new (signon_error_quark(), SIGNON_ERROR_RUNTIME, "Cannot create remote AuthSession object"); } else { GDBusConnection *connection; const gchar *bus_name; GError *proxy_error = NULL; connection = g_dbus_proxy_get_connection ((GDBusProxy *)proxy); bus_name = g_dbus_proxy_get_name ((GDBusProxy *)proxy); priv->proxy = sso_auth_session_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, bus_name, object_path, priv->cancellable, &proxy_error); if (G_UNLIKELY (proxy_error != NULL)) { g_warning ("Failed to initialize AuthSession proxy: %s", proxy_error->message); g_clear_error (&proxy_error); } g_dbus_proxy_set_default_timeout ((GDBusProxy *)priv->proxy, G_MAXINT); priv->signal_state_changed = g_signal_connect (priv->proxy, "state-changed", G_CALLBACK (auth_session_state_changed_cb), self); priv->signal_unregistered = g_signal_connect (priv->proxy, "unregistered", G_CALLBACK (auth_session_remote_object_destroyed_cb), self); } DEBUG ("Object path received: %s", object_path); g_free (object_path); signon_proxy_set_ready (self, auth_session_object_quark (), error); } static void auth_session_state_changed_cb (GDBusProxy *proxy, gint state, gchar *message, gpointer user_data) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (user_data)); SignonAuthSession *self = SIGNON_AUTH_SESSION (user_data); g_signal_emit ((GObject *)self, auth_session_signals[STATE_CHANGED], 0, state, message); } static void auth_session_remote_object_destroyed_cb (GDBusProxy *proxy, gpointer user_data) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (user_data)); SignonAuthSession *self = SIGNON_AUTH_SESSION (user_data); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); DEBUG ("remote object unregistered"); if (priv->proxy) destroy_proxy (priv); signon_proxy_set_not_ready (self); } static gboolean auth_session_priv_init (SignonAuthSession *self, guint id, const gchar *method_name, GError **err) { g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), FALSE); SignonAuthSessionPrivate *priv = SIGNON_AUTH_SESSION_PRIV (self); g_return_val_if_fail (priv, FALSE); priv->id = id; priv->method_name = g_strdup (method_name); priv->registering = FALSE; priv->busy = FALSE; priv->canceled = FALSE; return TRUE; } static void auth_session_cancel_ready_cb (gpointer object, const GError *error, gpointer user_data) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (object)); g_return_if_fail (user_data == NULL); SignonAuthSession *self = SIGNON_AUTH_SESSION (object); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); if (error) { //TODO: in general this function does not return any values, // that is why I think it should not emit anything for this particular case DEBUG("error during initialization"); } else if (priv->proxy && priv->busy) sso_auth_session_call_cancel_sync (priv->proxy, priv->cancellable, NULL); priv->busy = FALSE; priv->canceled = FALSE; } static void auth_session_check_remote_object(SignonAuthSession *self) { g_return_if_fail (self != NULL); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); if (priv->proxy != NULL) return; g_return_if_fail (priv->auth_service_proxy != NULL); if (!priv->registering) { priv->registering = TRUE; sso_auth_service_call_get_auth_session_object_path ( priv->auth_service_proxy, priv->id, "*", priv->method_name, priv->cancellable, auth_session_get_object_path_reply, self); } } 0707010000001F000081A4000003E800000064000000015BDC2CEA00001451000000000000000000000000000000000000003800000000libsignon-glib-2.1/libsignon-glib/signon-auth-session.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef SIGNONAUTHSESSION_H_ #define SIGNONAUTHSESSION_H_ #include <gio/gio.h> #include <glib-object.h> #include <libsignon-glib/signon-types.h> G_BEGIN_DECLS /* * Useful session data keys */ /** * SIGNON_SESSION_DATA_USERNAME: * * Username. */ #define SIGNON_SESSION_DATA_USERNAME "UserName" /** * SIGNON_SESSION_DATA_SECRET: * * Secret. */ #define SIGNON_SESSION_DATA_SECRET "Secret" /** * SIGNON_SESSION_DATA_REALM: * * Realm. */ #define SIGNON_SESSION_DATA_REALM "Realm" /** * SIGNON_SESSION_DATA_PROXY: * * Proxy. */ #define SIGNON_SESSION_DATA_PROXY "NetworkProxy" /** * SignonSessionDataUiPolicy: * @SIGNON_POLICY_DEFAULT: The plugin can decide when to show UI. * @SIGNON_POLICY_REQUEST_PASSWORD: Force the user to enter the password. * @SIGNON_POLICY_NO_USER_INTERACTION: No UI elements will be shown to the user. * @SIGNON_POLICY_VALIDATION: UI elements can be shown to the user only when * CAPTCHA-like security measures are required. * * Policy for the signon process, passed to the UI plugin. */ typedef enum { SIGNON_POLICY_DEFAULT = 0, SIGNON_POLICY_REQUEST_PASSWORD, SIGNON_POLICY_NO_USER_INTERACTION, SIGNON_POLICY_VALIDATION, } SignonSessionDataUiPolicy; /** * SIGNON_SESSION_DATA_UI_POLICY: * @see_also: #SignonSessionDataUiPolicy * * Policy for the signon process. */ #define SIGNON_SESSION_DATA_UI_POLICY "UiPolicy" /** * SIGNON_SESSION_DATA_CAPTION: * * Caption for the UI dialog. */ #define SIGNON_SESSION_DATA_CAPTION "Caption" /** * SIGNON_SESSION_DATA_TIMEOUT: * * Network timeout, in milliseconds (uint32). */ #define SIGNON_SESSION_DATA_TIMEOUT "NetworkTimeout" /** * SIGNON_SESSION_DATA_WINDOW_ID: * * Platform-specific window id (for dialog transiency) - uint32. */ #define SIGNON_SESSION_DATA_WINDOW_ID "WindowId" /** * SIGNON_SESSION_DATA_RENEW_TOKEN: * * Requests the signon plugin to obtain a new token (boolean). */ #define SIGNON_SESSION_DATA_RENEW_TOKEN "RenewToken" #define SIGNON_TYPE_AUTH_SESSION (signon_auth_session_get_type ()) #define SIGNON_AUTH_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSession)) #define SIGNON_AUTH_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionClass)) #define SIGNON_IS_AUTH_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_AUTH_SESSION)) #define SIGNON_IS_AUTH_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_AUTH_SESSION)) #define SIGNON_AUTH_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionClass)) typedef struct _SignonAuthSession SignonAuthSession; typedef struct _SignonAuthSessionPrivate SignonAuthSessionPrivate; typedef struct _SignonAuthSessionClass SignonAuthSessionClass; /** * SignonAuthSession: * * Opaque struct. Use the accessor functions below. */ struct _SignonAuthSession { GObject parent; SignonAuthSessionPrivate *priv; }; /** * SignonAuthSessionClass: * * Opaque struct. Use the accessor functions below. */ struct _SignonAuthSessionClass { GObjectClass parent; }; GType signon_auth_session_get_type (void) G_GNUC_CONST; SignonAuthSession *signon_auth_session_new(gint id, const gchar *method_name, GError **err); const gchar *signon_auth_session_get_method (SignonAuthSession *self); void signon_auth_session_process (SignonAuthSession *self, GVariant *session_data, const gchar *mechanism, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); GVariant *signon_auth_session_process_finish (SignonAuthSession *self, GAsyncResult *res, GError **error); void signon_auth_session_cancel(SignonAuthSession *self); G_END_DECLS #endif //SIGNONAUTHSESSIONIMPL_H_ 07070100000020000081A4000003E800000064000000015BDC2CEA00000669000000000000000000000000000000000000003200000000libsignon-glib-2.1/libsignon-glib/signon-errors.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #include "signon-errors.h" #include "signon-enum-types.h" #include "signon-internals.h" #include <gio/gio.h> /** * SECTION:signon-errors * @title: SignonError * @short_description: Possible errors from Signon. * * An enumeration of errors that are possible from Signon. */ #include "signon-errors-map.c" GQuark signon_error_quark (void) { static volatile gsize quark = 0; g_dbus_error_register_error_domain ("signon-errors", &quark, signon_error_entries, G_N_ELEMENTS (signon_error_entries)); return (GQuark) quark; } 07070100000021000081A4000003E800000064000000015BDC2CEA00001477000000000000000000000000000000000000003200000000libsignon-glib-2.1/libsignon-glib/signon-errors.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef __LIBSIGNON_ERRORS_H__ #define __LIBSIGNON_ERRORS_H__ #include <glib.h> #include <glib-object.h> #include <libsignon-glib/signon-enum-types.h> #define SIGNON_ERROR (signon_error_quark()) /** * SignonError: * @SIGNON_ERROR_UNKNOWN: Catch-all for errors not distinguished by another code. * @SIGNON_ERROR_INTERNAL_SERVER: Signon daemon internal error. * @SIGNON_ERROR_INTERNAL_COMMUNICATION: Error communicating with Sigon daemon. * @SIGNON_ERROR_PERMISSION_DENIED: The operation cannot be performed due to * insufficient client permissions. * @SIGNON_ERROR_METHOD_NOT_KNOWN: The method with this name was not found. * @SIGNON_ERROR_SERVICE_NOT_AVAILABLE: The service is temporarily unavailable. * @SIGNON_ERROR_INVALID_QUERY: Parameters for the query are invalid. * @SIGNON_ERROR_METHOD_NOT_AVAILABLE: The requested method is not available. * @SIGNON_ERROR_IDENTITY_NOT_FOUND: The identity mathching the #SignonIdentity * was not found on the service. * @SIGNON_ERROR_STORE_FAILED: Storing credentials failed. * @SIGNON_ERROR_REMOVE_FAILED: Removing credentials failed. * @SIGNON_ERROR_SIGNOUT_FAILED: Signing out failed. * @SIGNON_ERROR_IDENTITY_OPERATION_CANCELED: Identity operation was canceled * by the user. * @SIGNON_ERROR_CREDENTIALS_NOT_AVAILABLE: Query failed. * @SIGNON_ERROR_REFERENCE_NOT_FOUND: Trying to remove non-existent reference. * @SIGNON_ERROR_MECHANISM_NOT_AVAILABLE: The requested mechanism in not * available. * @SIGNON_ERROR_MISSING_DATA: The #SessionData does not contain the necessary * information. * @SIGNON_ERROR_INVALID_CREDENTIALS: The supplied credentials are invalid for * the mechanism implementation. * @SIGNON_ERROR_NOT_AUTHORIZED: Authorization failed. * @SIGNON_ERROR_WRONG_STATE: An operation method has been called in an * incorrect state. * @SIGNON_ERROR_OPERATION_NOT_SUPPORTED: The operation is not supported by the * mechanism implementation. * @SIGNON_ERROR_NO_CONNECTION: No network connection. * @SIGNON_ERROR_NETWORK: Network connection failed. * @SIGNON_ERROR_SSL: SSL connection failed. * @SIGNON_ERROR_RUNTIME: Casting #SessionData into subclass failed. * @SIGNON_ERROR_SESSION_CANCELED: Challenge was canceled. * @SIGNON_ERROR_TIMED_OUT: Challenge timed out. * @SIGNON_ERROR_USER_INTERACTION: User interaction dialog failed. * @SIGNON_ERROR_OPERATION_FAILED: Temporary failure in authentication. * @SIGNON_ERROR_ENCRYPTION_FAILED: @deprecated: Failure during data * encryption/decryption. * @SIGNON_ERROR_TOS_NOT_ACCEPTED: User declined Terms of Service. * @SIGNON_ERROR_FORGOT_PASSWORD: User requested password reset sequence. * @SIGNON_ERROR_METHOD_OR_MECHANISM_NOT_ALLOWED: Method or mechanism not * allowed for this identity. * @SIGNON_ERROR_INCORRECT_DATE: Date/time incorrect on device. * @SIGNON_ERROR_USER_ERROR: Placeholder to rearrange enumeration - userspace * specific. * * Possible Signon errors. */ typedef enum { SIGNON_ERROR_UNKNOWN = 1, SIGNON_ERROR_INTERNAL_SERVER = 2, SIGNON_ERROR_INTERNAL_COMMUNICATION = 3, SIGNON_ERROR_PERMISSION_DENIED = 4, SIGNON_ERROR_METHOD_NOT_KNOWN = 101, SIGNON_ERROR_SERVICE_NOT_AVAILABLE, SIGNON_ERROR_INVALID_QUERY, SIGNON_ERROR_METHOD_NOT_AVAILABLE = 201, SIGNON_ERROR_IDENTITY_NOT_FOUND, SIGNON_ERROR_STORE_FAILED, SIGNON_ERROR_REMOVE_FAILED, SIGNON_ERROR_SIGNOUT_FAILED, SIGNON_ERROR_IDENTITY_OPERATION_CANCELED, SIGNON_ERROR_CREDENTIALS_NOT_AVAILABLE, SIGNON_ERROR_REFERENCE_NOT_FOUND, SIGNON_ERROR_MECHANISM_NOT_AVAILABLE = 301, SIGNON_ERROR_MISSING_DATA, SIGNON_ERROR_INVALID_CREDENTIALS, SIGNON_ERROR_NOT_AUTHORIZED, SIGNON_ERROR_WRONG_STATE, SIGNON_ERROR_OPERATION_NOT_SUPPORTED, SIGNON_ERROR_NO_CONNECTION, SIGNON_ERROR_NETWORK, SIGNON_ERROR_SSL, SIGNON_ERROR_RUNTIME, SIGNON_ERROR_SESSION_CANCELED, SIGNON_ERROR_TIMED_OUT, SIGNON_ERROR_USER_INTERACTION, SIGNON_ERROR_OPERATION_FAILED, SIGNON_ERROR_ENCRYPTION_FAILED, SIGNON_ERROR_TOS_NOT_ACCEPTED, SIGNON_ERROR_FORGOT_PASSWORD, SIGNON_ERROR_METHOD_OR_MECHANISM_NOT_ALLOWED, SIGNON_ERROR_INCORRECT_DATE, SIGNON_ERROR_USER_ERROR = 400 } SignonError; GQuark signon_error_quark (void); #endif 07070100000022000081A4000003E800000064000000015BDC2CEA00000539000000000000000000000000000000000000003000000000libsignon-glib-2.1/libsignon-glib/signon-glib.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2011-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef SIGNON_GLIB_H #define SIGNON_GLIB_H #include <libsignon-glib/signon-auth-service.h> #include <libsignon-glib/signon-auth-session.h> #include <libsignon-glib/signon-enum-types.h> #include <libsignon-glib/signon-errors.h> #include <libsignon-glib/signon-identity-info.h> #include <libsignon-glib/signon-identity.h> #include <libsignon-glib/signon-security-context.h> #endif /* SIGNON_GLIB_H */ 07070100000023000081A4000003E800000064000000015BDC2CEA00004988000000000000000000000000000000000000003900000000libsignon-glib-2.1/libsignon-glib/signon-identity-info.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2011-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * SECTION:signon-identity-info * @title: SignonIdentityInfo * @short_description: Extra data for a #SignonIdentity. * * Extra data retreived from a #SignonIdentity. */ #include "signon-identity-info.h" #include "signon-internals.h" G_DEFINE_BOXED_TYPE (SignonIdentityInfo, signon_identity_info, (GBoxedCopyFunc)signon_identity_info_copy, (GBoxedFreeFunc)signon_identity_info_free); static GVariant * signon_variant_new_string (const gchar *string) { if (string == NULL || !g_utf8_validate (string, -1, NULL)) return g_variant_new_string (""); return g_variant_new_string (string); } static const gchar *identity_info_get_secret (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, NULL); return info->secret; } static void identity_info_set_id (SignonIdentityInfo *info, gint id) { g_return_if_fail (info != NULL); g_return_if_fail (id >= 0); info->id = id; } static void identity_methods_copy (gpointer key, gpointer value, gpointer user_data) { signon_identity_info_set_method ((SignonIdentityInfo *)user_data, (const gchar *)key, (const gchar* const *)value); } void signon_identity_info_set_methods (SignonIdentityInfo *info, const GHashTable *methods) { g_return_if_fail (info != NULL); g_return_if_fail (methods != NULL); DEBUG("%s", G_STRFUNC); if (info->methods) g_hash_table_remove_all (info->methods); else info->methods = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_strfreev); g_hash_table_foreach ((GHashTable *)methods, identity_methods_copy, info); } SignonIdentityInfo * signon_identity_info_new_from_variant (GVariant *variant) { GVariant *method_map = NULL; GVariant *acl_var = NULL; if (!variant) return NULL; SignonIdentityInfo *info = signon_identity_info_new (); GVariantDict dict; g_variant_dict_init (&dict, variant); DEBUG("%s: ", G_STRFUNC); g_variant_dict_lookup (&dict, "Id", "u", &info->id); g_variant_dict_lookup (&dict, "UserName", "s", &info->username); if (g_variant_dict_lookup (&dict, "Secret", "s", &info->secret)) { g_variant_dict_lookup (&dict, "StoreSecret", "b", &info->store_secret); } g_variant_dict_lookup (&dict, "Caption", "s", &info->caption); g_variant_dict_lookup (&dict, "Realms", "^as", &info->realms); /* get the methods */ method_map = g_variant_dict_lookup_value (&dict, "AuthMethods", (const GVariantType *) "a{sas}"); if (method_map != NULL) { GVariantIter iter; gchar *method = NULL; gchar **mechanisms = NULL; g_variant_iter_init (&iter, method_map); while (g_variant_iter_next (&iter, "{s^as}", &method, &mechanisms)) { g_hash_table_insert (info->methods, method, mechanisms); } g_variant_unref (method_map); } acl_var = g_variant_dict_lookup_value (&dict, "ACL", (const GVariantType *) "a(ss)"); if (acl_var != NULL) { GVariantIter iter; GVariant *child = NULL; GList *acl_list = NULL; g_variant_iter_init (&iter, acl_var); while ((child = g_variant_iter_next_value (&iter))) { SignonSecurityContext *ctx = signon_security_context_new_from_variant (child); if (ctx != NULL) acl_list = g_list_append (acl_list, ctx); g_variant_unref (child); } info->access_control_list = acl_list; g_variant_unref (acl_var); } g_variant_dict_lookup (&dict, "Type", "u", &info->type); return info; } GVariant * signon_identity_info_to_variant (const SignonIdentityInfo *self) { GVariantBuilder builder; GVariantBuilder method_builder; GVariant *method_map; GHashTableIter iter; const gchar *method; const gchar **mechanisms; g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", "Id", g_variant_new_uint32 (self->id)); g_variant_builder_add (&builder, "{sv}", "UserName", signon_variant_new_string (self->username)); g_variant_builder_add (&builder, "{sv}", "Secret", signon_variant_new_string (self->secret)); g_variant_builder_add (&builder, "{sv}", "Caption", signon_variant_new_string (self->caption)); g_variant_builder_add (&builder, "{sv}", "StoreSecret", g_variant_new_boolean (self->store_secret)); g_variant_builder_init (&method_builder, (const GVariantType *)"a{sas}"); g_hash_table_iter_init (&iter, self->methods); while (g_hash_table_iter_next (&iter, (gpointer)&method, (gpointer)&mechanisms)) { g_variant_builder_add (&method_builder, "{s^as}", method, mechanisms); } method_map = g_variant_builder_end (&method_builder); g_variant_builder_add (&builder, "{sv}", "AuthMethods", method_map); if (self->realms != NULL) { g_variant_builder_add (&builder, "{sv}", "Realms", g_variant_new_strv ((const gchar * const *) self->realms, -1)); } if (self->access_control_list != NULL) { GVariantBuilder acl_builder; g_variant_builder_init (&acl_builder, (const GVariantType *)"a(ss)"); GList *l; for (l = self->access_control_list; l != NULL; l = l->next) { GVariant* acl_var = signon_security_context_to_variant (l->data); if (acl_var != NULL) g_variant_builder_add_value (&acl_builder, acl_var); } g_variant_builder_add (&builder, "{sv}", "ACL", g_variant_builder_end (&acl_builder)); } g_variant_builder_add (&builder, "{sv}", "Type", g_variant_new_uint32 (self->type)); return g_variant_builder_end (&builder); } /* * Public methods: */ /** * signon_identity_info_new: * * Creates a new #SignonIdentityInfo item. * * Returns: a new #SignonIdentityInfo item. */ SignonIdentityInfo *signon_identity_info_new () { SignonIdentityInfo *info = g_slice_new0 (SignonIdentityInfo); info->methods = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_strfreev); info->store_secret = FALSE; return info; } /** * signon_identity_info_free: * @info: the #SignonIdentityInfo. * * Destroys the given #SignonIdentityInfo item. */ void signon_identity_info_free (SignonIdentityInfo *info) { if (info == NULL) return; g_free (info->username); g_free (info->secret); g_free (info->caption); g_hash_table_destroy (info->methods); g_strfreev (info->realms); g_list_free_full (info->access_control_list, (GDestroyNotify)signon_security_context_free); g_slice_free (SignonIdentityInfo, info); } /** * signon_identity_info_copy: * @other: the #SignonIdentityInfo. * * Get a newly-allocated copy of @info. * * Returns: a copy of the given #SignonIdentityInfo, or %NULL on failure. */ SignonIdentityInfo *signon_identity_info_copy (const SignonIdentityInfo *other) { g_return_val_if_fail (other != NULL, NULL); SignonIdentityInfo *info = signon_identity_info_new (); identity_info_set_id (info, signon_identity_info_get_id (other)); signon_identity_info_set_username (info, signon_identity_info_get_username (other)); signon_identity_info_set_secret (info, identity_info_get_secret(other), signon_identity_info_get_storing_secret (other)); signon_identity_info_set_caption (info, signon_identity_info_get_caption(other)); signon_identity_info_set_methods (info, signon_identity_info_get_methods (other)); signon_identity_info_set_realms (info, signon_identity_info_get_realms (other)); signon_identity_info_set_access_control_list (info, signon_identity_info_get_access_control_list (other)); signon_identity_info_set_identity_type (info, signon_identity_info_get_identity_type (other)); return info; } /** * signon_identity_info_get_id: * @info: the #SignonIdentityInfo. * * Get the numeric ID of @info. * * Returns: the numeric ID of the identity. */ gint signon_identity_info_get_id (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, -1); return info->id; } /** * signon_identity_info_get_username: * @info: the #SignonIdentityInfo. * * Get the username of @info. * * Returns: the username, or %NULL. */ const gchar *signon_identity_info_get_username (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, NULL); return info->username; } /** * signon_identity_info_get_storing_secret: * @info: the #SignonIdentityInfo. * * Get whether the secret of @info should be stored. * * Returns: %TRUE if Signon must store the secret, %FALSE otherwise. */ gboolean signon_identity_info_get_storing_secret (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, FALSE); return info->store_secret; } /** * signon_identity_info_get_caption: * @info: the #SignonIdentityInfo. * * Get the display name of @info. * * Returns: the display name for the identity. */ const gchar *signon_identity_info_get_caption (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, NULL); return info->caption; } /** * signon_identity_info_get_methods: * @info: the #SignonIdentityInfo. * * Get a hash table of the methods and mechanisms of @info. * * Returns: (transfer none) (element-type utf8 GStrv): the table of allowed * methods and mechanisms. */ const GHashTable *signon_identity_info_get_methods (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, NULL); return info->methods; } /** * signon_identity_info_get_realms: * @info: the #SignonIdentityInfo. * * Get an array of the realms of @info. * * Returns: (transfer none): a %NULL terminated array of realms. */ const gchar* const *signon_identity_info_get_realms (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, NULL); return (const gchar* const *)info->realms; } /** * signon_identity_info_get_access_control_list: * @info: the #SignonIdentityInfo. * * Get an array of ACL statements of the identity. * * Returns: (transfer full) (element-type SignonSecurityContext): a #GList of * #SignonSecurityContext representing ACL statements. * Each element should be freed with signon_security_context_copy() after use. */ GList *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, NULL); return g_list_copy_deep (info->access_control_list, (GCopyFunc)signon_security_context_copy, NULL); } /** * signon_identity_info_get_identity_type: * @info: the #SignonIdentityInfo. * * Get the type of the identity. * * Returns: the type of the identity. */ SignonIdentityType signon_identity_info_get_identity_type (const SignonIdentityInfo *info) { g_return_val_if_fail (info != NULL, -1); return info->type; } /** * signon_identity_info_set_username: * @info: the #SignonIdentityInfo. * @username: the username. * * Sets the username for the identity. */ void signon_identity_info_set_username (SignonIdentityInfo *info, const gchar *username) { g_return_if_fail (info != NULL); if (info->username) g_free (info->username); info->username = g_strdup (username); } /** * signon_identity_info_set_secret: * @info: the #SignonIdentityInfo. * @secret: the secret. * @store_secret: whether signond should store the secret in its DB. * * Sets the secret (password) for the identity, and whether the signon daemon * should remember it. */ void signon_identity_info_set_secret (SignonIdentityInfo *info, const gchar *secret, gboolean store_secret) { g_return_if_fail (info != NULL); if (info->secret) g_free (info->secret); info->secret = g_strdup (secret); info->store_secret = store_secret; } /** * signon_identity_info_set_caption: * @info: the #SignonIdentityInfo. * @caption: the caption. * * Sets the caption (display name) for the identity. */ void signon_identity_info_set_caption (SignonIdentityInfo *info, const gchar *caption) { g_return_if_fail (info != NULL); if (info->caption) g_free (info->caption); info->caption = g_strdup (caption); } /** * signon_identity_info_set_method: * @info: the #SignonIdentityInfo. * @method: an authentication method. * @mechanisms: (array zero-terminated=1): a %NULL-termianted list of mechanisms. * * Adds a method to the list of allowed methods. If this method is not called * even once, then all methods are allowed. * Mechanisms are method-specific variants of authentication. */ void signon_identity_info_set_method (SignonIdentityInfo *info, const gchar *method, const gchar* const *mechanisms) { g_return_if_fail (info != NULL); g_return_if_fail (info->methods != NULL); g_return_if_fail (method != NULL); g_return_if_fail (mechanisms != NULL); g_hash_table_replace (info->methods, g_strdup(method), g_strdupv((gchar **)mechanisms)); } /** * signon_identity_info_remove_method: * @info: the #SignonIdentityInfo. * @method: an authentication method. * * Remove @method from the list of allowed authentication methods. If all * methods are removed, then all methods are allowed. */ void signon_identity_info_remove_method (SignonIdentityInfo *info, const gchar *method) { g_return_if_fail (info != NULL); g_return_if_fail (info->methods != NULL); g_hash_table_remove (info->methods, method); } /** * signon_identity_info_set_realms: * @info: the #SignonIdentityInfo. * @realms: (array zero-terminated=1): a %NULL-terminated list of realms. * * Specify what realms this identity can be used in. */ void signon_identity_info_set_realms (SignonIdentityInfo *info, const gchar* const *realms) { g_return_if_fail (info != NULL); if (info->realms) g_strfreev (info->realms); info->realms = g_strdupv ((gchar **)realms); } /** * signon_identity_info_set_access_control_list: * @info: the #SignonIdentityInfo. * @access_control_list: (element-type SignonSecurityContext): a #GList of * #SignonSecurityContext representing ACL security domains. * * Specifies the ACL for this identity. The actual meaning of the ACL depends * on the security framework used by signond. */ void signon_identity_info_set_access_control_list (SignonIdentityInfo *info, GList *access_control_list) { g_return_if_fail (info != NULL); if (info->access_control_list) g_list_free_full (info->access_control_list, (GDestroyNotify)signon_security_context_free); info->access_control_list = g_list_copy_deep (access_control_list, (GCopyFunc)signon_security_context_copy, NULL); } /** * signon_identity_info_add_access_control: * @info: the #SignonIdentityInfo. * @system_context: the system context to add. * @application_context: the application context to add. * * Add an ACL to this identity. This is an helper function. */ void signon_identity_info_add_access_control (SignonIdentityInfo *info, const gchar *system_context, const gchar *application_context) { SignonSecurityContext *ctx = NULL; g_return_if_fail (info != NULL); g_return_if_fail (system_context != NULL); g_return_if_fail (application_context != NULL); ctx = signon_security_context_new_from_values (system_context, application_context); info->access_control_list = g_list_append (info->access_control_list, ctx); } /** * signon_identity_info_set_identity_type: * @info: the #SignonIdentityInfo. * @type: the type of the identity. * * Specifies the type of this identity. */ void signon_identity_info_set_identity_type (SignonIdentityInfo *info, SignonIdentityType type) { g_return_if_fail (info != NULL); info->type = type; } 07070100000024000081A4000003E800000064000000015BDC2CEA00000F7B000000000000000000000000000000000000003900000000libsignon-glib-2.1/libsignon-glib/signon-identity-info.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2011-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SIGNON_IDENTITY_INFO_H_ #define _SIGNON_IDENTITY_INFO_H_ #include <glib-object.h> G_BEGIN_DECLS /** * SignonIdentityInfo: * * Opaque struct. Use the accessor functions below. */ typedef struct _SignonIdentityInfo SignonIdentityInfo; /** * SignonIdentityType: * @SIGNON_IDENTITY_TYPE_OTHER: an identity that is not an app, web or network * @SIGNON_IDENTITY_TYPE_APP: an application identity * @SIGNON_IDENTITY_TYPE_WEB: a web identity * @SIGNON_IDENTITY_TYPE_NETWORK: a network server identity * * Types used in #SignonIdentityInfo. */ typedef enum { SIGNON_IDENTITY_TYPE_OTHER = 0, SIGNON_IDENTITY_TYPE_APP = 1 << 0, SIGNON_IDENTITY_TYPE_WEB = 1 << 1, SIGNON_IDENTITY_TYPE_NETWORK = 1 << 2 } SignonIdentityType; GType signon_identity_info_get_type (void) G_GNUC_CONST; SignonIdentityInfo *signon_identity_info_new (); void signon_identity_info_free (SignonIdentityInfo *info); SignonIdentityInfo *signon_identity_info_copy (const SignonIdentityInfo *other); gint signon_identity_info_get_id (const SignonIdentityInfo *info); const gchar *signon_identity_info_get_username (const SignonIdentityInfo *info); gboolean signon_identity_info_get_storing_secret (const SignonIdentityInfo *info); const gchar *signon_identity_info_get_caption (const SignonIdentityInfo *info); const GHashTable *signon_identity_info_get_methods (const SignonIdentityInfo *info); const gchar* const *signon_identity_info_get_realms (const SignonIdentityInfo *info); GList *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info); SignonIdentityType signon_identity_info_get_identity_type (const SignonIdentityInfo *info); void signon_identity_info_set_username (SignonIdentityInfo *info, const gchar *username); void signon_identity_info_set_secret (SignonIdentityInfo *info, const gchar *secret, gboolean store_secret); void signon_identity_info_set_caption (SignonIdentityInfo *info, const gchar *caption); void signon_identity_info_set_method (SignonIdentityInfo *info, const gchar *method, const gchar* const *mechanisms); void signon_identity_info_remove_method (SignonIdentityInfo *info, const gchar *method); void signon_identity_info_set_realms (SignonIdentityInfo *info, const gchar* const *realms); void signon_identity_info_set_access_control_list (SignonIdentityInfo *info, GList *access_control_list); void signon_identity_info_add_access_control (SignonIdentityInfo *info, const gchar *system_context, const gchar *application_context); void signon_identity_info_set_identity_type (SignonIdentityInfo *info, SignonIdentityType type); G_END_DECLS #endif /* _SIGNON_IDENTITY_INFO_H_ */ 07070100000025000081A4000003E800000064000000015BDC2CEA0000A5BB000000000000000000000000000000000000003400000000libsignon-glib-2.1/libsignon-glib/signon-identity.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * SECTION:signon-identity * @title: SignonIdentity * @short_description: Client side presentation of a credential. * * The #SignonIdentity represents a database entry for a single identity. */ #include "signon-identity.h" #include "signon-auth-session.h" #include "signon-internals.h" #include "signon-proxy.h" #include "signon-errors.h" #include "sso-auth-service.h" #include "sso-identity-gen.h" #define SIGNON_RETURN_IF_CANCELLED(error) \ if (error != NULL && \ error->domain == G_IO_ERROR && \ error->code == G_IO_ERROR_CANCELLED) \ { \ g_error_free (error); \ return; \ } static void signon_identity_proxy_if_init (SignonProxyInterface *iface); static void signon_identity_set_id (SignonIdentity *identity, guint32 id); G_DEFINE_TYPE_WITH_CODE (SignonIdentity, signon_identity, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SIGNON_TYPE_PROXY, signon_identity_proxy_if_init)) enum { PROP_0, PROP_ID }; typedef enum { NOT_REGISTERED, PENDING_REGISTRATION, REGISTERED, } IdentityRegistrationState; typedef enum { DATA_UPDATED = 0, IDENTITY_REMOVED, IDENTITY_SIGNED_OUT } RemoteIdentityState; struct _SignonIdentityPrivate { SsoIdentity *proxy; SsoAuthService *auth_service_proxy; GCancellable *cancellable; SignonIdentityInfo *identity_info; GSList *sessions; IdentityRegistrationState registration_state; gboolean removed; gboolean signed_out; gboolean updated; gboolean first_registration; guint id; guint signal_info_updated; guint signal_unregistered; }; enum { SIGNEDOUT_SIGNAL, LAST_SIGNAL }; static guint signals[LAST_SIGNAL]; #define SIGNON_IDENTITY_PRIV(obj) (SIGNON_IDENTITY(obj)->priv) static void identity_check_remote_registration (SignonIdentity *self); static void identity_store_info_ready_cb (gpointer object, const GError *error, gpointer user_data); static void identity_store_info_reply (GObject *object, GAsyncResult *res, gpointer userdata); static void identity_session_object_destroyed_cb (gpointer data, GObject *where_the_session_was); static void identity_verify_ready_cb (gpointer object, const GError *error, gpointer user_data); static void identity_query_ready_cb (gpointer object, const GError *error, gpointer user_data); static void identity_remove_ready_cb (gpointer object, const GError *error, gpointer user_data); static void identity_signout_ready_cb (gpointer object, const GError *error, gpointer user_data); static void identity_process_signout (SignonIdentity *self); static void identity_process_updated (SignonIdentity *self); static void identity_process_removed (SignonIdentity *self); static GQuark identity_object_quark () { static GQuark quark = 0; if (!quark) quark = g_quark_from_static_string ("identity_object_quark"); return quark; } static void signon_identity_proxy_setup (SignonProxy *proxy) { identity_check_remote_registration (SIGNON_IDENTITY (proxy)); } static void signon_identity_proxy_if_init (SignonProxyInterface *iface) { iface->setup = signon_identity_proxy_setup; } static void signon_identity_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { SignonIdentity *self = SIGNON_IDENTITY (object); switch (property_id) { case PROP_ID: signon_identity_set_id (self, g_value_get_uint (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void signon_identity_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { SignonIdentity *self = SIGNON_IDENTITY (object); switch (property_id) { case PROP_ID: g_value_set_uint (value, signon_identity_get_id (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void signon_identity_init (SignonIdentity *identity) { SignonIdentityPrivate *priv; identity->priv = G_TYPE_INSTANCE_GET_PRIVATE (identity, SIGNON_TYPE_IDENTITY, SignonIdentityPrivate); priv = identity->priv; priv->auth_service_proxy = sso_auth_service_get_instance(); priv->cancellable = g_cancellable_new (); priv->registration_state = NOT_REGISTERED; priv->removed = FALSE; priv->signed_out = FALSE; priv->updated = FALSE; priv->first_registration = TRUE; } static void signon_identity_dispose (GObject *object) { SignonIdentity *identity = SIGNON_IDENTITY (object); SignonIdentityPrivate *priv = identity->priv; if (priv->cancellable) { g_cancellable_cancel (priv->cancellable); g_object_unref (priv->cancellable); priv->cancellable = NULL; } if (priv->identity_info) { signon_identity_info_free (priv->identity_info); priv->identity_info = NULL; } g_clear_object (&priv->auth_service_proxy); if (priv->proxy) { g_signal_handler_disconnect (priv->proxy, priv->signal_info_updated); g_signal_handler_disconnect (priv->proxy, priv->signal_unregistered); g_object_unref (priv->proxy); priv->proxy = NULL; } if (priv->sessions) g_critical ("SignonIdentity: the list of AuthSessions MUST be empty"); G_OBJECT_CLASS (signon_identity_parent_class)->dispose (object); } static void signon_identity_finalize (GObject *object) { G_OBJECT_CLASS (signon_identity_parent_class)->finalize (object); } static void signon_identity_class_init (SignonIdentityClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GParamSpec *pspec; object_class->set_property = signon_identity_set_property; object_class->get_property = signon_identity_get_property; pspec = g_param_spec_uint ("id", "Identity ID", "Set/Get Identity ID", 0, G_MAXUINT, 0, G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property (object_class, PROP_ID, pspec); g_type_class_add_private (object_class, sizeof (SignonIdentityPrivate)); /** * SignonIdentity::signed-out: * * Emitted when the identity was signed out. */ signals[SIGNEDOUT_SIGNAL] = g_signal_new("signed-out", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0 /* class closure */, NULL /* accumulator */, NULL /* accu_data */, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE /* return_type */, 0); object_class->dispose = signon_identity_dispose; object_class->finalize = signon_identity_finalize; } static void identity_state_changed_cb (GDBusProxy *proxy, gint state, gpointer user_data) { g_return_if_fail (SIGNON_IS_IDENTITY (user_data)); SignonIdentity *self = SIGNON_IDENTITY (user_data); switch (state) { case DATA_UPDATED: DEBUG ("State changed to DATA_UPDATED"); identity_process_updated (self); break; case IDENTITY_REMOVED: DEBUG ("State changed to IDENTITY_REMOVED"); identity_process_removed (self); break; case IDENTITY_SIGNED_OUT: DEBUG ("State changed to IDENTITY_SIGNED_OUT"); identity_process_signout (self); break; default: g_critical ("wrong state value obtained from signon daemon"); }; } static void identity_remote_object_destroyed_cb(GDBusProxy *proxy, gpointer user_data) { g_return_if_fail (SIGNON_IS_IDENTITY (user_data)); SignonIdentity *self = SIGNON_IDENTITY (user_data); SignonIdentityPrivate *priv = self->priv; g_return_if_fail (priv != NULL); if (priv->proxy) { g_object_unref (priv->proxy); priv->proxy = NULL; } DEBUG ("%s %d", G_STRFUNC, __LINE__); signon_proxy_set_not_ready (self); priv->registration_state = NOT_REGISTERED; signon_identity_info_free (priv->identity_info); priv->identity_info = NULL; priv->removed = FALSE; priv->signed_out = FALSE; priv->updated = FALSE; } static void identity_registered (SignonIdentity *identity, char *object_path, GVariant *identity_data, GError *error) { g_return_if_fail (SIGNON_IS_IDENTITY (identity)); SignonIdentityPrivate *priv; priv = identity->priv; g_return_if_fail (priv != NULL); if (!error) { GDBusConnection *connection; GDBusProxy *auth_service_proxy; const gchar *bus_name; GError *proxy_error = NULL; DEBUG("%s: %s", G_STRFUNC, object_path); /* * TODO: as Aurel will finalize the code polishing so we will * need to implement the refresh of the proxy to SignonIdentity * */ g_return_if_fail (priv->proxy == NULL); auth_service_proxy = (GDBusProxy *)priv->auth_service_proxy; connection = g_dbus_proxy_get_connection (auth_service_proxy); bus_name = g_dbus_proxy_get_name (auth_service_proxy); priv->proxy = sso_identity_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, bus_name, object_path, priv->cancellable, &proxy_error); if (G_UNLIKELY (proxy_error != NULL)) { g_warning ("Failed to initialize Identity proxy: %s", proxy_error->message); g_clear_error (&proxy_error); } priv->signal_info_updated = g_signal_connect (priv->proxy, "info-updated", G_CALLBACK (identity_state_changed_cb), identity); priv->signal_unregistered = g_signal_connect (priv->proxy, "unregistered", G_CALLBACK (identity_remote_object_destroyed_cb), identity); if (identity_data) { DEBUG("%s: ", G_STRFUNC); priv->identity_info = signon_identity_info_new_from_variant (identity_data); g_variant_unref (identity_data); } priv->updated = TRUE; } else if (error->domain == G_DBUS_ERROR && error->code == G_DBUS_ERROR_SERVICE_UNKNOWN) { /* This can happen if signond quits and the GDBusProxy is not notified * about it -- typically because the main loop was not being run. * We try the registration once more. */ if (priv->first_registration) { DEBUG ("Service unknown; retrying registration"); g_error_free (error); priv->first_registration = FALSE; priv->registration_state = NOT_REGISTERED; identity_check_remote_registration (identity); return; } else { g_warning ("%s, second failure: %s", G_STRFUNC, error->message); } } else g_warning ("%s: %s", G_STRFUNC, error->message); /* * execute queued operations or emit errors on each of them * */ priv->registration_state = REGISTERED; /* * TODO: if we will add a new state for identity: "INVALID" * consider emission of another error, like "invalid" * */ signon_proxy_set_ready (identity, identity_object_quark (), error); /* * as the registration failed we do not * request for new registration, but emit * same error again and again * */ } /** * signon_identity_get_id: * @identity: the #SignonIdentity. * * Get the id of the @identity. * * Since: 2.0 * * Returns: the id of the #SignonIdentity, or 0 if the identity has not being * registered. */ guint32 signon_identity_get_id (SignonIdentity *identity) { g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), 0); g_return_val_if_fail (identity->priv != NULL, 0); return identity->priv->id; } static void signon_identity_set_id (SignonIdentity *identity, guint32 id) { g_return_if_fail (SIGNON_IS_IDENTITY (identity)); g_return_if_fail (identity->priv != NULL); if (identity->priv->id != id) { identity->priv->id = id; g_object_notify (G_OBJECT (identity), "id"); } } /** * signon_identity_get_last_error: * @identity: the #SignonIdentity. * * Get the most recent error that occurred on @identity. * * Returns: a #GError containing the most recent error, or %NULL on failure. */ const GError * signon_identity_get_last_error (SignonIdentity *identity) { g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), NULL); return signon_proxy_get_last_error (identity); } static void identity_new_cb (GObject *object, GAsyncResult *res, gpointer userdata) { SignonIdentity *identity = (SignonIdentity*)userdata; SsoAuthService *proxy = SSO_AUTH_SERVICE (object); gchar *object_path = NULL; GError *error = NULL; g_return_if_fail (identity != NULL); DEBUG ("%s", G_STRFUNC); sso_auth_service_call_register_new_identity_finish (proxy, &object_path, res, &error); SIGNON_RETURN_IF_CANCELLED (error); identity_registered (identity, object_path, NULL, error); g_free (object_path); } static void identity_new_from_db_cb (GObject *object, GAsyncResult *res, gpointer userdata) { SignonIdentity *identity = (SignonIdentity*)userdata; SsoAuthService *proxy = SSO_AUTH_SERVICE (object); gchar *object_path = NULL; GVariant *identity_data; GError *error = NULL; g_return_if_fail (identity != NULL); DEBUG ("%s", G_STRFUNC); sso_auth_service_call_get_identity_finish (proxy, &object_path, &identity_data, res, &error); SIGNON_RETURN_IF_CANCELLED (error); identity_registered (identity, object_path, identity_data, error); g_free (object_path); } static void identity_check_remote_registration (SignonIdentity *self) { g_return_if_fail (self != NULL); SignonIdentityPrivate *priv = self->priv; g_return_if_fail (priv != NULL); if (priv->registration_state != NOT_REGISTERED) return; /* TODO: implement the application security context */ if (priv->id != 0) sso_auth_service_call_get_identity (priv->auth_service_proxy, priv->id, "*", priv->cancellable, identity_new_from_db_cb, self); else sso_auth_service_call_register_new_identity (priv->auth_service_proxy, "*", priv->cancellable, identity_new_cb, self); priv->registration_state = PENDING_REGISTRATION; } /** * signon_identity_new_from_db: * @id: identity ID. * * Construct an identity object associated with an existing identity * record. * * Returns: an instance of a #SignonIdentity. */ SignonIdentity* signon_identity_new_from_db (guint32 id) { SignonIdentity *identity; DEBUG ("%s %d: %d\n", G_STRFUNC, __LINE__, id); if (id == 0) return NULL; identity = g_object_new (SIGNON_TYPE_IDENTITY, "id", id, NULL); g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), NULL); g_return_val_if_fail (identity->priv != NULL, NULL); identity_check_remote_registration (identity); return identity; } /** * signon_identity_new: * * Construct new, empty, identity object. * * Returns: an instance of an #SignonIdentity. */ SignonIdentity* signon_identity_new () { DEBUG ("%s %d", G_STRFUNC, __LINE__); SignonIdentity *identity = g_object_new (SIGNON_TYPE_IDENTITY, NULL); g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), NULL); g_return_val_if_fail (identity->priv != NULL, NULL); identity_check_remote_registration (identity); return identity; } static void identity_session_object_destroyed_cb(gpointer data, GObject *where_the_session_was) { g_return_if_fail (SIGNON_IS_IDENTITY (data)); DEBUG ("%s %d", G_STRFUNC, __LINE__); SignonIdentity *self = SIGNON_IDENTITY (data); SignonIdentityPrivate *priv = self->priv; g_return_if_fail (priv != NULL); priv->sessions = g_slist_remove(priv->sessions, (gpointer)where_the_session_was); g_object_unref (self); } /** * signon_identity_create_session: * @self: the #SignonIdentity. * @method: method. * @error: pointer to a location which will receive the error, if any. * * Creates an authentication session for this identity. * * Returns: (transfer full): a new #SignonAuthSession. */ SignonAuthSession * signon_identity_create_session(SignonIdentity *self, const gchar *method, GError **error) { g_return_val_if_fail (SIGNON_IS_IDENTITY (self), NULL); SignonIdentityPrivate *priv = self->priv; g_return_val_if_fail (priv != NULL, NULL); DEBUG ("%s %d", G_STRFUNC, __LINE__); if (method == NULL) { DEBUG ("NULL method as input. Aborting."); g_set_error(error, signon_error_quark(), SIGNON_ERROR_UNKNOWN, "NULL input method."); return NULL; } GSList *list = priv->sessions; while (list) { SignonAuthSession *session = SIGNON_AUTH_SESSION (priv->sessions->data); const gchar *sessionMethod = signon_auth_session_get_method (session); if (g_strcmp0(sessionMethod, method) == 0) { DEBUG ("Auth Session with method `%s` already created.", method); g_set_error (error, signon_error_quark(), SIGNON_ERROR_METHOD_NOT_AVAILABLE, "Authentication session for this method already requested."); return NULL; } list = list->next; } SignonAuthSession *session = signon_auth_session_new (priv->id, method, error); if (session) { DEBUG ("%s %d", G_STRFUNC, __LINE__); priv->sessions = g_slist_append(priv->sessions, session); g_object_weak_ref (G_OBJECT(session), identity_session_object_destroyed_cb, self); /* * if you want to delete the identity * you MUST delete all authsessions * first * */ g_object_ref (self); priv->signed_out = FALSE; } return session; } /** * signon_identity_store_info: * @self: the #SignonIdentity. * @info: the #SignonIdentityInfo data to store. * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore. * @callback: a callback which will be called when the * authentication reply is available. * @user_data: user data to be passed to the callback. * * Stores the data from @info into the identity. * * Since: 2.0 */ void signon_identity_store_info (SignonIdentity *self, const SignonIdentityInfo *info, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = NULL; GVariant *info_variant = NULL; DEBUG (); g_return_if_fail (SIGNON_IS_IDENTITY (self)); g_return_if_fail (info != NULL); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, signon_identity_store_info); info_variant = signon_identity_info_to_variant (info); g_task_set_task_data (task, g_variant_ref_sink (info_variant), (GDestroyNotify)g_variant_unref); signon_proxy_call_when_ready (self, identity_object_quark(), identity_store_info_ready_cb, task); } /** * signon_identity_store_info_finish: * @self: the #SignonIdentity. * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to * signon_identity_store_info(). * @error: return location for error, or %NULL. * * Collect the result of the signon_identity_store_info() operation. * * Returns: %TRUE if the info has been stored, %FALSE otherwise. */ gboolean signon_identity_store_info_finish (SignonIdentity *self, GAsyncResult *res, GError **error) { g_return_val_if_fail (g_task_is_valid (res, self), FALSE); return g_task_propagate_boolean (G_TASK (res), error); } static void identity_store_info_ready_cb (gpointer object, const GError *error, gpointer user_data) { g_return_if_fail (SIGNON_IS_IDENTITY (object)); SignonIdentity *self = SIGNON_IDENTITY (object); SignonIdentityPrivate *priv = self->priv; g_return_if_fail (priv != NULL); DEBUG ("%s %d", G_STRFUNC, __LINE__); GTask *task = (GTask *)user_data; g_return_if_fail (task != NULL); if (error) { DEBUG ("IdentityError: %s", error->message); g_task_return_error (task, g_error_copy (error)); g_object_unref (task); } else { g_return_if_fail (priv->proxy != NULL); sso_identity_call_store (priv->proxy, g_task_get_task_data (task), g_task_get_cancellable (task), identity_store_info_reply, task); } } static void identity_store_info_reply (GObject *object, GAsyncResult *res, gpointer userdata) { GTask *task = (GTask *)userdata; SsoIdentity *proxy = SSO_IDENTITY (object); SignonIdentity *self = NULL; SignonIdentityPrivate *priv = NULL; GError *error = NULL; guint id; g_return_if_fail (task != NULL); self = g_task_get_source_object (task); g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); priv = self->priv; if (sso_identity_call_store_finish (proxy, &id, res, &error)) { GSList *slist = priv->sessions; g_return_if_fail (priv->identity_info == NULL); while (slist) { SignonAuthSession *session = SIGNON_AUTH_SESSION (priv->sessions->data); signon_auth_session_set_id (session, id); slist = g_slist_next (slist); } signon_identity_set_id (self, id); /* * if the previous state was REMOVED * then we need to reset it * */ priv->removed = FALSE; g_task_return_boolean (task, TRUE); } else { g_task_return_error (task, error); } g_object_unref (task); } static void identity_verify_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SsoIdentity *proxy = SSO_IDENTITY (object); gboolean valid; GError *error = NULL; GTask *task = (GTask *)userdata; g_return_if_fail (task != NULL); if (!sso_identity_call_verify_secret_finish (proxy, &valid, res, &error)) { g_task_return_error (task, error); g_object_unref (task); return; } g_task_return_boolean (task, TRUE); g_object_unref (task); } static void identity_verify_ready_cb (gpointer object, const GError *error, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)object; SignonIdentityPrivate *priv = NULL; GTask *task = (GTask *)user_data; g_return_if_fail (SIGNON_IS_IDENTITY (self)); g_return_if_fail (self->priv != NULL); priv = self->priv; DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (task != NULL); if (priv->removed == TRUE) { g_task_return_new_error (task, signon_error_quark (), SIGNON_ERROR_IDENTITY_NOT_FOUND, "Already removed from database."); g_object_unref (task); } else if (error) { DEBUG ("IdentityError: %s", error->message); g_task_return_error (task, g_error_copy (error)); g_object_unref (task); } else { DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (priv->proxy != NULL); sso_identity_call_verify_secret (priv->proxy, g_task_get_task_data (task), g_task_get_cancellable (task), identity_verify_reply, task); } } /** * signon_identity_verify_secret: * @self: the #SignonIdentity. * @secret: the secret (password) to be verified. * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore. * @callback: a callback which will be called when the verification is done. * @user_data: user data to be passed to the callback. * * Verifies the given secret. * * Since: 2.0 */ void signon_identity_verify_secret (SignonIdentity *self, const gchar *secret, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = NULL; g_return_if_fail (SIGNON_IS_IDENTITY (self)); DEBUG ("%s %d", G_STRFUNC, __LINE__); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, signon_identity_verify_secret); g_task_set_task_data (task, g_strdup (secret), (GDestroyNotify)g_free); signon_proxy_call_when_ready (self, identity_object_quark(), identity_verify_ready_cb, task); } /** * signon_identity_verify_secret_finish: * @self: the #SignonIdentity. * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to * signon_identity_verify_secret(). * @error: return location for error, or %NULL. * * Collect the result of the signon_identity_verify_secret() operation. * * Returns: %TRUE if the secret is valid, %FALSE otherwise. */ gboolean signon_identity_verify_secret_finish (SignonIdentity *self, GAsyncResult *res, GError **error) { g_return_val_if_fail (g_task_is_valid (res, self), FALSE); return g_task_propagate_boolean (G_TASK (res), error); } static void identity_process_updated (SignonIdentity *self) { DEBUG ("%d %s", __LINE__, __func__); g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); SignonIdentityPrivate *priv = self->priv; g_return_if_fail (priv->proxy != NULL); signon_identity_info_free (priv->identity_info); priv->identity_info = NULL; priv->updated = FALSE; } static void identity_process_removed (SignonIdentity *self) { g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); DEBUG ("%d %s", __LINE__, __func__); SignonIdentityPrivate *priv = self->priv; if (priv->removed == TRUE) return; priv->removed = TRUE; signon_identity_info_free (priv->identity_info); priv->identity_info = NULL; signon_identity_set_id (self, 0); } static void identity_process_signout(SignonIdentity *self) { g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); DEBUG ("%d %s", __LINE__, __func__); SignonIdentityPrivate *priv = self->priv; if (priv->signed_out == TRUE) return; GSList *llink = priv->sessions; while (llink) { GSList *next = llink->next; g_object_unref (G_OBJECT(llink->data)); llink = next; } priv->signed_out = TRUE; g_signal_emit(G_OBJECT(self), signals[SIGNEDOUT_SIGNAL], 0); } static void identity_signout_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SsoIdentity *proxy = SSO_IDENTITY (object); GError *error = NULL; GTask *task = (GTask *)userdata; SignonIdentity *self = NULL; gboolean result = TRUE; g_return_if_fail (task != NULL); self = g_task_get_source_object (task); g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); if (sso_identity_call_sign_out_finish (proxy, &result, res, &error)) { // FIXME: there is an issue in signond that makes result always return FALSE //if (result) g_task_return_boolean (task, TRUE); /*else g_task_return_new_error (task, signon_error_quark (), SIGNON_ERROR_SIGNOUT_FAILED, "The Daemon could not Sign out the Identity.");*/ } else g_task_return_error (task, error); g_object_unref (task); } static void identity_removed_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SsoIdentity *proxy = SSO_IDENTITY (object); GError *error = NULL; GTask *task = (GTask *)userdata; SignonIdentity *self = NULL; g_return_if_fail (task != NULL); self = g_task_get_source_object (task); g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); if (sso_identity_call_remove_finish (proxy, res, &error)) g_task_return_boolean (task, TRUE); else g_task_return_error (task, error); g_object_unref (task); } static void identity_signout_ready_cb(gpointer object, const GError *error, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)object; SignonIdentityPrivate *priv = NULL; GTask *task = (GTask *)user_data; g_return_if_fail (SIGNON_IS_IDENTITY (self)); g_return_if_fail (self->priv != NULL); priv = self->priv; DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (task != NULL); if (priv->removed == TRUE) { g_task_return_new_error (task, signon_error_quark (), SIGNON_ERROR_IDENTITY_NOT_FOUND, "Already removed from database."); g_object_unref (task); } else if (error) { DEBUG ("IdentityError: %s", error->message); g_task_return_error (task, g_error_copy (error)); g_object_unref (task); } else { DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (priv->proxy != NULL); sso_identity_call_sign_out (priv->proxy, priv->cancellable, identity_signout_reply, task); } } static void identity_remove_ready_cb (gpointer object, const GError *error, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)object; SignonIdentityPrivate *priv = NULL; GTask *task = (GTask *)user_data; g_return_if_fail (SIGNON_IS_IDENTITY (self)); g_return_if_fail (self->priv != NULL); priv = self->priv; DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (task != NULL); if (priv->removed == TRUE) { g_task_return_new_error (task, signon_error_quark (), SIGNON_ERROR_IDENTITY_NOT_FOUND, "Already removed from database."); g_object_unref (task); } else if (error) { DEBUG ("IdentityError: %s", error->message); g_task_return_error (task, g_error_copy (error)); g_object_unref (task); } else { DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (priv->proxy != NULL); sso_identity_call_remove (priv->proxy, g_task_get_cancellable (task), identity_removed_reply, task); } } /** * signon_identity_remove: * @self: the #SignonIdentity. * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore. * @callback: a callback which will be called when the operation has completed. * @user_data: user data to be passed to the callback. * * Removes the corresponding credentials record from the database. * * Since: 2.0 */ void signon_identity_remove (SignonIdentity *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = NULL; g_return_if_fail (SIGNON_IS_IDENTITY (self)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, signon_identity_remove); signon_proxy_call_when_ready (self, identity_object_quark (), identity_remove_ready_cb, task); } gboolean signon_identity_remove_finish (SignonIdentity *self, GAsyncResult *res, GError **error) { g_return_val_if_fail (g_task_is_valid (res, self), FALSE); return g_task_propagate_boolean (G_TASK (res), error); } /** * signon_identity_sign_out: * @self: the #SignonIdentity. * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore. * @callback: a callback which will be called when the operation has completed. * @user_data: user data to be passed to the callback. * * Asks signond to close all authentication sessions for this * identity, and to remove any stored secrets associated with it (password and * authentication tokens). * * Since: 2.0 */ void signon_identity_sign_out (SignonIdentity *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = NULL; g_return_if_fail (SIGNON_IS_IDENTITY (self)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, signon_identity_sign_out); signon_proxy_call_when_ready (self, identity_object_quark(), identity_signout_ready_cb, task); } gboolean signon_identity_sign_out_finish (SignonIdentity *self, GAsyncResult *res, GError **error) { g_return_val_if_fail (g_task_is_valid (res, self), FALSE); return g_task_propagate_boolean (G_TASK (res), error); } static void identity_query_info_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SsoIdentity *proxy = SSO_IDENTITY (object); SignonIdentity *self = NULL; SignonIdentityPrivate *priv = NULL; GVariant *identity_data = NULL; GError *error = NULL; GTask *task = (GTask *)userdata; DEBUG ("%d %s", __LINE__, __func__); g_return_if_fail (task != NULL); self = g_task_get_source_object (task); g_return_if_fail (self != NULL); g_return_if_fail (self->priv != NULL); priv = self->priv; if (sso_identity_call_get_info_finish (proxy, &identity_data, res, &error)) { if (priv->identity_info) g_clear_pointer (&priv->identity_info, (GDestroyNotify)signon_identity_info_free); priv->identity_info = signon_identity_info_new_from_variant (identity_data); g_variant_unref (identity_data); signon_identity_set_id (self, signon_identity_info_get_id (priv->identity_info)); priv->updated = TRUE; g_task_return_pointer (task, signon_identity_info_copy (priv->identity_info), (GDestroyNotify)signon_identity_info_free); } else { g_task_return_error (task, error); } g_object_unref (task); } static void identity_query_ready_cb (gpointer object, const GError *error, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)object; SignonIdentityPrivate *priv = NULL; GTask *task = (GTask *)user_data; g_return_if_fail (SIGNON_IS_IDENTITY (self)); g_return_if_fail (self->priv != NULL); priv = self->priv; DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (task != NULL); if (priv->removed == TRUE) { DEBUG ("Already removed from database."); g_task_return_new_error (task, signon_error_quark (), SIGNON_ERROR_IDENTITY_NOT_FOUND, "Already removed from database."); g_object_unref (task); } else if (error) { DEBUG ("IdentityError: %s", error->message); g_task_return_error (task, g_error_copy (error)); g_object_unref (task); } else if (priv->id == 0) { DEBUG ("Identity is not stored and has no info yet"); g_task_return_new_error (task, signon_error_quark (), SIGNON_ERROR_IDENTITY_NOT_FOUND, "Identity is not stored and has no info yet"); g_object_unref (task); } else if (priv->updated == FALSE || priv->identity_info == NULL) { DEBUG ("%s %d", G_STRFUNC, __LINE__); g_return_if_fail (priv->proxy != NULL); sso_identity_call_get_info (priv->proxy, g_task_get_cancellable (task), identity_query_info_reply, task); } else { DEBUG ("%s %d", G_STRFUNC, __LINE__); g_task_return_pointer (task, signon_identity_info_copy (priv->identity_info), (GDestroyNotify)signon_identity_info_free); g_object_unref (task); } } /** * signon_identity_query_info: * @self: the #SignonIdentity. * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore. * @callback: a callback which will be called when the #SignonIdentityInfo is * available. * @user_data: user data to be passed to the callback. * * Fetches the #SignonIdentityInfo associated with this identity. * * Since: 2.0 */ void signon_identity_query_info (SignonIdentity *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = NULL; g_return_if_fail (SIGNON_IS_IDENTITY (self)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, signon_identity_query_info); signon_proxy_call_when_ready (self, identity_object_quark (), identity_query_ready_cb, task); } /** * signon_identity_query_info_finish: * @self: the #SignonIdentity. * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to * signon_identity_query_info(). * @error: return location for error, or %NULL. * * Collect the result of the signon_identity_query_info() operation. * * Returns: the #SignonIdentityInfo associated with this identity. */ SignonIdentityInfo * signon_identity_query_info_finish (SignonIdentity *self, GAsyncResult *res, GError **error) { g_return_val_if_fail (g_task_is_valid (res, self), NULL); return g_task_propagate_pointer (G_TASK (res), error); } 07070100000026000081A4000003E800000064000000015BDC2CEA000013DE000000000000000000000000000000000000003400000000libsignon-glib-2.1/libsignon-glib/signon-identity.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SIGNON_IDENTITY_H_ #define _SIGNON_IDENTITY_H_ #include <libsignon-glib/signon-auth-session.h> #include <libsignon-glib/signon-identity-info.h> #include <glib-object.h> G_BEGIN_DECLS #define SIGNON_TYPE_IDENTITY (signon_identity_get_type ()) #define SIGNON_IDENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_IDENTITY, SignonIdentity)) #define SIGNON_IDENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_IDENTITY, SignonIdentityClass)) #define SIGNON_IS_IDENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_IDENTITY)) #define SIGNON_IS_IDENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_IDENTITY)) #define SIGNON_IDENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_IDENTITY, SignonIdentityClass)) typedef struct _SignonIdentityClass SignonIdentityClass; typedef struct _SignonIdentityPrivate SignonIdentityPrivate; typedef struct _SignonIdentity SignonIdentity; /** * SignonIdentityClass: * * Opaque struct. Use the accessor functions below. */ struct _SignonIdentityClass { GObjectClass parent_class; }; /** * SignonIdentity: * * Opaque struct. Use the accessor functions below. */ struct _SignonIdentity { GObject parent_instance; SignonIdentityPrivate *priv; }; GType signon_identity_get_type (void) G_GNUC_CONST; SignonIdentity *signon_identity_new_from_db (guint32 id); SignonIdentity *signon_identity_new (); guint32 signon_identity_get_id (SignonIdentity *identity); const GError *signon_identity_get_last_error (SignonIdentity *identity); SignonAuthSession *signon_identity_create_session(SignonIdentity *self, const gchar *method, GError **error); void signon_identity_store_info (SignonIdentity *self, const SignonIdentityInfo *info, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean signon_identity_store_info_finish (SignonIdentity *self, GAsyncResult *res, GError **error); void signon_identity_verify_secret (SignonIdentity *self, const gchar *secret, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean signon_identity_verify_secret_finish (SignonIdentity *self, GAsyncResult *res, GError **error); void signon_identity_query_info (SignonIdentity *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); SignonIdentityInfo *signon_identity_query_info_finish (SignonIdentity *self, GAsyncResult *res, GError **error); void signon_identity_remove (SignonIdentity *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean signon_identity_remove_finish (SignonIdentity *self, GAsyncResult *res, GError **error); void signon_identity_sign_out (SignonIdentity *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean signon_identity_sign_out_finish (SignonIdentity *self, GAsyncResult *res, GError **error); G_END_DECLS #endif /* _SIGNON_IDENTITY_H_ */ 07070100000027000081A4000003E800000064000000015BDC2CEA00001619000000000000000000000000000000000000003500000000libsignon-glib-2.1/libsignon-glib/signon-internals.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SIGNONINTERNALS_H_ #define _SIGNONINTERNALS_H_ #ifndef SIGNON_TRACE #define SIGNON_TRACE #endif #ifdef SIGNON_TRACE #define DEBUG(format...) g_debug (G_STRLOC ": " format) #else #define DEBUG(...) do {} while (0) #endif #include "signon-identity.h" #include "signon-auth-session.h" #include "signon-security-context.h" G_BEGIN_DECLS struct _SignonIdentityInfo { gint id; gchar *username; gchar *secret; gchar *caption; gboolean store_secret; GHashTable *methods; gchar **realms; GList *access_control_list; SignonIdentityType type; }; struct _SignonSecurityContext { gchar *system_context; gchar *application_context; }; #define SIGNOND_SERVICE_PREFIX "com.google.code.AccountsSSO.SingleSignOn" #define SIGNON_DBUS_ERROR_PREFIX SIGNOND_SERVICE_PREFIX ".Error." #define SIGNOND_DAEMON_OBJECTPATH "/com/google/code/AccountsSSO/SingleSignOn" /* * Common server/client sides error names and messages * */ #define SIGNOND_UNKNOWN_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "Unknown" #define SIGNOND_INTERNAL_SERVER_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "InternalServer" #define SIGNOND_INTERNAL_COMMUNICATION_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "InternalCommunication" #define SIGNOND_PERMISSION_DENIED_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "PermissionDenied" #define SIGNOND_METHOD_OR_MECHANISM_NOT_ALLOWED_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "MethodOrMechanismNotAllowed" #define SIGNOND_ENCRYPTION_FAILED_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "EncryptionFailed" #define SIGNOND_METHOD_NOT_KNOWN_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "MethodNotKnown" #define SIGNOND_SERVICE_NOT_AVAILABLE_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "ServiceNotAvailable" #define SIGNOND_INVALID_QUERY_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "InvalidQuery" #define SIGNOND_METHOD_NOT_AVAILABLE_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "MethodNotAvailable" #define SIGNOND_IDENTITY_NOT_FOUND_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "IdentityNotFound" #define SIGNOND_STORE_FAILED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "StoreFailed" #define SIGNOND_REMOVE_FAILED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "RemoveFailed" #define SIGNOND_SIGNOUT_FAILED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "SignOutFailed" #define SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "IdentityOperationCanceled" #define SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "CredentialsNotAvailable" #define SIGNOND_REFERENCE_NOT_FOUND_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "ReferenceNotFound" #define SIGNOND_MECHANISM_NOT_AVAILABLE_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "MechanismNotAvailable" #define SIGNOND_MISSING_DATA_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "MissingData" #define SIGNOND_INVALID_CREDENTIALS_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "InvalidCredentials" #define SIGNOND_NOT_AUTHORIZED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "NotAuthorized" #define SIGNOND_WRONG_STATE_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "WrongState" #define SIGNOND_OPERATION_NOT_SUPPORTED_ERR_NAME \ SIGNON_DBUS_ERROR_PREFIX "OperationNotSupported" #define SIGNOND_NO_CONNECTION_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "NoConnection" #define SIGNOND_NETWORK_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "Network" #define SIGNOND_SSL_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "Ssl" #define SIGNOND_RUNTIME_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "Runtime" #define SIGNOND_SESSION_CANCELED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "SessionCanceled" #define SIGNOND_TIMED_OUT_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "TimedOut" #define SIGNOND_USER_INTERACTION_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "UserInteraction" #define SIGNOND_OPERATION_FAILED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "OperationFailed" #define SIGNOND_TOS_NOT_ACCEPTED_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "TOSNotAccepted" #define SIGNOND_FORGOT_PASSWORD_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "ForgotPassword" #define SIGNOND_INCORRECT_DATE_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "IncorrectDate" #define SIGNOND_USER_ERROR_ERR_NAME SIGNON_DBUS_ERROR_PREFIX "User" G_GNUC_INTERNAL SignonIdentityInfo * signon_identity_info_new_from_variant (GVariant *variant); G_GNUC_INTERNAL GVariant * signon_identity_info_to_variant (const SignonIdentityInfo *self); G_GNUC_INTERNAL SignonSecurityContext * signon_security_context_new_from_variant (GVariant *variant); G_GNUC_INTERNAL GVariant * signon_security_context_to_variant (const SignonSecurityContext *self); G_GNUC_INTERNAL void signon_identity_info_set_methods (SignonIdentityInfo *self, const GHashTable *methods); G_GNUC_INTERNAL void signon_auth_session_set_id(SignonAuthSession* self, gint32 id); G_END_DECLS #endif 07070100000028000081A4000003E800000064000000015BDC2CEA00000011000000000000000000000000000000000000003600000000libsignon-glib-2.1/libsignon-glib/signon-marshal.listVOID:INT,STRING 07070100000029000081A4000003E800000064000000015BDC2CEA00001843000000000000000000000000000000000000003100000000libsignon-glib-2.1/libsignon-glib/signon-proxy.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #include "signon-proxy.h" #include "signon-internals.h" G_DEFINE_INTERFACE (SignonProxy, signon_proxy, G_TYPE_OBJECT) typedef struct { SignonReadyCb callback; gpointer user_data; } SignonReadyCbData; typedef struct { gpointer self; GSList *callbacks; GSource *idle_source; } SignonReadyData; static void signon_proxy_default_init (SignonProxyInterface *iface) { /* add properties and signals to the interface here */ } static GQuark _signon_proxy_ready_quark() { static GQuark quark = 0; if (!quark) quark = g_quark_from_static_string ("signon_proxy_ready_quark"); return quark; } static GQuark _signon_proxy_error_quark() { static GQuark quark = 0; if (!quark) quark = g_quark_from_static_string ("signon_proxy_error_quark"); return quark; } static void signon_proxy_invoke_ready_callbacks (SignonReadyData *rd, const GError *error) { GSList *list; /* Make a copy of the callbacks list and erase the pointer in the * structure, to ensure that we won't invoke the same callback twice. */ GSList *callbacks = rd->callbacks; rd->callbacks = NULL; for (list = callbacks; list != NULL; list = list->next) { SignonReadyCbData *cb = list->data; cb->callback (rd->self, error, cb->user_data); g_slice_free (SignonReadyCbData, cb); } g_slist_free (callbacks); } static void signon_ready_data_free (SignonReadyData *rd) { if (rd->self) { //TODO: Signon error codes need be presented instead of 555 and 666 GError error = { 555, 666, "Object disposed" }; signon_proxy_invoke_ready_callbacks (rd, &error); } if (rd->idle_source) { g_main_context_unref (g_source_get_context (rd->idle_source)); g_source_destroy (rd->idle_source); rd->idle_source = NULL; } g_slice_free (SignonReadyData, rd); } static gboolean signon_proxy_call_when_ready_idle (SignonReadyData *rd) { if (GPOINTER_TO_INT (g_object_get_qdata((GObject*)rd->self, _signon_proxy_ready_quark())) == TRUE) { //TODO: specify the last error in object initialization GError * err = g_object_get_qdata((GObject*)rd->self, _signon_proxy_error_quark()); signon_proxy_invoke_ready_callbacks (rd, err); } else { signon_proxy_setup (SIGNON_PROXY (rd->self)); } g_main_context_unref (g_source_get_context (rd->idle_source)); rd->idle_source = NULL; return FALSE; } void signon_proxy_setup (gpointer self) { SignonProxyInterface *iface; g_return_if_fail (SIGNON_IS_PROXY (self)); iface = SIGNON_PROXY_GET_IFACE (self); if (iface->setup != NULL) { iface->setup (self); } } void signon_proxy_call_when_ready (gpointer object, GQuark quark, SignonReadyCb callback, gpointer user_data) { SignonReadyData *rd; SignonReadyCbData *cb; g_return_if_fail (SIGNON_IS_PROXY (object)); g_return_if_fail (quark != 0); g_return_if_fail (callback != NULL); cb = g_slice_new (SignonReadyCbData); cb->callback = callback; cb->user_data = user_data; rd = g_object_get_qdata ((GObject *)object, quark); if (!rd) { rd = g_slice_new (SignonReadyData); rd->self = object; rd->callbacks = NULL; rd->idle_source = NULL; g_object_set_qdata_full ((GObject *)object, quark, rd, (GDestroyNotify)signon_ready_data_free); } rd->callbacks = g_slist_append (rd->callbacks, cb); if (!rd->idle_source) { rd->idle_source = g_idle_source_new (); g_source_set_callback (rd->idle_source, (GSourceFunc)signon_proxy_call_when_ready_idle, rd, NULL); g_source_attach (rd->idle_source, g_main_context_ref_thread_default ()); } } void signon_proxy_set_ready (gpointer object, GQuark quark, GError *error) { SignonReadyData *rd; g_return_if_fail (SIGNON_IS_PROXY (object)); g_object_set_qdata((GObject *)object, _signon_proxy_ready_quark(), GINT_TO_POINTER(TRUE)); if(error) g_object_set_qdata_full ((GObject *)object, _signon_proxy_error_quark(), error, (GDestroyNotify)g_error_free); rd = g_object_get_qdata ((GObject *)object, quark); if (!rd) return; g_object_ref (object); signon_proxy_invoke_ready_callbacks (rd, error); g_object_unref (object); } void signon_proxy_set_not_ready (gpointer object) { g_return_if_fail (SIGNON_IS_PROXY (object)); g_object_set_qdata ((GObject *)object, _signon_proxy_ready_quark(), GINT_TO_POINTER(FALSE)); g_object_set_qdata ((GObject *)object, _signon_proxy_error_quark(), NULL); } const GError * signon_proxy_get_last_error (gpointer object) { g_return_val_if_fail (SIGNON_IS_PROXY (object), NULL); return g_object_get_qdata((GObject *)object, _signon_proxy_error_quark()); } 0707010000002A000081A4000003E800000064000000015BDC2CEA000007B0000000000000000000000000000000000000003100000000libsignon-glib-2.1/libsignon-glib/signon-proxy.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SIGNON_PROXY_H_ #define _SIGNON_PROXY_H_ #include <glib.h> #include <glib-object.h> G_BEGIN_DECLS #define SIGNON_TYPE_PROXY (signon_proxy_get_type ()) G_GNUC_INTERNAL G_DECLARE_INTERFACE(SignonProxy, signon_proxy, SIGNON, PROXY, GObject) typedef void (*SignonReadyCb) (gpointer object, const GError *error, gpointer user_data); struct _SignonProxyInterface { GTypeInterface parent_iface; void (*setup) (SignonProxy *self); }; G_GNUC_INTERNAL void signon_proxy_setup (gpointer self); G_GNUC_INTERNAL void signon_proxy_call_when_ready (gpointer self, GQuark quark, SignonReadyCb callback, gpointer user_data); G_GNUC_INTERNAL void signon_proxy_set_ready (gpointer self, GQuark quark, GError *error); G_GNUC_INTERNAL void signon_proxy_set_not_ready (gpointer self); G_GNUC_INTERNAL const GError *signon_proxy_get_last_error (gpointer self); G_END_DECLS #endif /* _SIGNON_PROXY_H_ */ 0707010000002B000081A4000003E800000064000000015BDC2CEA000017D6000000000000000000000000000000000000003C00000000libsignon-glib-2.1/libsignon-glib/signon-security-context.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2010 Nokia Corporation. * Copyright (C) 2011-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * SECTION:signon-security-context * @title: SignonSecurityContext * @short_description: Security context for #SignonIdentityInfo. * * Security context information for a #SignonIdentity. */ #include "signon-security-context.h" #include "signon-internals.h" G_DEFINE_BOXED_TYPE (SignonSecurityContext, signon_security_context, (GBoxedCopyFunc)signon_security_context_copy, (GBoxedFreeFunc)signon_security_context_free); SignonSecurityContext * signon_security_context_new_from_variant (GVariant *variant) { gchar *system_context = NULL; gchar *application_context = NULL; SignonSecurityContext *ctx; g_return_val_if_fail (variant != NULL, NULL); g_variant_get (variant, "(ss)", &system_context, &application_context); ctx = signon_security_context_new_from_values (system_context, application_context); g_free (system_context); g_free (application_context); return ctx; } GVariant * signon_security_context_to_variant (const SignonSecurityContext *ctx) { g_return_val_if_fail (ctx != NULL, NULL); return g_variant_new ("(ss)", ctx->system_context, ctx->application_context); } /* * Public methods: */ /** * signon_security_context_new: * * Creates a new #SignonSecurityContext item. * * Returns: (transfer full): a new #SignonSecurityContext item. */ SignonSecurityContext * signon_security_context_new (void) { SignonSecurityContext *ctx = g_slice_new0 (SignonSecurityContext); ctx->system_context = g_strdup (""); ctx->application_context = g_strdup (""); return ctx; } /** * signon_security_context_new_from_values: * @system_context: system security context * @application_context: application security context * * Creates a new #SignonSecurityContext item. * * Returns: (transfer full): a new #SignonSecurityContext item. */ SignonSecurityContext * signon_security_context_new_from_values (const gchar *system_context, const gchar *application_context) { SignonSecurityContext *ctx = signon_security_context_new (); if (system_context != NULL) signon_security_context_set_system_context (ctx, system_context); if (application_context != NULL) signon_security_context_set_application_context (ctx, application_context); return ctx; } /** * signon_security_context_free: * @ctx: the #SignonSecurityContext. * * Destroys the given #SignonSecurityContext item. */ void signon_security_context_free (SignonSecurityContext *ctx) { if (ctx == NULL) return; g_free (ctx->system_context); g_free (ctx->application_context); g_slice_free (SignonSecurityContext, ctx); } /** * signon_security_context_copy: * @other: the #SignonSecurityContext. * * Get a newly-allocated copy of @info. * * Returns: (transfer full): a copy of the given #SignonIdentityInfo, or %NULL on failure. */ SignonSecurityContext * signon_security_context_copy (const SignonSecurityContext *other) { g_return_val_if_fail (other != NULL, NULL); SignonSecurityContext *ctx = signon_security_context_new (); signon_security_context_set_system_context (ctx, signon_security_context_get_system_context (other)); signon_security_context_set_application_context (ctx, signon_security_context_get_application_context (other)); return ctx; } /** * signon_security_context_get_application_context: * @ctx: the #SignonSecurityContext. * * Get the application context of @ctx. * * Returns: the application context. */ const gchar * signon_security_context_get_application_context (const SignonSecurityContext *ctx) { g_return_val_if_fail (ctx != NULL, NULL); return ctx->application_context; } /** * signon_security_context_get_system_context: * @ctx: the #SignonSecurityContext. * * Get the system context of @ctx. * * Returns: the system context. */ const gchar * signon_security_context_get_system_context (const SignonSecurityContext *ctx) { g_return_val_if_fail (ctx != NULL, NULL); return ctx->system_context; } /** * signon_security_context_set_application_context: * @ctx: the #SignonSecurityContext. * @application_context: the application context. * * Sets the application context. */ void signon_security_context_set_application_context (SignonSecurityContext *ctx, const gchar *application_context) { g_return_if_fail (ctx != NULL); if (ctx->application_context) g_free (ctx->application_context); if (application_context != NULL) ctx->application_context = g_strdup (application_context); else ctx->application_context = g_strdup (""); } /** * signon_security_context_set_system_context: * @ctx: the #SignonSecurityContext. * @system_context: the system context. * * Sets the system context. */ void signon_security_context_set_system_context (SignonSecurityContext *ctx, const gchar *system_context) { g_return_if_fail (ctx != NULL); if (ctx->system_context) g_free (ctx->system_context); if (system_context != NULL) ctx->system_context = g_strdup (system_context); else ctx->system_context = g_strdup (""); } 0707010000002C000081A4000003E800000064000000015BDC2CEA0000080B000000000000000000000000000000000000003C00000000libsignon-glib-2.1/libsignon-glib/signon-security-context.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2018 elementary, Inc * * Contact: Corentin Noël <corentin@elementary.io> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SIGNON_SECURITY_CONTEXT_H_ #define _SIGNON_SECURITY_CONTEXT_H_ #include <glib-object.h> G_BEGIN_DECLS /** * SignonSecurityContext: * * Opaque struct. Use the accessor functions below. */ typedef struct _SignonSecurityContext SignonSecurityContext; GType signon_security_context_get_type (void) G_GNUC_CONST; SignonSecurityContext *signon_security_context_new (void); SignonSecurityContext *signon_security_context_new_from_values (const gchar *system_context, const gchar *application_context); void signon_security_context_free (SignonSecurityContext *ctx); SignonSecurityContext *signon_security_context_copy (const SignonSecurityContext *other); const gchar *signon_security_context_get_application_context (const SignonSecurityContext *ctx); const gchar *signon_security_context_get_system_context (const SignonSecurityContext *ctx); void signon_security_context_set_application_context (SignonSecurityContext *ctx, const gchar *application_context); void signon_security_context_set_system_context (SignonSecurityContext *ctx, const gchar *system_context); G_END_DECLS #endif /* _SIGNON_SECURITY_CONTEXT_H_ */ 0707010000002D000081A4000003E800000064000000015BDC2CEA000004FE000000000000000000000000000000000000003100000000libsignon-glib-2.1/libsignon-glib/signon-types.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef SIGNON_TYPES_H #define SIGNON_TYPES_H #include <glib.h> G_BEGIN_DECLS #ifdef SIGNON_DISABLE_DEPRECATION_WARNINGS #define SIGNON_DEPRECATED #define SIGNON_DEPRECATED_FOR(x) #else #define SIGNON_DEPRECATED G_DEPRECATED #define SIGNON_DEPRECATED_FOR(x) G_DEPRECATED_FOR(x) #endif G_END_DECLS #endif /* SIGNON_TYPES_H */ 0707010000002E000081A4000003E800000064000000015BDC2CEA00000C63000000000000000000000000000000000000003500000000libsignon-glib-2.1/libsignon-glib/sso-auth-service.c/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #include "signon-errors.h" #include "signon-internals.h" #include "sso-auth-service.h" static GHashTable *thread_objects = NULL; static GMutex map_mutex; static SsoAuthService * get_singleton () { SsoAuthService *object = NULL; g_mutex_lock (&map_mutex); if (thread_objects != NULL) { GWeakRef *ref; ref = g_hash_table_lookup (thread_objects, g_thread_self ()); if (ref != NULL) { object = g_weak_ref_get (ref); } } g_mutex_unlock (&map_mutex); return object; } static void weak_ref_free(GWeakRef *ref) { g_weak_ref_clear (ref); g_slice_free (GWeakRef, ref); } static void set_singleton (SsoAuthService *object) { g_return_if_fail (SSO_IS_AUTH_SERVICE (object)); g_mutex_lock (&map_mutex); if (thread_objects == NULL) { thread_objects = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) weak_ref_free); } if (object != NULL) { GWeakRef *ref = g_slice_new (GWeakRef); g_weak_ref_init (ref, object); g_hash_table_insert (thread_objects, g_thread_self (), ref); } g_mutex_unlock (&map_mutex); } SsoAuthService * sso_auth_service_get_instance () { SsoAuthService *sso_auth_service; GError *error = NULL; sso_auth_service = get_singleton (); if (sso_auth_service != NULL) return sso_auth_service; /* Create the object */ sso_auth_service = sso_auth_service_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, SIGNOND_SERVICE_PREFIX, SIGNOND_DAEMON_OBJECTPATH, NULL, &error); if (G_LIKELY (error == NULL)) { set_singleton (sso_auth_service); } else { g_warning ("Couldn't activate signond: %s", error->message); g_clear_error (&error); } /* While at it, register the error mapping with GDBus */ signon_error_quark (); return sso_auth_service; } 0707010000002F000081A4000003E800000064000000015BDC2CEA00000486000000000000000000000000000000000000003500000000libsignon-glib-2.1/libsignon-glib/sso-auth-service.h/* vi: set et sw=4 ts=4 cino=t0,(0: */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2012-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef _SSO_AUTH_SERVICE_H_ #define _SSO_AUTH_SERVICE_H_ #include "sso-auth-service-gen.h" G_BEGIN_DECLS G_GNUC_INTERNAL SsoAuthService *sso_auth_service_get_instance (); G_END_DECLS #endif /* _SSO_AUTH_SERVICE_H_ */ 07070100000030000081A4000003E800000064000000015BDC2CEA000002BA000000000000000000000000000000000000001F00000000libsignon-glib-2.1/meson.buildproject('libsignon-glib', 'c', version: '2.1' ) library_major = '2' gnome = import('gnome') pkg = import('pkgconfig') gio_dep = dependency('gio-2.0', version: '>=2.36') gio_unix_dep = dependency('gio-unix-2.0') glib_dep = dependency('glib-2.0', version: '>=2.32') gobject_dep = dependency('gobject-2.0', version: '>=2.35.1') if get_option('tests') check_dep = dependency('check', version: '>=0.9.4') endif if get_option('debugging') add_project_arguments('-DENABLE_DEBUG=1', language : 'c') endif root_dir = include_directories ('.') subdir('libsignon-glib') subdir('docs') if get_option('python') subdir('pygobject') endif if get_option('tests') subdir('tests') endif 07070100000031000081A4000003E800000064000000015BDC2CEA00000234000000000000000000000000000000000000002500000000libsignon-glib-2.1/meson_options.txtoption('tests', type : 'boolean', description : 'Build with test support') option('debugging', type : 'boolean', value: false, description : 'Printing of debug messages') option('python', type : 'boolean', description : 'Build with python support') option('py-overrides-dir', type : 'string', value : '', description: 'Path to pygobject overrides directory') option('documentation', type : 'boolean', description : 'Generate the documentation of the library') option('introspection', type : 'boolean', description : 'Build with the GObject introspection support') 07070100000032000041ED000003E800000064000000025BDC2CEA00000000000000000000000000000000000000000000001D00000000libsignon-glib-2.1/pygobject07070100000033000081A4000003E800000064000000015BDC2CEA000002F9000000000000000000000000000000000000002700000000libsignon-glib-2.1/pygobject/Signon.pyfrom ..overrides import override from ..importer import modules from gi.repository import GObject Signon = modules['Signon']._introspection_module __all__ = [] class GStrv(list): __gtype__ = GObject.type_from_name('GStrv') class AuthSession(Signon.AuthSession): # Convert list of strings into a GStrv def process(self, session_data, mechanism, callback, userdata): cleaned_data = {} for (key, value) in session_data.items(): if isinstance(value, list): cleaned_data[key] = GStrv(value) else: cleaned_data[key] = value Signon.AuthSession.process(self, cleaned_data, mechanism, callback, userdata) AuthSession = override(AuthSession) __all__.append('AuthSession') 07070100000034000081A4000003E800000064000000015BDC2CEA00000208000000000000000000000000000000000000002900000000libsignon-glib-2.1/pygobject/meson.buildpy_override = get_option('py-overrides-dir') if py_override == '' python_exec = find_program(['python3', 'python']) py_override_cmd = run_command( python_exec, ['-c', 'import gi;print (gi._overridesdir, end="")'], ) if py_override_cmd.returncode() != 0 error('Error getting the GObject Introspection override directory: ' + py_override_cmd.stderr()) endif py_override = py_override_cmd.stdout() endif install_data( 'Signon.py', install_dir: py_override, ) 07070100000035000041ED000003E800000064000000025BDC2CEA00000000000000000000000000000000000000000000001900000000libsignon-glib-2.1/tests07070100000036000081A4000003E800000064000000015BDC2CEA0000B883000000000000000000000000000000000000002800000000libsignon-glib-2.1/tests/check_signon.c/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of libsignon-glib * * Copyright (C) 2009-2011 Nokia Corporation. * Copyright (C) 2011-2016 Canonical Ltd. * * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * @example check_signon.c * Shows how to initialize the framework. */ #define SIGNON_DISABLE_DEPRECATION_WARNINGS #include "libsignon-glib/signon-internals.h" #include "libsignon-glib/signon-auth-service.h" #include "libsignon-glib/signon-auth-session.h" #include "libsignon-glib/signon-identity.h" #include "libsignon-glib/signon-errors.h" #include <glib.h> #include <check.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static GMainLoop *main_loop = NULL; static SignonIdentity *identity = NULL; static SignonAuthService *auth_service = NULL; #define SIGNOND_IDLE_TIMEOUT (5 + 2) static gboolean _contains(gchar **list, gchar *item) { gboolean present = FALSE; gint i = 0; while (list[i] != NULL) { if (g_strcmp0 (item, list[i]) == 0) present = TRUE; i++; } return present; } static void end_test () { if (auth_service) { g_object_unref (auth_service); auth_service = NULL; } if (identity) { g_object_unref (identity); identity = NULL; } if (main_loop) { g_main_loop_quit (main_loop); g_main_loop_unref (main_loop); main_loop = NULL; } } static gboolean quit_loop (gpointer user_data) { GMainLoop *loop = user_data; g_main_loop_quit (loop); return FALSE; } static void run_main_loop_for_n_seconds(guint seconds) { GMainLoop *loop = g_main_loop_new (NULL, FALSE); g_timeout_add_seconds (seconds, quit_loop, loop); g_main_loop_run (loop); g_main_loop_unref (loop); } START_TEST(test_init) { g_debug("%s", G_STRFUNC); auth_service = signon_auth_service_new (); main_loop = g_main_loop_new (NULL, FALSE); fail_unless (SIGNON_IS_AUTH_SERVICE (auth_service), "Failed to initialize the AuthService."); end_test (); } END_TEST static void signon_query_methods_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonAuthService *auth_service = SIGNON_AUTH_SERVICE (source_object); GError *error = NULL; gchar **methods = signon_auth_service_get_methods_finish (auth_service, res, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); g_main_loop_quit (main_loop); fail(); } gboolean has_ssotest = FALSE; fail_unless (g_strcmp0 (user_data, "Hello") == 0, "Got wrong string"); fail_unless (methods != NULL, "The methods does not exist"); for (gint i = 0; methods[i] != NULL; i++) { const gchar *method = methods[i]; if (g_strcmp0 (method, "ssotest") == 0) { has_ssotest = TRUE; break; } } fail_unless (has_ssotest, "ssotest method does not exist"); g_main_loop_quit (main_loop); } START_TEST(test_query_methods) { g_debug("%s", G_STRFUNC); if(!main_loop) main_loop = g_main_loop_new (NULL, FALSE); auth_service = signon_auth_service_new (); fail_unless (SIGNON_IS_AUTH_SERVICE (auth_service), "Failed to initialize the AuthService."); signon_auth_service_get_methods (auth_service, NULL, signon_query_methods_cb, "Hello"); g_main_loop_run (main_loop); end_test (); } END_TEST START_TEST(test_query_methods_sync) { gchar **methods = NULL; GError *error = NULL; g_debug("%s", G_STRFUNC); auth_service = signon_auth_service_new (); fail_unless (SIGNON_IS_AUTH_SERVICE (auth_service), "Failed to initialize the AuthService."); methods = signon_auth_service_get_methods_sync (auth_service, NULL, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); fail(); } gboolean has_ssotest = FALSE; fail_unless (methods != NULL, "The methods does not exist"); for (gint i = 0; methods[i] != NULL; i++) { const gchar *method = methods[i]; if (g_strcmp0 (method, "ssotest") == 0) { has_ssotest = TRUE; break; } } fail_unless (has_ssotest, "ssotest method does not exist"); } END_TEST static void signon_query_mechanisms_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonAuthService *auth_service = SIGNON_AUTH_SERVICE (source_object); GError *error = NULL; gchar **mechanisms = signon_auth_service_get_mechanisms_finish (auth_service, res, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); g_main_loop_quit (main_loop); fail(); } gboolean has_mech1 = FALSE; gboolean has_mech2 = FALSE; gboolean has_mech3 = FALSE; fail_unless (strcmp (user_data, "Hello") == 0, "Got wrong string"); fail_unless (mechanisms != NULL, "The mechanisms does not exist"); for (gint i = 0; mechanisms[i] != NULL; i++) { const gchar *mechanism = mechanisms[i]; if (g_strcmp0 (mechanism, "mech1") == 0) has_mech1 = TRUE; if (g_strcmp0 (mechanism, "mech2") == 0) has_mech2 = TRUE; if (g_strcmp0 (mechanism, "mech3") == 0) has_mech3 = TRUE; } fail_unless (has_mech1, "mech1 mechanism does not exist"); fail_unless (has_mech2, "mech2 mechanism does not exist"); fail_unless (has_mech3, "mech3 mechanism does not exist"); g_main_loop_quit (main_loop); } static void signon_query_mechanisms_cb_fail (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonAuthService *auth_service = SIGNON_AUTH_SERVICE (source_object); GError *error = NULL; gchar **mechanisms = signon_auth_service_get_mechanisms_finish (auth_service, res, &error); fail_unless (error != NULL); fail_unless (mechanisms == NULL); fail_unless (error->domain == SIGNON_ERROR); fail_unless (error->code == SIGNON_ERROR_METHOD_NOT_KNOWN); g_main_loop_quit (main_loop); } START_TEST(test_query_mechanisms) { g_debug("%s", G_STRFUNC); auth_service = signon_auth_service_new (); fail_unless (SIGNON_IS_AUTH_SERVICE (auth_service), "Failed to initialize the AuthService."); signon_auth_service_get_mechanisms (auth_service, "ssotest", NULL, signon_query_mechanisms_cb, "Hello"); if(!main_loop) main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); /* Test a non existing method */ signon_auth_service_get_mechanisms (auth_service, "non-existing", NULL, signon_query_mechanisms_cb_fail, "Hello"); g_main_loop_run (main_loop); end_test (); } END_TEST START_TEST(test_query_mechanisms_sync) { gchar **mechanisms = NULL; GError *error = NULL; g_debug("%s", G_STRFUNC); auth_service = signon_auth_service_new (); fail_unless (SIGNON_IS_AUTH_SERVICE (auth_service), "Failed to initialize the AuthService."); mechanisms = signon_auth_service_get_mechanisms_sync (auth_service, "ssotest", NULL, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); fail(); } gboolean has_mech1 = FALSE; gboolean has_mech2 = FALSE; gboolean has_mech3 = FALSE; fail_unless (mechanisms != NULL, "The mechanisms does not exist"); for (gint i = 0; mechanisms[i] != NULL; i++) { const gchar *mechanism = mechanisms[i]; if (g_strcmp0 (mechanism, "mech1") == 0) has_mech1 = TRUE; if (g_strcmp0 (mechanism, "mech2") == 0) has_mech2 = TRUE; if (g_strcmp0 (mechanism, "mech3") == 0) has_mech3 = TRUE; } fail_unless (has_mech1, "mech1 mechanism does not exist"); fail_unless (has_mech2, "mech2 mechanism does not exist"); fail_unless (has_mech3, "mech3 mechanism does not exist"); /* Test a non existing method */ mechanisms = signon_auth_service_get_mechanisms_sync (auth_service, "non-existing", NULL, &error); fail_unless (error != NULL); fail_unless (mechanisms == NULL); fail_unless (error->domain == SIGNON_ERROR); fail_unless (error->code == SIGNON_ERROR_METHOD_NOT_KNOWN); } END_TEST static void test_auth_session_process2_async_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonAuthSession *self = (SignonAuthSession *)source_object; GError *error = NULL; GVariant *reply = signon_auth_session_process_finish (self, res, &error); gboolean ok; if (error) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); g_main_loop_quit (main_loop); fail(); } fail_unless (reply != NULL, "Could not process the auth session"); gchar* username2 = NULL; ok = g_variant_lookup (reply, SIGNON_SESSION_DATA_USERNAME, "&s", &username2); ck_assert (ok); ck_assert_str_eq (username2, "test_username"); g_variant_unref (reply); g_main_loop_quit (main_loop); } static void test_auth_session_states_cb (SignonAuthSession *self, gint state, gchar *message, gpointer user_data) { gint *state_counter = (gint *)user_data; (*state_counter)++; } START_TEST(test_auth_session_creation) { GError *err = NULL; gpointer auth_session_sentinel; gpointer idty_sentinel; const gchar *method = NULL; g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(NULL, NULL); fail_unless (idty != NULL, "Cannot create Identity object"); SignonAuthSession *auth_session = signon_identity_create_session(idty, "ssotest", &err); fail_unless (auth_session != NULL, "Cannot create AuthSession object"); method = signon_auth_session_get_method (auth_session); fail_unless (g_strcmp0 (method, "ssotest") == 0, "Wrong AuthSession method name"); g_object_add_weak_pointer (G_OBJECT (idty), &idty_sentinel); g_object_add_weak_pointer (G_OBJECT (auth_session), &auth_session_sentinel); g_object_unref (idty); fail_unless (SIGNON_IS_IDENTITY(idty), "Identity must stay untill all its session are not destroyed"); g_object_unref (auth_session); fail_if (auth_session_sentinel != NULL, "AuthSession is not synchronized with parent Identity"); fail_if (idty_sentinel != NULL, "Identity is not synchronized with its AuthSession"); g_clear_error(&err); } END_TEST static void test_auth_session_process_async_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonAuthSession *auth_session = SIGNON_AUTH_SESSION (source_object); GVariant **v_reply = user_data; GError *error = NULL; fail_unless (SIGNON_IS_AUTH_SESSION (source_object)); *v_reply = signon_auth_session_process_finish (auth_session, res, &error); fail_unless (error == NULL); g_main_loop_quit (main_loop); } START_TEST(test_auth_session_process_async) { gint state_counter = 0; GError *err = NULL; GVariantBuilder builder; GVariant *session_data, *reply; gchar *username, *realm; gboolean ok; g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(NULL, NULL); fail_unless (idty != NULL, "Cannot create Identity object"); SignonAuthSession *auth_session = signon_identity_create_session(idty, "ssotest", &err); fail_unless (auth_session != NULL, "Cannot create AuthSession object"); g_clear_error(&err); g_signal_connect(auth_session, "state-changed", G_CALLBACK(test_auth_session_states_cb), &state_counter); g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", SIGNON_SESSION_DATA_USERNAME, g_variant_new_string ("test_username")); g_variant_builder_add (&builder, "{sv}", SIGNON_SESSION_DATA_SECRET, g_variant_new_string ("test_pw")); session_data = g_variant_builder_end (&builder); signon_auth_session_process (auth_session, session_data, "mech1", NULL, test_auth_session_process_async_cb, &reply); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); fail_unless (state_counter == 12, "Wrong numer of state change signals: %d", state_counter); fail_unless (reply != NULL); session_data = NULL; ok = g_variant_lookup (reply, SIGNON_SESSION_DATA_USERNAME, "&s", &username); ck_assert (ok); ck_assert_str_eq (username, "test_username"); ok = g_variant_lookup (reply, SIGNON_SESSION_DATA_REALM, "&s", &realm); ck_assert (ok); ck_assert_str_eq (realm, "testRealm_after_test"); g_variant_unref (reply); g_object_unref (auth_session); g_object_unref (idty); end_test (); } END_TEST static void test_auth_session_process_failure_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonAuthSession *auth_session = SIGNON_AUTH_SESSION (source_object); GVariant *v_reply; GError **error = user_data; fail_unless (SIGNON_IS_AUTH_SESSION (source_object)); v_reply = signon_auth_session_process_finish (auth_session, res, error); fail_unless (v_reply == NULL); g_main_loop_quit (main_loop); } START_TEST(test_auth_session_process_failure) { SignonAuthSession *auth_session; GVariantBuilder builder; GVariant *session_data; GError *error = NULL; g_debug("%s", G_STRFUNC); auth_session = signon_auth_session_new (0, "nonexisting-method", &error); fail_unless (auth_session != NULL, "Cannot create AuthSession object"); fail_unless (error == NULL); g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", "key", g_variant_new_string ("value")); session_data = g_variant_builder_end (&builder); signon_auth_session_process (auth_session, session_data, "mech1", NULL, test_auth_session_process_failure_cb, &error); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); fail_unless (error != NULL); fail_unless (error->domain == SIGNON_ERROR); fail_unless (error->code == SIGNON_ERROR_METHOD_NOT_KNOWN); g_error_free (error); g_object_unref (auth_session); end_test (); } END_TEST START_TEST(test_auth_session_process_cancel) { SignonAuthSession *auth_session; GVariantBuilder builder; GVariant *session_data; GError *error = NULL; g_debug("%s", G_STRFUNC); auth_session = signon_auth_session_new (0, "nonexisting-method", &error); fail_unless (auth_session != NULL, "Cannot create AuthSession object"); fail_unless (error == NULL); g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", "key", g_variant_new_string ("value")); session_data = g_variant_builder_end (&builder); signon_auth_session_process (auth_session, session_data, "mech1", NULL, test_auth_session_process_failure_cb, &error); signon_auth_session_cancel (auth_session); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); fail_unless (error != NULL); fail_unless (error->domain == SIGNON_ERROR); fail_unless (error->code == SIGNON_ERROR_METHOD_NOT_KNOWN); g_error_free (error); g_object_unref (auth_session); end_test (); } END_TEST static void test_auth_session_process_after_store_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { gchar *v_username; GError *error = NULL; GVariantDict *dict = NULL; GVariant *reply = signon_auth_session_process_finish ((SignonAuthSession *)source_object, res, &error); if (error != NULL) { fail("Got error: %s", error->message); g_main_loop_quit (main_loop); return; } fail_unless (reply != NULL, "The result is empty"); dict = g_variant_dict_new (reply); g_variant_dict_lookup (dict, SIGNON_SESSION_DATA_USERNAME, "s", &v_username); fail_unless (g_strcmp0 (v_username, "Nice user") == 0, "Wrong value of username"); g_variant_dict_unref (dict); g_free (v_username); g_main_loop_quit (main_loop); } static void test_auth_session_process_after_store_start_session (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; GVariant *session_data = NULL; guint32 id; SignonAuthSession *auth_session = (SignonAuthSession *)user_data; fail_unless (auth_session != NULL); fail_unless (SIGNON_IS_AUTH_SESSION (auth_session)); if (!signon_identity_store_info_finish (self, res, &error)) { g_warning ("%s %d: %s", G_STRFUNC, __LINE__, error->message); fail(); g_main_loop_quit (main_loop); return; } id = signon_identity_get_id (self); fail_unless (id > 0); session_data = g_variant_new (g_variant_type_peek_string (G_VARIANT_TYPE_VARDICT), NULL); signon_auth_session_process (auth_session, session_data, "mech1", NULL, test_auth_session_process_after_store_cb, NULL); } START_TEST(test_auth_session_process_after_store) { SignonIdentityInfo *info = NULL; SignonIdentity *identity = NULL; GList *acl = g_list_append (NULL, signon_security_context_new_from_values ("*", "*")); SignonAuthSession *auth_session = NULL; GError *error = NULL; g_debug("%s", G_STRFUNC); main_loop = g_main_loop_new (NULL, FALSE); identity = signon_identity_new (); fail_unless (SIGNON_IS_IDENTITY (identity), "Failed to initialize the Identity."); info = signon_identity_info_new (); signon_identity_info_set_username (info, "Nice user"); signon_identity_info_set_access_control_list (info, acl); g_list_free_full (acl, (GDestroyNotify)signon_security_context_free); /* * This auth session will get an updated Identity ID when the identity * get created. */ auth_session = signon_identity_create_session(identity, "ssotest", &error); fail_unless (auth_session != NULL, "Cannot create AuthSession object"); if (error != NULL) { fail ("Got error: %s", error->message); g_clear_error (&error); } signon_identity_store_info (identity, info, NULL, test_auth_session_process_after_store_start_session, auth_session); g_main_loop_run (main_loop); g_object_unref (identity); g_object_unref (auth_session); signon_identity_info_free (info); end_test (); } END_TEST static void add_methods_to_identity_info (SignonIdentityInfo *info) { const gchar *mechanisms[] = { "mechanism1", "mechanism2", "mechanism3", NULL }; signon_identity_info_set_method (info, "method1", mechanisms); signon_identity_info_set_method (info, "method2", mechanisms); signon_identity_info_set_method (info, "method3", mechanisms); } static void new_identity_store_credentials_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; gint *new_id = user_data; guint32 id; if (!signon_identity_store_info_finish (self, res, &error)) { g_warning ("%s %d: %s", G_STRFUNC, __LINE__, error->message); fail(); } id = signon_identity_get_id (self); fail_unless (id > 0); *new_id = id; g_object_unref (self); g_main_loop_quit (main_loop); } static guint new_identity() { SignonIdentity *identity; GList *acl = g_list_append (NULL, signon_security_context_new_from_values ("*", "*")); guint id = 0; identity = signon_identity_new(NULL, NULL); fail_unless (SIGNON_IS_IDENTITY (identity)); SignonIdentityInfo *info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); signon_identity_info_set_caption (info, "caption"); signon_identity_info_set_access_control_list (info, acl); g_list_free_full (acl, (GDestroyNotify)signon_security_context_free); signon_identity_store_info (identity, info, NULL, new_identity_store_credentials_cb, &id); signon_identity_info_free (info); if (id == 0) g_main_loop_run (main_loop); return id; } static gboolean identity_registered_cb (gpointer data) { g_main_loop_quit (main_loop); return FALSE; } START_TEST(test_get_existing_identity) { g_debug("%s", G_STRFUNC); main_loop = g_main_loop_new (NULL, FALSE); guint id = new_identity(); fail_unless (id != 0); identity = signon_identity_new_from_db(id); fail_unless (identity != NULL); fail_unless (SIGNON_IS_IDENTITY (identity), "Failed to initialize the Identity."); g_timeout_add (1000, identity_registered_cb, identity); g_main_loop_run (main_loop); end_test (); } END_TEST START_TEST(test_get_nonexisting_identity) { g_debug("%s", G_STRFUNC); identity = signon_identity_new_from_db(G_MAXINT); fail_unless (identity != NULL); fail_unless (SIGNON_IS_IDENTITY (identity), "Failed to initialize the Identity."); g_timeout_add (1000, identity_registered_cb, identity); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); const GError *error = NULL; error = signon_identity_get_last_error(identity); fail_unless (error != NULL); fail_unless (error->domain == SIGNON_ERROR); fail_unless (error->code == SIGNON_ERROR_IDENTITY_NOT_FOUND || error->code == SIGNON_ERROR_PERMISSION_DENIED); end_test (); } END_TEST static void store_credentials_identity_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; guint32 id; if (!signon_identity_store_info_finish (self, res, &error)) { g_warning ("%s %d: %s", G_STRFUNC, __LINE__, error->message); fail(); } id = signon_identity_get_id (self); fail_unless (id > 0); if (user_data != NULL) { gint *last_id = (gint *)user_data; g_warning ("%s (prev_id vs new_id): %d vs %d", G_STRFUNC, *last_id, id); fail_unless (id == (*last_id) + 1); (*last_id) += 1; } /* Wait some time to ensure that the info-updated signals are * processed */ g_timeout_add_seconds (2, quit_loop, main_loop); } START_TEST(test_store_credentials_identity) { g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(NULL, NULL); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); main_loop = g_main_loop_new (NULL, FALSE); gint last_id = new_identity(); SignonIdentityInfo *info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); signon_identity_info_set_caption (info, "caption"); add_methods_to_identity_info (info); signon_identity_store_info (idty, info, NULL, store_credentials_identity_cb, &last_id); signon_identity_info_free (info); g_main_loop_run (main_loop); g_object_unref(idty); end_test (); } END_TEST static void identity_verify_secret_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; gboolean valid = signon_identity_verify_secret_finish (self, res, &error); fail_unless (error == NULL, "The callback returned error for proper secret"); fail_unless (valid == TRUE, "The callback gives FALSE for proper secret"); g_main_loop_quit((GMainLoop *)user_data); } START_TEST(test_verify_secret_identity) { GList *acl = g_list_append (NULL, signon_security_context_new_from_values ("*", "*")); g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(NULL, NULL); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); gchar secret[] = "007"; main_loop = g_main_loop_new (NULL, FALSE); SignonIdentityInfo *info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, secret, TRUE); signon_identity_info_set_caption (info, "caption"); signon_identity_info_set_access_control_list (info, acl); add_methods_to_identity_info (info); g_list_free_full (acl, (GDestroyNotify)signon_security_context_free); signon_identity_store_info (idty, info, NULL, store_credentials_identity_cb, NULL); signon_identity_info_free (info); g_main_loop_run (main_loop); signon_identity_verify_secret (idty, secret, NULL, identity_verify_secret_cb, main_loop); g_main_loop_run (main_loop); g_object_unref (idty); end_test (); } END_TEST static void identity_remove_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; g_warning (" %s ", __func__); if (signon_identity_remove_finish (self, res, &error)) { g_warning ("No error"); fail_if (user_data != NULL, "The callback must return an error"); } else { g_warning ("Error: %s ", error->message); g_error_free (error); fail_if (user_data == NULL, "There should be no error in callback"); } g_main_loop_quit(main_loop); } START_TEST(test_remove_identity) { g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); main_loop = g_main_loop_new (NULL, FALSE); /* * Try to remove non-stored idetnity * */ signon_identity_remove(idty, NULL, identity_remove_cb, NULL); g_main_loop_run (main_loop); /* * Try to remove existing identy * */ gint id = new_identity(); SignonIdentity *idty2 = signon_identity_new_from_db (id); signon_identity_remove(idty2, NULL, identity_remove_cb, NULL); g_main_loop_run (main_loop); /* * Try to remove already removed * */ signon_identity_remove(idty2, NULL, identity_remove_cb, GINT_TO_POINTER(TRUE)); g_object_unref (idty); g_object_unref (idty2); end_test (); } END_TEST static void identity_info_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; SignonIdentityInfo *info = signon_identity_query_info_finish (self, res, &error); if (error) { g_warning ("%s: Error: %s ", __func__, error->message); fail_if (info != NULL, "Error: %s ", error->message); g_main_loop_quit(main_loop); return; } g_warning ("No error"); SignonIdentityInfo **pattern_ptr = (SignonIdentityInfo **)user_data; SignonIdentityInfo *pattern = NULL; if (pattern_ptr) pattern = (*pattern_ptr); if (pattern == NULL) fail_unless (info == NULL, "The info must be NULL"); else { fail_unless (info != NULL, "The info must be non-null"); fail_unless (g_strcmp0 (signon_identity_info_get_username(info), signon_identity_info_get_username(pattern)) == 0, "The info has wrong username"); fail_unless (g_strcmp0 (signon_identity_info_get_caption(info), signon_identity_info_get_caption(pattern)) == 0, "The info has wrong caption"); GHashTable *methods = (GHashTable *)signon_identity_info_get_methods (info); gchar **mechs1 = g_hash_table_lookup (methods, "method1"); gchar **mechs2 = g_hash_table_lookup (methods, "method2"); gchar **mechs3 = g_hash_table_lookup (methods, "method3"); fail_unless (g_strv_length (mechs1) == 3); fail_unless (g_strv_length (mechs2) == 3); fail_unless (g_strv_length (mechs3) == 3); fail_unless (_contains(mechs1, "mechanism1")); fail_unless (_contains(mechs1, "mechanism2")); fail_unless (_contains(mechs1, "mechanism3")); fail_unless (_contains(mechs2, "mechanism1")); fail_unless (_contains(mechs2, "mechanism2")); fail_unless (_contains(mechs2, "mechanism3")); fail_unless (_contains(mechs3, "mechanism1")); fail_unless (_contains(mechs3, "mechanism2")); fail_unless (_contains(mechs3, "mechanism3")); } if (info && pattern_ptr) { signon_identity_info_free (pattern); *pattern_ptr = signon_identity_info_copy (info); } g_main_loop_quit(main_loop); } static SignonIdentityInfo *create_standard_info() { g_debug("%s", G_STRFUNC); SignonIdentityInfo *info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); signon_identity_info_set_caption (info, "caption"); signon_identity_info_add_access_control (info, "*", "*"); gchar *mechanisms[] = { "mechanism1", "mechanism2", "mechanism3", NULL }; signon_identity_info_set_method (info, "method1", (const gchar **)mechanisms); signon_identity_info_set_method (info, "method2", (const gchar **)mechanisms); signon_identity_info_set_method (info, "method3", (const gchar **)mechanisms); return info; } START_TEST(test_info_identity) { GList *acl = g_list_append (NULL, signon_security_context_new_from_values ("*", "*")); g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); SignonIdentityInfo *info = NULL; main_loop = g_main_loop_new (NULL, FALSE); /* * Try to get_info for non-stored idetnity * */ signon_identity_query_info (idty, NULL, identity_info_cb, &info); g_main_loop_run (main_loop); info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); signon_identity_info_set_caption (info, "caption"); signon_identity_info_set_access_control_list (info, acl); add_methods_to_identity_info (info); g_list_free_full (acl, (GDestroyNotify)signon_security_context_free); signon_identity_store_info (idty, info, NULL, store_credentials_identity_cb, NULL); signon_identity_info_free (info); g_main_loop_run (main_loop); info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); signon_identity_info_set_caption (info, "caption"); add_methods_to_identity_info (info); signon_identity_query_info (idty, NULL, identity_info_cb, &info); g_main_loop_run (main_loop); gint id = signon_identity_info_get_id (info); fail_unless (id != 0); SignonIdentity *idty2 = signon_identity_new_from_db (id); signon_identity_query_info (idty2, NULL, identity_info_cb, &info); g_main_loop_run (main_loop); /* * Try to update one identity and * have a look what will happen * */ signon_identity_info_set_username (info, "James Bond_2nd version"); signon_identity_info_set_caption (info, "caption_2nd version"); signon_identity_store_info (idty2, info, NULL, store_credentials_identity_cb, NULL); g_main_loop_run (main_loop); signon_identity_query_info (idty, NULL, identity_info_cb, &info); g_main_loop_run (main_loop); /* * Try to remove existing identity and * have a look what will happen * */ signon_identity_remove(idty2, NULL, identity_remove_cb, NULL); g_main_loop_run (main_loop); signon_identity_query_info (idty2, NULL, identity_info_cb, NULL); g_main_loop_run (main_loop); signon_identity_query_info (idty, NULL, identity_info_cb, NULL); g_main_loop_run (main_loop); signon_identity_info_free (info); g_object_unref (idty); g_object_unref (idty2); end_test (); } END_TEST static void identity_signout_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { SignonIdentity *self = (SignonIdentity *)source_object; GError *error = NULL; if (signon_identity_sign_out_finish (self, res, &error)) g_warning ("%s: No error", G_STRFUNC); else { g_warning ("%s: %s", G_STRFUNC, error->message); fail_unless (error == NULL, "There should be no error in callback"); g_error_free (error); } g_main_loop_quit (main_loop); } static void identity_signout_signal_cb (gpointer instance, gpointer user_data) { gint *incr = (gint *)user_data; (*incr) = (*incr) + 1; g_warning ("%s: %d", G_STRFUNC, *incr); } START_TEST(test_signout_identity) { gpointer as1_sentinel, as2_sentinel; g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); SignonIdentityInfo *info = create_standard_info(); main_loop = g_main_loop_new (NULL, FALSE); signon_identity_store_info (idty, info, NULL, store_credentials_identity_cb, NULL); g_main_loop_run (main_loop); signon_identity_query_info (idty, NULL, identity_info_cb, &info); g_main_loop_run (main_loop); gint id = signon_identity_info_get_id (info); SignonIdentity *idty2 = signon_identity_new_from_db (id); /* wait some more time to ensure that the object gets registered */ run_main_loop_for_n_seconds(2); signon_identity_info_free (info); GError *err = NULL; SignonAuthSession *as1 = signon_identity_create_session (idty, "ssotest", &err); fail_unless (as1 != NULL, "cannot create AuthSession"); SignonAuthSession *as2 = signon_identity_create_session (idty2, "ssotest", &err); fail_unless (as2 != NULL, "cannot create AuthSession"); gint counter = 0; g_signal_connect (idty, "signed-out", G_CALLBACK(identity_signout_signal_cb), &counter); g_signal_connect (idty2, "signed-out", G_CALLBACK(identity_signout_signal_cb), &counter); g_object_add_weak_pointer (G_OBJECT (as1), &as1_sentinel); g_object_add_weak_pointer (G_OBJECT (as2), &as2_sentinel); signon_identity_sign_out (idty, NULL, identity_signout_cb, NULL); g_main_loop_run (main_loop); fail_unless (counter == 2, "Lost some of SIGNOUT signals"); fail_if (as1_sentinel != NULL, "Authsession1 was not destroyed after signout"); fail_if (as2_sentinel != NULL, "Authsession2 was not destroyed after signout"); g_object_unref (idty); g_object_unref (idty2); end_test (); } END_TEST START_TEST(test_unregistered_identity) { g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); SignonIdentityInfo *info = create_standard_info(); main_loop = g_main_loop_new (NULL, FALSE); signon_identity_store_info (idty, info, NULL, store_credentials_identity_cb, NULL); g_main_loop_run (main_loop); /* * give the time for identity to became idle * */ sleep(SIGNOND_IDLE_TIMEOUT); SignonIdentity *idty2 = signon_identity_new(); /* * give time to handle unregistered signal * */ //run_main_loop_for_n_seconds(5); signon_identity_query_info (idty, NULL, identity_info_cb, &info); g_main_loop_run (main_loop); signon_identity_info_free (info); g_object_unref (idty); g_object_unref (idty2); end_test (); } END_TEST START_TEST(test_unregistered_auth_session) { GVariantBuilder builder; GVariant *session_data; GVariant *reply = NULL; gchar *username; gboolean ok; g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(); fail_unless (idty != NULL); fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); main_loop = g_main_loop_new (NULL, FALSE); GError *err = NULL; SignonAuthSession *as = signon_identity_create_session(idty, "ssotest", &err); /* give time to register the objects */ run_main_loop_for_n_seconds(2); /* * give the time for identity to became idle * */ sleep(SIGNOND_IDLE_TIMEOUT); SignonIdentity *idty2 = signon_identity_new(); g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", SIGNON_SESSION_DATA_USERNAME, g_variant_new_string ("test_username")); g_variant_builder_add (&builder, "{sv}", SIGNON_SESSION_DATA_SECRET, g_variant_new_string ("test_pw")); session_data = g_variant_ref_sink (g_variant_builder_end (&builder)); signon_auth_session_process (as, session_data, "mech1", NULL, test_auth_session_process_async_cb, &reply); g_main_loop_run (main_loop); fail_unless (reply != NULL); ok = g_variant_lookup (reply, SIGNON_SESSION_DATA_USERNAME, "&s", &username); ck_assert (ok); ck_assert_str_eq (username, "test_username"); g_variant_unref (reply); gchar* patterns[4]; patterns[0] = g_strdup("mech1"); patterns[1] = g_strdup("mech2"); patterns[2] = g_strdup("mech3"); patterns[3] = NULL; signon_auth_session_process (as, session_data, "mech1", NULL, test_auth_session_process2_async_cb, NULL); g_main_loop_run (main_loop); g_object_unref (as); g_object_unref (idty); g_object_unref (idty2); g_free (patterns[0]); g_free (patterns[1]); g_free (patterns[2]); g_free (patterns[3]); end_test (); } END_TEST static void test_regression_unref_process_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GError *error = NULL; GVariant *reply = signon_auth_session_process_finish ((SignonAuthSession *)source_object, res, &error); gchar *v_string = NULL; if (error) { g_warning ("%s: %s", G_STRFUNC, error->message); g_main_loop_quit (main_loop); fail(); } fail_unless (reply != NULL, "The result is empty"); fail_unless (g_strcmp0 (user_data, "Hi there!") == 0, "Didn't get expected user_data"); g_variant_lookup (reply, "James", "&s", &v_string); fail_unless (v_string != NULL); fail_unless (g_strcmp0 (v_string, "Bond") == 0, "Wrong reply data"); /* The next line is actually the regression we want to test */ g_object_unref (source_object); g_main_loop_quit (main_loop); } START_TEST(test_regression_unref) { SignonAuthSession *auth_session; GVariant *session_data; GError *error = NULL; GVariantBuilder builder; g_debug ("%s", G_STRFUNC); main_loop = g_main_loop_new (NULL, FALSE); auth_session = signon_auth_session_new (0, "ssotest", &error); fail_unless (auth_session != NULL); g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", "James", g_variant_new_string ("Bond")); session_data = g_variant_builder_end (&builder); signon_auth_session_process (auth_session, session_data, "mech1", NULL, test_regression_unref_process_cb, "Hi there!"); g_main_loop_run (main_loop); end_test (); } END_TEST Suite * signon_suite(void) { Suite *s = suite_create ("signon-glib"); /* Core test case */ TCase * tc_core = tcase_create("Core"); /* * 18 minutes timeout * */ tcase_set_timeout(tc_core, 1080); tcase_add_test (tc_core, test_init); tcase_add_test (tc_core, test_query_methods); tcase_add_test (tc_core, test_query_methods_sync); tcase_add_test (tc_core, test_query_mechanisms); tcase_add_test (tc_core, test_query_mechanisms_sync); tcase_add_test (tc_core, test_get_existing_identity); tcase_add_test (tc_core, test_get_nonexisting_identity); tcase_add_test (tc_core, test_auth_session_creation); tcase_add_test (tc_core, test_auth_session_process_async); tcase_add_test (tc_core, test_auth_session_process_failure); tcase_add_test (tc_core, test_auth_session_process_cancel); tcase_add_test (tc_core, test_auth_session_process_after_store); tcase_add_test (tc_core, test_store_credentials_identity); tcase_add_test (tc_core, test_verify_secret_identity); tcase_add_test (tc_core, test_remove_identity); tcase_add_test (tc_core, test_info_identity); tcase_add_test (tc_core, test_signout_identity); tcase_add_test (tc_core, test_unregistered_identity); tcase_add_test (tc_core, test_unregistered_auth_session); tcase_add_test (tc_core, test_regression_unref); suite_add_tcase (s, tc_core); return s; } int main(void) { int number_failed; Suite * s = signon_suite(); SRunner * sr = srunner_create(s); srunner_set_xml(sr, "/tmp/result.xml"); srunner_run_all(sr, CK_NORMAL); number_failed = srunner_ntests_failed(sr); srunner_free (sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } /* vim: set ai et tw=75 ts=4 sw=4: */ 07070100000037000081A4000003E800000064000000015BDC2CEA00000683000000000000000000000000000000000000002500000000libsignon-glib-2.1/tests/meson.buildsignon_glib_testsuite = executable( 'signon-glib-checksuite', 'check_signon.c', dependencies: [libsignon_glib_dep, check_dep], ) test_env = environment() test_env.set('TESTDIR', meson.current_source_dir()) test_env.set('TEST_APP', signon_glib_testsuite.full_path()) # Environment variables for the signon daemon test_env.set('SSO_LOGGING_LEVEL', '2') test_env.set('SSO_STORAGE_PATH', '/tmp') test_env.set('SSO_DAEMON_TIMEOUT', '1') test_env.set('SSO_IDENTITY_TIMEOUT', '3') test_env.set('SSO_AUTHSESSION_TIMEOUT', '3') test_env.set('SSO_EXTENSIONS_DIR', '/tmp') # this disables all extensions #Environment variables for the test application test_env.set('G_MESSAGES_DEBUG', 'all') dbus_test_runner = find_program('dbus-test-runner', required: false) if dbus_test_runner.found() message('Using dbus-test-runner') signond = find_program('signond', required: false) if (not signond.found()) signond = find_program('gsignond', required: false) endif if (not signond.found()) error('The signon or gsignon daemon is required to run the tests.') endif test( meson.project_name(), dbus_test_runner, args: [ '-m', '180', '--keep-env', '-t', signond.path(), '-r', '-t', signon_glib_testsuite, '-f', 'com.google.code.AccountsSSO.SingleSignOn', ], timeout: 300, # Timeout after 5 minutes env: test_env ) else message('Using existing D-Bus session and signond instance') test( meson.project_name(), signon_glib_testsuite, timeout: 300, # Timeout after 5 minutes env: test_env ) endif 07070100000038000081ED000003E800000064000000015BDC2CEA0000040C000000000000000000000000000000000000002D00000000libsignon-glib-2.1/tests/signon-glib-test.sh#!/bin/sh # Environment variables for the signon daemon export SSO_LOGGING_LEVEL=2 export SSO_STORAGE_PATH="/tmp" export SSO_DAEMON_TIMEOUT=1 export SSO_IDENTITY_TIMEOUT=3 export SSO_AUTHSESSION_TIMEOUT=3 export SSO_EXTENSIONS_DIR="/tmp" # this disables all extensions #Environment variables for the test application export G_MESSAGES_DEBUG=all # If running the test executable under a wrapper, setup the tests so that the # wrapper can debug them more easily. if [ -n "$WRAPPER" ]; then export G_SLICE=always-malloc export CK_FORK="no" else export G_SLICE=debug-blocks fi # If dbus-test-runner exists, use it to run the tests in a separate D-Bus # session if command -v dbus-test-runner > /dev/null ; then echo "Using dbus-test-runner" dbus-test-runner -m 180 --keep-env \ -t signond -r \ -t "$TEST_APP" -f com.google.code.AccountsSSO.SingleSignOn else echo "Using existing D-Bus session" pkill signond || true trap "pkill -9 signond" EXIT signond & sleep 2 $TEST_APP fi 07070100000039000081A4000003E800000064000000015BDC2CEA00000257000000000000000000000000000000000000002300000000libsignon-glib-2.1/tests/tests.xml <testdefinition version="0.1"> <suite name="libsignon-glib1-tests" domain="Accounts and SSO"> <set description="libsignon-glib1-tests:signon-glib-tests" name="/usr/bin/signon-glib-test.sh"> <case description="libsignon-glib-tests:signon-glib-test.sh" name="signon-glib-test.sh" type="Functional" level="Feature" timeout="1600"> <step>/usr/bin/signon-glib-test.sh</step> </case> <environments><scratchbox>true</scratchbox> <hardware>true</hardware></environments> </set> </suite> </testdefinition> 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!568 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor