use of org.forgerock.openam.tokens.CoreTokenField in project OpenAM by OpenRock.
the class QueryBuilder method returnTheseAttributes.
/**
* Limit the search to return only the named attributes.
*
* @param returnFields Collection of CoreTokenField that are required in the search results.
* @return The QueryBuilder instance.
* @throws IllegalArgumentException If the requested fields were null or empty.
*/
public QueryBuilder<C, F> returnTheseAttributes(Collection<CoreTokenField> returnFields) {
Reject.ifTrue(returnFields == null || returnFields.isEmpty());
Set<String> fields = new HashSet<String>();
for (CoreTokenField field : returnFields) {
fields.add(field.toString());
}
return setReturnAttributes(fields);
}
use of org.forgerock.openam.tokens.CoreTokenField in project OpenAM by OpenRock.
the class TokenTest method shouldStoreInteger.
@Test
public void shouldStoreInteger() {
// Given
Integer value = new Integer(12345);
CoreTokenField key = CoreTokenField.INTEGER_EIGHT;
Token token = new Token("", TokenType.SESSION);
// When
token.setAttribute(key, value);
// Then
assertEquals(value, token.getValue(key));
}
use of org.forgerock.openam.tokens.CoreTokenField in project OpenAM by OpenRock.
the class TokenTest method shouldStoreString.
@Test
public void shouldStoreString() {
// Given
CoreTokenField key = CoreTokenField.STRING_ONE;
String value = "Badger";
Token token = new Token("", TokenType.SESSION);
// When
token.setAttribute(key, value);
// Then
assertEquals(value, token.getValue(key));
}
use of org.forgerock.openam.tokens.CoreTokenField in project OpenAM by OpenRock.
the class TokenTest method shouldReturnNotReturnAttributesForUnsetAttributes.
@Test
public void shouldReturnNotReturnAttributesForUnsetAttributes() {
// Given
Token token = new Token("ID", TokenType.SESSION);
CoreTokenField field = CoreTokenField.STRING_ONE;
// Set and clear an attribute
token.setAttribute(field, "badger");
token.clearAttribute(field);
// When
Collection<CoreTokenField> fields = token.getAttributeNames();
// Then
assertEquals(fields.size(), 2);
}
use of org.forgerock.openam.tokens.CoreTokenField in project OpenAM by OpenRock.
the class TokenTest method shouldRespectReadOnlyField.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldRespectReadOnlyField() {
// Given
CoreTokenField key = CoreTokenField.TOKEN_ID;
assertEquals(true, Token.isFieldReadOnly(key));
Token token = new Token("", TokenType.SESSION);
// When/Then
token.setAttribute(key, "");
}
Aggregations