LassoServer

## LassoServer LassoServer — Representation of the current server |

## Synopsis

    struct              LassoServer;
    LassoServer *       lasso_server_new                    (const gchar *metadata,
                                                             const gchar *private_key,
                                                             const gchar *private_key_password,
                                                             const gchar *certificate);
    LassoServer *       lasso_server_new_from_buffers       (const gchar *metadata,
                                                             const gchar *private_key_content,
                                                             const gchar *private_key_password,
                                                             const gchar *certificate_content);
    LassoServer *       lasso_server_new_from_dump          (const gchar *dump);
    lasso_error_t       lasso_server_add_provider           (LassoServer *server,
                                                             LassoProviderRole role,
                                                             const gchar *metadata,
                                                             const gchar *public_key,
                                                             const gchar *ca_cert_chain);
    lasso_error_t       lasso_server_add_provider_from_buffer
                                                            (LassoServer *server,
                                                             LassoProviderRole role,
                                                             const gchar *metadata,
                                                             const gchar *public_key,
                                                             const gchar *ca_cert_chain);
    void                lasso_server_destroy                (LassoServer *server);
    gchar *             lasso_server_dump                   (LassoServer *server);
    LassoProvider *     lasso_server_get_provider           (const LassoServer *server,
                                                             const gchar *providerID);
    lasso_error_t       lasso_server_set_encryption_private_key
                                                            (LassoServer *server,
                                                             const gchar *filename_or_buffer);
    lasso_error_t       lasso_server_set_encryption_private_key_with_password
                                                            (LassoServer *server,
                                                             const gchar *filename_or_buffer,
                                                             const gchar *password);
    lasso_error_t       lasso_server_load_affiliation       (LassoServer *server,
                                                             const gchar *filename);
    lasso_error_t       lasso_server_saml2_assertion_setup_signature
                                                            (LassoServer *server,
                                                             LassoSaml2Assertion *saml2_assertion);

## Description

It holds the data about a provider, other providers it knows, which certificates to use, etc.

## Details

### struct LassoServer

    struct LassoServer {
    	LassoProvider parent;

    	GHashTable *providers; /* of LassoProvider */
    	/* Can actually contain LassoDataService or LassoIdWsf2DataService or any subclass */

    	gchar *private_key;
    	gchar *private_key_password;
    	gchar *certificate;
    	LassoSignatureMethod signature_method;
    };

### lasso_server_new ()

    LassoServer *       lasso_server_new                    (const gchar *metadata,
                                                             const gchar *private_key,
                                                             const gchar *private_key_password,
                                                             const gchar *certificate);

Creates a new LassoServer.

`metadata` : | path to the provider metadata file or NULL, for a LECP server
`private_key:(allow-none)` : | path to the the server private key file or NULL
`private_key_password:(allow-none)` : | password to private key if it is encrypted, or NULL
`certificate:(allow-none)` : | path to the server certificate file, or NULL
Returns : | a newly created LassoServer object; or NULL if an error occured

### lasso_server_new_from_buffers ()

    LassoServer *       lasso_server_new_from_buffers       (const gchar *metadata,
                                                             const gchar *private_key_content,
                                                             const gchar *private_key_password,
                                                             const gchar *certificate_content);

Creates a new LassoServer.

`metadata` : | NULL terminated string containing the content of an ID-FF 1.2 metadata file
`private_key_content:(allow-none)` : | NULL terminated string containing a PEM formatted private key
`private_key_password:(allow-none)` : | a NULL terminated string which is the optional password of the private key
`certificate_content:(allow-none)` : | NULL terminated string containing a PEM formatted X509 certificate
Returns : | a newly created LassoServer object; or NULL if an error occured

### lasso_server_new_from_dump ()

    LassoServer *       lasso_server_new_from_dump          (const gchar *dump);

Restores the `dump` to a new LassoServer.

`dump` : | XML server dump
Returns : | a newly created LassoServer; or NULL if an error occured

### lasso_server_add_provider ()

    lasso_error_t       lasso_server_add_provider           (LassoServer *server,
                                                             LassoProviderRole role,
                                                             const gchar *metadata,
                                                             const gchar *public_key,
                                                             const gchar *ca_cert_chain);

Creates a new LassoProvider and makes it known to the `server`

`server` : | a LassoServer
`role` : | provider role, identity provider or service provider
`metadata` : | path to the provider metadata file
`public_key:(allow-none)` : | provider public key file (may be a certificate) or NULL
`ca_cert_chain:(allow-none)` : | provider CA certificate chain file or NULL
Returns : | 0 on success; a negative value if an error occured.

### lasso_server_add_provider_from_buffer ()

    lasso_error_t       lasso_server_add_provider_from_buffer
                                                            (LassoServer *server,
                                                             LassoProviderRole role,
                                                             const gchar *metadata,
                                                             const gchar *public_key,
                                                             const gchar *ca_cert_chain);

Creates a new LassoProvider and makes it known to the `server`

`server` : | a LassoServer
`role` : | provider role, identity provider or service provider
`metadata` : | a string buffer containg the metadata file for a new provider
`public_key:(allow-none)` : | provider public key file (may be a certificate) or NULL
`ca_cert_chain:(allow-none)` : | provider CA certificate chain file or NULL
Returns : | 0 on success; a negative value if an error occured.

### lasso_server_destroy ()

    void                lasso_server_destroy                (LassoServer *server);

Destroys a server.

`server` : | a LassoServer

### lasso_server_dump ()

    gchar *             lasso_server_dump                   (LassoServer *server);

Dumps `server` content to an XML string.

`server` : | a LassoServer
Returns : | the dump string. It must be freed by the caller. [transfer full]

### lasso_server_get_provider ()

    LassoProvider *     lasso_server_get_provider           (const LassoServer *server,
                                                             const gchar *providerID);

Looks up for a LassoProvider whose ID is `providerID` and returns it.

`server` : | a LassoServer
`providerID` : | the provider ID
Returns : | the LassoProvider, NULL if it was not found. The LassoProvider is owned by Lasso and should not be freed. [transfer none]

### lasso_server_set_encryption_private_key ()

    lasso_error_t       lasso_server_set_encryption_private_key
                                                            (LassoServer *server,
                                                             const gchar *filename_or_buffer);

### Warning

`lasso_server_set_encryption_private_key` has been deprecated since version 2.3 and should not be used in newly-written code. Use `lasso_server_set_encryption_private_key_with_password()` instead.

Load an encryption private key from a file and set it in the server object

If `filename_or_buffer` is NULL, it frees the currently setted key.

`server` : | a LassoServer
`filename_or_buffer:(allow-none)` : | file name of the encryption key to load or its content as a NULL-terminated string.
Returns : | 0 on success; another value if an error occured.

### lasso_server_set_encryption_private_key_with_password ()

    lasso_error_t       lasso_server_set_encryption_private_key_with_password
                                                            (LassoServer *server,
                                                             const gchar *filename_or_buffer,
                                                             const gchar *password);

Load an encryption private key from a file and set it in the server object. If `password` is non-NULL try to decrypt the key with it.

If `filename_or_buffer` is NULL, it frees the currently setted key.

`server` : | a LassoServer
`filename_or_buffer:(allow-none)` : | file name of the encryption key to load or its content as a NULL-terminated string.
`password:(allow-none)` : | an optional password to decrypt the encryption key.
Returns : | 0 on success; another value if an error occured.

Since 2.3

### lasso_server_load_affiliation ()

    lasso_error_t       lasso_server_load_affiliation       (LassoServer *server,
                                                             const gchar *filename);

Load an affiliation metadata file into `server`; this must be called after providers have been added to `server`.

`server` : | a LassoServer
`filename` : | file name of the affiliation metadata to load
Returns : | 0 on success; another value if an error occured.

### lasso_server_saml2_assertion_setup_signature ()

    lasso_error_t       lasso_server_saml2_assertion_setup_signature
                                                            (LassoServer *server,
                                                             LassoSaml2Assertion *saml2_assertion);

Configure signature on a saml2:Assertion element.

`server` : | a LassoServer object
`saml2_assertion` : | a LassoSaml2Assertion object
Returns : | 0 if successfull, an error code otherwise.