コード例 #1
0
bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
{
    rawCookies.clear();

    RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());

    bool sendSecureCookies = url.protocolIs("https");
    RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), sendSecureCookies));

    CFIndex count = CFArrayGetCount(cookiesCF.get());
    rawCookies.reserveCapacity(count);

    for (CFIndex i = 0; i < count; i++) {
       CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
       String name = cookieName(cookie).get();
       String value = cookieValue(cookie).get();
       String domain = cookieDomain(cookie).get();
       String path = cookiePath(cookie).get();

       double expires = (cookieExpirationTime(cookie) + kCFAbsoluteTimeIntervalSince1970) * 1000;

       bool httpOnly = CFHTTPCookieIsHTTPOnly(cookie);
       bool secure = CFHTTPCookieIsSecure(cookie);
       bool session = false;    // FIXME: Need API for if a cookie is a session cookie.

       rawCookies.uncheckedAppend(Cookie(name, value, domain, path, expires, httpOnly, secure, session));
    }

    return true;
}
コード例 #2
0
ファイル: Cookie.cpp プロジェクト: BackupTheBerlios/qedo
//
// Cookie
//
Cookie_impl::Cookie_impl
()
{
	CORBA::OctetSeq_var octet_key = new CORBA::OctetSeq();

	octet_key -> length ( 20 );

	for ( unsigned int i = 0; i < 20; i++ )
	{
		(*octet_key)[i] = ((char*)(&cookie_key_))[i];
	}

	cookieValue ( *octet_key );
}
コード例 #3
0
//
// Cookie
//
Cookie_impl::Cookie_impl()
{
	CORBA::OctetSeq_var octet_key = new CORBA::OctetSeq();

	octet_key->length (8);

	for (unsigned int i = 0; i < 8; i++)
	{
		octet_key.inout()[i] = ((char*)(&cookie_key_))[i];
	}

	cookieValue (octet_key.in());

    ++cookie_key_;
}
コード例 #4
0
CORBA::Boolean 
Cookie_impl::equal (Components::Cookie* cook)
{
	Cookie_impl* foreign_cook = dynamic_cast<Cookie_impl*>(cook);

	if (! foreign_cook)
		return false;

	CORBA::OctetSeq x = cookieValue();
	CORBA::OctetSeq y = foreign_cook->cookieValue();

	for (unsigned int i = 0; i < x.length(); i++)
	{
		if (x[i] != y[i])
			return false;
    }
    
	return true;
}
コード例 #5
0
ファイル: Cookie.cpp プロジェクト: BackupTheBerlios/qedo
bool 
Cookie_impl::equal
( Components::Cookie* cook )
{
	CORBA::OctetSeq x = cookieValue();

	Cookie_impl* cook_impl = dynamic_cast < Cookie_impl* > ( cook );

	if ( ! cook_impl )
		return false;

	CORBA::OctetSeq y = dynamic_cast<Cookie_impl*>(cook) -> cookieValue();

	if ( x.length() != y.length() )
		return false;
    
	for ( unsigned int i = 0; i < x.length(); i++ )
	{
		if ( x[i] != y[i] )
			return false;
    }
    
	return true;
}
コード例 #6
0
ファイル: Cookie.cpp プロジェクト: BackupTheBerlios/qedo
Cookie_impl::Cookie_impl
( const CORBA::OctetSeq& val )
{
	cookieValue ( val );
}
コード例 #7
0
ファイル: HippoPlatformImpl.cpp プロジェクト: nihed/magnetism
static gboolean
read_ie_login_cookie(const char       *web_host,
                     char            **username_p,
                     char            **password_p)
{
    WCHAR staticBuffer[1024];
    WCHAR *allocBuffer = NULL;
    WCHAR *cookieBuffer = staticBuffer;
    DWORD cookieSize = sizeof(staticBuffer) / sizeof(staticBuffer[0]);
    char *cookie = NULL;
    HippoBSTR authUrl;

    *username_p = NULL;
    *password_p = NULL;
    
    makeAuthUrl(web_host, &authUrl);

retry:
    *cookieBuffer = 0;
    if (!InternetGetCookieEx(authUrl, 
                             L"auth",
                             cookieBuffer, &cookieSize,
                             0,
                             NULL))
    {
        HRESULT error = GetLastError();
        if (error == ERROR_INSUFFICIENT_BUFFER) {
            cookieBuffer = allocBuffer = new WCHAR[cookieSize];
            if (!cookieBuffer)
                goto out;
            goto retry;
        } else {
            hippoDebugLogW(L"Failed to get auth cookie %d", (int) error);
            cookieSize = 0;
        }
    }

    WCHAR *p = cookieBuffer;
    WCHAR *nextCookie = NULL;
    for (WCHAR *p = cookieBuffer; p < cookieBuffer + cookieSize; p = nextCookie + 1) {
        HippoBSTR host;
        HippoBSTR username;
        HippoBSTR password;

        nextCookie = wcschr(p, ';');
        if (!nextCookie)
            nextCookie = cookieBuffer + cookieSize;

        while (*p == ' ' || *p == '\t') // Skip whitespace after ;
            p++;

        if (!startsWith(p, L"auth="))
            continue;

        p += 5; // Skip 'auth='

        HippoUStr cookieValue(p, (int) (nextCookie - p));
    
        if (hippo_parse_login_cookie(cookieValue.c_str(), web_host, username_p, password_p)) {
            //hippoDebugLogU("using cookie '%s'", cookieValue.c_str());
            break;
        }

        //hippoDebugLogU("skipping cookie '%s'", cookieValue.c_str());
    }

out:
    delete[] allocBuffer;

    return (*username_p && *password_p);
}