public class Utils {
public static XKMSConfigData populateXKMSConfig(HttpServletRequest request) {
String paramValue;
XKMSConfigData configData = new XKMSConfigData();
if (request.getParameter(XKMSMgtConstants.SERVER_AUTHENTICATION_CODE) != null) {
paramValue = request.getParameter(XKMSMgtConstants.SERVER_AUTHENTICATION_CODE);
configData.setAuthenCode(paramValue);
}
if (request.getParameter(XKMSMgtConstants.KEY_STORE_LOCATION) != null) {
paramValue = request.getParameter(XKMSMgtConstants.KEY_STORE_LOCATION);
configData.setKeystoreLocation(paramValue);
}
if (request.getParameter(XKMSMgtConstants.KEY_STORE_PASSWORD) != null) {
paramValue = request.getParameter(XKMSMgtConstants.KEY_STORE_PASSWORD);
configData.setKeystorePassword(paramValue);
}
if (request.getParameter(XKMSMgtConstants.SERVER_CERT_ALIACE) != null) {
paramValue = request.getParameter(XKMSMgtConstants.SERVER_CERT_ALIACE);
configData.setServerCertAlias(paramValue);
}
if (request.getParameter(XKMSMgtConstants.SERVER_KEY_PASSWORD) != null) {
paramValue = request.getParameter(XKMSMgtConstants.SERVER_KEY_PASSWORD);
configData.setServerKeyPassword(paramValue);
}
if (request.getParameter(XKMSMgtConstants.ISSUER_CERT_ALIACE) != null) {
paramValue = request.getParameter(XKMSMgtConstants.ISSUER_CERT_ALIACE);
configData.setIssuerCertAlias(paramValue);
}
if (request.getParameter(XKMSMgtConstants.ISSUER_KEY_PASSWORD) != null) {
paramValue = request.getParameter(XKMSMgtConstants.ISSUER_KEY_PASSWORD);
configData.setIssuerKeyPassword(paramValue);
}
if (request.getParameter(XKMSMgtConstants.DEFAULT_EXPIRY_INTERVAL) != null) {
paramValue = request.getParameter(XKMSMgtConstants.DEFAULT_EXPIRY_INTERVAL);
int interval = Integer.parseInt(paramValue);
configData.setDefaultExpriyInterval(interval);
}
if (request.getParameter(XKMSMgtConstants.DEFAULT_PRIVATE_KEY_PASSWORD) != null) {
paramValue = request.getParameter(XKMSMgtConstants.DEFAULT_PRIVATE_KEY_PASSWORD);
configData.setDefaultPrivateKeyPassword(paramValue);
}
if (request.getParameter(XKMSMgtConstants.ENABLE_PERSISTENCE) != null) {
paramValue = request.getParameter(XKMSMgtConstants.ENABLE_PERSISTENCE);
configData.setPersistenceEnabled(Boolean.parseBoolean(paramValue));
}
return configData;
}