Beispiel #1
0
static void
try_security_mechanism (server_t *self, client_t *client)
{
    client->next_event = foe_event;                                                          
    char *login, *password;                                                                  
    if (streq (fmq_msg_mechanism (client->request), "PLAIN")                                 
    &&  fmq_sasl_plain_decode (fmq_msg_response (client->request), &login, &password) == 0) {
        zconfig_t *account = zconfig_locate (self->config, "security/plain/account");        
        while (account) {                                                                    
            if (streq (zconfig_resolve (account, "login", ""), login)                        
            &&  streq (zconfig_resolve (account, "password", ""), password)) {               
                client->next_event = friend_event;                                           
                break;                                                                       
            }                                                                                
            account = zconfig_next (account);                                                
        }                                                                                    
    }                                                                                        
    free (login);                                                                            
    free (password);                                                                         
}
Beispiel #2
0
//  --------------------------------------------------------------------------
//  Self test of this class
int
fmq_sasl_test (bool verbose)
{
    printf (" * fmq_sasl: ");

    //  @selftest
    zframe_t *frame = fmq_sasl_plain_encode ("Happy", "Harry");
    char *login, *password;
    int rc = fmq_sasl_plain_decode (frame, &login, &password);
    assert (rc == 0);
    assert (streq (login, "Happy"));
    assert (streq (password, "Harry"));
    zframe_destroy (&frame);
    free (login);
    free (password);
    //  @end

    printf ("OK\n");
    return 0;
}