}
/**
- * gsignond_identity_info_check_method_mechanism:
- * @info: instance of #GSignondIdentityInfo
- *
- * @method: the method to be checked for.
- *
- * @mechanism: the mechanism(s) to be checked for.
- *
- * @allowed_mechanisms: (out) string of the allowed mechanisms
- *
- * Checks which mechanisms are allowed for the given method and returns the
- * allowed mechanism(s) in the string.
- *
- * Returns: TRUE if check is successful, FALSE otherwise.
- */
-gboolean
-gsignond_identity_info_check_method_mechanism (
- GSignondIdentityInfo *info,
- const gchar *method,
- const gchar *mechanism,
- gchar **allowed_mechanisms)
-{
- g_assert (info != NULL);
-
- GSequence *mechanisms = NULL;
- gchar ** split_mechs = NULL;
- GString* allowed_mechs = NULL;
- gint i, j=0;
- const gchar *space = " ";
-
- g_return_val_if_fail (info != NULL, FALSE);
- g_return_val_if_fail (method != NULL && mechanism != NULL, FALSE);
-
- *allowed_mechanisms = NULL;
- mechanisms = gsignond_identity_info_get_mechanisms (info, method);
- if (mechanisms == NULL) {
- return TRUE;
- }
-
- if (g_sequence_lookup (mechanisms, (gpointer)mechanism,
- (GCompareDataFunc) _compare_strings, NULL) != NULL) {
- *allowed_mechanisms = g_strdup (mechanism);
- g_sequence_free (mechanisms);
- return TRUE;
- }
- split_mechs = g_strsplit (mechanism, space, 0);
- if (g_strv_length (split_mechs) <= 1 ) {
- g_sequence_free (mechanisms);
- if (split_mechs) g_strfreev (split_mechs);
- return FALSE;
- }
-
- allowed_mechs = g_string_new (NULL);
- i = 0;
- while (split_mechs[i]) {
- if (g_sequence_lookup (mechanisms, (gpointer)split_mechs[i],
- (GCompareDataFunc)_compare_strings, NULL) != NULL) {
- if (j > 0) {
- g_string_append (allowed_mechs, space);
- }
- g_string_append (allowed_mechs, split_mechs[i]);
- ++j;
- }
- ++i;
- }
- g_strfreev (split_mechs);
- g_sequence_free (mechanisms);
-
- *allowed_mechanisms = g_string_free (allowed_mechs, FALSE);
-
- return TRUE;
-}
-
-/**
* gsignond_identity_info_compare:
* @info: instance1 of #GSignondIdentityInfo
*
GSignondSecurityContext *ctx, *ctx1, *ctx2, *ctx3 ;
GHashTable *methods = NULL, *methods2;
GSequence *seq1 = NULL, *seq_realms, *seq21, *mechs;
- gchar *allowmech;
GList *list2;
identity = gsignond_identity_info_new ();
fail_unless (gsignond_identity_info_remove_method (
identity, "method4") == TRUE);
- allowmech = NULL;
- fail_unless (gsignond_identity_info_check_method_mechanism (
- identity, "method4", "mech567", &allowmech) == TRUE);
-
- allowmech = NULL;
- fail_unless (gsignond_identity_info_check_method_mechanism (
- identity, "method1", "mech11", &allowmech) == TRUE);
- fail_if (allowmech == NULL);
-
- fail_unless (g_strcmp0 (allowmech, "mech11") == 0);
- g_free (allowmech);allowmech = NULL;
-
- fail_unless (gsignond_identity_info_check_method_mechanism (
- identity, "method1", "mech11 mech12", &allowmech) == TRUE);
- fail_unless (g_strcmp0 (allowmech, "mech11 mech12") == 0);
- g_free (allowmech);allowmech = NULL;
-
- fail_unless (gsignond_identity_info_check_method_mechanism (
- identity, "method1", "mech21", &allowmech) == FALSE);
- if (allowmech) {
- g_free (allowmech);allowmech = NULL;
- }
/*acl*/
ctx1 = gsignond_security_context_new_from_values ("sysctx1", "appctx1");
ctx2 = gsignond_security_context_new_from_values ("sysctx2", "appctx2");