static gint lasso_server_add_provider_helper(LassoServer *server, LassoProviderRole role, const gchar *metadata, const gchar *public_key, const gchar *ca_cert_chain, LassoProvider *(*provider_constructor)(LassoProviderRole role, const char *metadata, const char *public_key, const char *ca_cert_chain)) { LassoProvider *provider; g_return_val_if_fail(LASSO_IS_SERVER(server), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); g_return_val_if_fail(metadata != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); provider = provider_constructor(role, metadata, public_key, ca_cert_chain); if (provider == NULL) { return critical_error(LASSO_SERVER_ERROR_ADD_PROVIDER_FAILED); } provider->role = role; if (LASSO_PROVIDER(server)->private_data->conformance == LASSO_PROTOCOL_SAML_2_0 && provider->private_data->conformance != LASSO_PROTOCOL_SAML_2_0) { lasso_node_destroy(LASSO_NODE(provider)); return LASSO_SERVER_ERROR_ADD_PROVIDER_PROTOCOL_MISMATCH; } if (LASSO_PROVIDER(server)->private_data->conformance == LASSO_PROTOCOL_LIBERTY_1_2 && provider->private_data->conformance > LASSO_PROTOCOL_LIBERTY_1_2) { lasso_node_destroy(LASSO_NODE(provider)); return LASSO_SERVER_ERROR_ADD_PROVIDER_PROTOCOL_MISMATCH; } g_hash_table_insert(server->providers, g_strdup(provider->ProviderID), provider); return 0; }
/** * lasso_identity_destroy: * @identity: a #LassoIdentity * * Destroys an identity. **/ void lasso_identity_destroy(LassoIdentity *identity) { if (identity == NULL) return; lasso_node_destroy(LASSO_NODE(identity)); }
/** * lasso_server_new_from_buffers: * @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 * * Creates a new #LassoServer. * * Return value: a newly created #LassoServer object; or NULL if an error occured */ LassoServer* lasso_server_new_from_buffers(const char *metadata, const char *private_key_content, const char *private_key_password, const char *certificate_content) { LassoServer *server; server = g_object_new(LASSO_TYPE_SERVER, NULL); /* metadata can be NULL (if server is a LECP) */ if (metadata != NULL) { if (lasso_provider_load_metadata_from_buffer(LASSO_PROVIDER(server), metadata) == FALSE) { message(G_LOG_LEVEL_CRITICAL, "Failed to load metadata from preloaded buffer"); lasso_node_destroy(LASSO_NODE(server)); return NULL; } } lasso_assign_string(server->certificate, certificate_content); if (private_key_content) { lasso_assign_string(server->private_key, private_key_content); lasso_assign_string(server->private_key_password, private_key_password); server->private_data->encryption_private_key = lasso_xmlsec_load_private_key_from_buffer(private_key_content, strlen(private_key_content), private_key_password); if (! server->private_data->encryption_private_key) { message(G_LOG_LEVEL_WARNING, "Cannot load the private key"); lasso_release_gobject(server); } } lasso_provider_load_public_key(&server->parent, LASSO_PUBLIC_KEY_SIGNING); lasso_provider_load_public_key(&server->parent, LASSO_PUBLIC_KEY_ENCRYPTION); return server; }
/** * lasso_ecp_destroy: * @ecp: a #LassoEcp * * Destroys a #LassoEcp object * **/ void lasso_ecp_destroy(LassoEcp *ecp) { lasso_node_destroy(LASSO_NODE(ecp)); }
/** * lasso_server_destroy: * @server: a #LassoServer * * Destroys a server. **/ void lasso_server_destroy(LassoServer *server) { lasso_node_destroy(LASSO_NODE(server)); }