CoreTokenFieldTypes.java revision b334b83b7ac2d9a8c60d935cad0365506f13333b
/**
* Copyright 2013 ForgeRock, Inc.
*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*/
/**
* Provides the mapping between CoreTokenFields and the type of the value that is associated to
* that field.
*
* There are currently a number of uses for the type information of a Core Token Field:
* - Manipulating a Token via its generic fields.
* - Persisting a Token to LDAP
*
* Both of these cases need to know the type of the value stored in the Tokens map.
*
* @author robert.wapshott@forgerock.com
*/
public class CoreTokenFieldTypes {
/**
*
* @param types A mapping of CoreTokenField to value. Non null, may be empty.
* @throws com.sun.identity.sm.ldap.exceptions.LDAPOperationFailedException If one of the values was invalid for the CoreTokenField field.
*/
}
}
/**
* Validate the value matches the expected type for the given key.
*
* @param field The CoreTokenField to validate against.
* @param value The value to verify. Non null.
* @throws com.sun.identity.sm.ldap.exceptions.LDAPOperationFailedException
*/
"\n" +
"Value field cannot be null!" +
"Key: {0}:{1}",
CoreTokenField.class.getSimpleName(),
}
try {
} else if (isCalendar(field)) {
} else if (isByteArray(field)) {
assertClass(value, byte[].class);
} else {
}
} catch (LDAPOperationFailedException e) {
"\n" +
"Value was not the correct type:\n" +
" Key: {0}:{1}\n" +
"Required Class: {2}" +
" Actual Class: {3}",
CoreTokenField.class.getSimpleName(),
e.getMessage(),
e);
}
}
/**
* @param field Non null field to check.
* @return True if the field is a Date.
*/
// Intentional fall-through
switch (field) {
case EXPIRY_DATE:
case DATE_ONE:
case DATE_TWO:
case DATE_THREE:
case DATE_FOUR:
case DATE_FIVE:
return true;
default:
return false;
}
}
/**
* @param field Non null field to check.
* @return True if the field is an Integer.
*/
// Intentional fall-through
switch (field) {
case INTEGER_ONE:
case INTEGER_TWO:
case INTEGER_THREE:
case INTEGER_FOUR:
case INTEGER_FIVE:
case INTEGER_SIX:
case INTEGER_SEVEN:
case INTEGER_EIGHT:
case INTEGER_NINE:
case INTEGER_TEN:
return true;
default:
return false;
}
}
/**
* @param field Non null field to check.
* @return True if the field is a String.
*/
switch (field) {
case TOKEN_ID:
case USER_ID:
case STRING_ONE:
case STRING_TWO:
case STRING_THREE:
case STRING_FOUR:
case STRING_FIVE:
case STRING_SIX:
case STRING_SEVEN:
case STRING_EIGHT:
case STRING_NINE:
case STRING_TEN:
case STRING_ELEVEN:
case STRING_TWELVE:
case STRING_THIRTEEN:
case STRING_FOURTEEN:
case STRING_FIFTEEN:
return true;
default:
return false;
}
}
/**
* @param field Non null field to check.
* @return True if the field is a binary field.
*/
}
/**
* Perform a simple class assertion.
* @param value Non null value to assert.
* @param clazz Non null class to assert against.
* @throws com.sun.identity.sm.ldap.exceptions.LDAPOperationFailedException If the value was not assignable from the clazz.
*/
}
}
}