Esempio n. 1
0
Credential::Credential(const Credential& original, CredentialPersistence persistence)
    : m_user(original.user())
    , m_password(original.password())
    , m_persistence(persistence)
#if CERTIFICATE_CREDENTIALS_SUPPORTED
    , m_identity(original.identity())
    , m_certificates(original.certificates())
    , m_type(original.type())
#endif
{
}
Esempio n. 2
0
bool operator==(const Credential& a, const Credential& b)
{
    // Check persistence first since all credential types
    // have the persistence property.
    if (a.persistence() != b.persistence())
        return false;
    
#if CERTIFICATE_CREDENTIALS_SUPPORTED
    CredentialType aType = a.type();
    if (aType != b.type())
        return false;
    
    // Comparing identity and certificate chain pointers is valid only
    // for client certificate type credentials.
    //
    // FIXME: Is pointer comparison of the identity and certificates properties sufficient?
    if (aType == CredentialTypeClientCertificate) {
        if (a.identity() != b.identity())
            return false;
        if (a.certificates() != b.certificates())
            return false;
        
        // We only need to check identity and certificates to compare
        // client certificate based credentials.
        return true;
    }
    
    ASSERT(a.type() == CredentialTypePassword && b.type() == CredentialTypePassword);
#endif    
    
    if (a.user() != b.user())
        return false;
    if (a.password() != b.password())
        return false;
        
    return true;
}
Esempio n. 3
0
CFURLCredentialRef createCF(const Credential& coreCredential)
{
    CFURLCredentialPersistence persistence = kCFURLCredentialPersistenceNone;
    switch (coreCredential.persistence()) {
    case CredentialPersistenceNone:
        break;
    case CredentialPersistenceForSession:
        persistence = kCFURLCredentialPersistenceForSession;
        break;
    case CredentialPersistencePermanent:
        persistence = kCFURLCredentialPersistencePermanent;
        break;
    default:
        ASSERT_NOT_REACHED();
    }
    
#if CERTIFICATE_CREDENTIALS_SUPPORTED
    if (coreCredential.type() == CredentialTypeClientCertificate)
        return CFURLCredentialCreateWithIdentityAndCertificateArray(kCFAllocatorDefault, coreCredential.identity(), coreCredential.certificates(), persistence);
#endif

    CFStringRef user = coreCredential.user().createCFString();
    CFStringRef password = coreCredential.password().createCFString();
    CFURLCredentialRef result = CFURLCredentialCreate(0, user, password, 0, persistence);
    CFRelease(user);
    CFRelease(password);

    return result;
}