Search in sources :

Example 1 with CompositeCollection

use of org.apache.commons.collections.collection.CompositeCollection in project heritrix3 by internetarchive.

the class BdbCookieStore method cookieStoreFor.

/**
 * Returns a {@link LimitedCookieStoreFacade} whose
 * {@link LimitedCookieStoreFacade#getCookies()} method returns only cookies
 * from {@code host} and its parent domains, if applicable.
 */
public CookieStore cookieStoreFor(String host) {
    CompositeCollection cookieCollection = new CompositeCollection();
    if (InternetDomainName.isValid(host)) {
        InternetDomainName domain = InternetDomainName.from(host);
        while (domain != null) {
            Collection<Cookie> subset = hostSubset(domain.toString());
            cookieCollection.addComposited(subset);
            if (domain.hasParent()) {
                domain = domain.parent();
            } else {
                domain = null;
            }
        }
    } else {
        Collection<Cookie> subset = hostSubset(host.toString());
        cookieCollection.addComposited(subset);
    }
    @SuppressWarnings("unchecked") List<Cookie> cookieList = new RestrictedCollectionWrappedList<Cookie>(cookieCollection);
    LimitedCookieStoreFacade store = new LimitedCookieStoreFacade(cookieList);
    return store;
}
Also used : Cookie(org.apache.http.cookie.Cookie) InternetDomainName(com.google.common.net.InternetDomainName) CompositeCollection(org.apache.commons.collections.collection.CompositeCollection)

Example 2 with CompositeCollection

use of org.apache.commons.collections.collection.CompositeCollection in project DKSR-Open-UrbanPulse by DKSR-Data-Competence-for-Cities-Regions.

the class UPSecurityRealmTest method testReturnNullWhenFromRealmResultIsEmpty.

@Test
public void testReturnNullWhenFromRealmResultIsEmpty() {
    when(principalCollectionMock.fromRealm(anyString())).thenReturn(new CompositeCollection());
    assertNull(uPSecurityRealm.doGetAuthorizationInfo(principalCollectionMock));
}
Also used : CompositeCollection(org.apache.commons.collections.collection.CompositeCollection) Test(org.junit.Test)

Aggregations

CompositeCollection (org.apache.commons.collections.collection.CompositeCollection)2 InternetDomainName (com.google.common.net.InternetDomainName)1 Cookie (org.apache.http.cookie.Cookie)1 Test (org.junit.Test)1