package com.eactive.eai.agent.security;

import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommandException;
import com.eactive.eai.common.security.CryptoModuleManager;
import com.eactive.eai.common.util.Logger;

public class ReloadCryptoModuleCommand extends Command {

	private static final long serialVersionUID = 1032982004418318100L;

	@Override
	public Object execute() throws CommandException {
		Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
		try {
			String cryptoId = (String) args;
			CryptoModuleManager.getInstance().reload(cryptoId);
			return "success";
		} catch (Exception e) {
			String rspErrorCode = "RECEAIMCM002";
			String msg = this.makeException(rspErrorCode, e);
			if (logger.isError()) {
				logger.error(msg, e);
			}
			throw new CommandException(e.getMessage());
		}
	}
}
