use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class EntitlementService method getApplicationSearchFilter.
private String getApplicationSearchFilter(Set<SearchFilter> filters) {
StringBuilder strFilter = new StringBuilder();
if ((filters == null) || filters.isEmpty()) {
strFilter.append("(ou=*)");
} else {
if (filters.size() == 1) {
strFilter.append(filters.iterator().next().getFilter());
} else {
strFilter.append("(&");
for (SearchFilter psf : filters) {
strFilter.append(psf.getFilter());
}
strFilter.append(")");
}
}
return strFilter.toString();
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class PrivilegePolicyStoreTest method shouldHandleStringEquality.
@Test
public void shouldHandleStringEquality() throws Exception {
// Given
String value = "testValue";
QueryRequest request = mockQueryRequest(QueryFilter.equalTo(new JsonPointer(STRING_ATTRIBUTE), value));
// When
testStore.query(request);
// Then
verify(mockManager).search(singleton(new SearchFilter(STRING_SEARCH_ATTRIBUTE, value)));
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldHandleAndQueries.
@Test
public void shouldHandleAndQueries() throws Exception {
// Given
String value1 = "value1";
String value2 = "value2";
QueryRequest request = mockQueryRequest(and(equalTo(new JsonPointer(STRING_ATTRIBUTE), value1), equalTo(new JsonPointer(STRING_ATTRIBUTE), value2)));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
SearchFilter searchFilter1 = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value1);
SearchFilter searchFilter2 = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value2);
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter1, searchFilter2)));
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldSupportDateQueries.
@Test(dataProvider = "SupportedQueryOperators")
public void shouldSupportDateQueries(String queryOperator, SearchFilter.Operator expectedOperator) throws Exception {
// Given
// Note: only second accuracy supported in timestamp format
Date value = new Date(123456789000l);
QueryRequest request = mockQueryRequest(comparisonFilter(new JsonPointer(DATE_ATTRIBUTE), queryOperator, DateUtils.toUTCDateFormat(value)));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
// Date should be converted into a time-stamp long value
SearchFilter searchFilter = new SearchFilter(new SearchAttribute(DATE_ATTRIBUTE, "ou"), value.getTime(), expectedOperator);
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter)));
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldTranslateAlwaysTrueQueryFilterToEmptySearchFilters.
@Test
public void shouldTranslateAlwaysTrueQueryFilterToEmptySearchFilters() throws Exception {
// Given
QueryRequest request = mockQueryRequest(QueryFilter.<JsonPointer>alwaysTrue());
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(Collections.<SearchFilter>emptySet()));
}
Aggregations