Directory src/examples contains code examples that demonstrate how an application
("service provider" in terms of SAML specification) can use single sign-on
server SSO-2.0 ("identity provider" in terms of SAML specification).


        ---
        DEPENDENCIES

These examples require following:

1. PHP command line interpreter version 5.1 or later with OpenSSL module

2. HTTP_Request package. Get it from Pear repository: http://pear.php.net/package/HTTP_Request

3. lighttpd server


        ---
        FILES

* src/examples/sp_registration.php
	Utility that allows to register and unregister an application in SSO server.
	Execute "php sp_registration.php" to print usage information.

* src/examples/example.reg-request
	Example registration data file to be used with sp_registration.php.
	Modify it to suit your environment.

* src/examples/auth/
    Contains code that demonstrates use of SAML authentication. These examples
    require a HTTP server. See ONLINE SP EXAMPLES section below for details.

    * name_mapper.php
    User id mapping service example.

    * proxied_auth.php
        Credentials checker example.

    * ui.php
        Example implementation of foreign UI.

    * auth.php
        Page that sents authentication request.

    * logout.php
        Page that sends single logout request.

    * SAML.php
        Handler of SAML messages that are sent from SSO server to application.

    * fi.php
        Example of federated identity management page.

        ---
        REGISTRATION EXAMPLES

These examples demonstrate how you can attach your application to SSO server.
Before your application can use SSO functionality it should be registered in
SSO server.
Registration instructions:
0. Note that you may have several registrations (be registered as several
different applications or be registered in several sso cervices). To have that
copy example.reg-request file to youChosenRegistraionName.reg-request
and use "yourChosenRegistraionName" as registration name.
Examples below assume that registration name is "example" and current
directory is src/examples.

1. Edit example.reg-request to match your environment

2. Execute
    php register_sp.php register example url_of_sso_service
where url_of_sso_service is for example https://sso.yourcompany.ink:11443

To update registration (if properties of your application has changed or you
need new cecurity certificate) execute
    php register_sp.php update example

To detach application from SSO server (so SSO server forgets all data related to your
application) execute
    php register_sp.php detach example


        ---
        ONLINE SP EXAMPLES

These examples require HTTP server. Provided configuration file assumes that
lighttpd server is used.

Examples in this section cover following use cases:
    * authentication
    * logout

UI renderer code however supports full set of required UI types.

Instructions:
1. Register example application in SSO server as described in REGISTRATION EXAMPLES section.
2. Start web server
    lighttpd -f auth/lighttpd.conf &
2. Open page http://localhost_name:8180/examples/auth/auth.php in browser.
You will be redirected to SSO server that will show you login user interface via UI renderer.

3. Login as user 'joe' with password '123'

4. Now you are logged-in and may request login page http://localhost_name:8180/examples/auth/auth.php
again.

5. To be signed-out, request page http://localhost_name:8180/examples/auth/logout.php