class AppKeyExecutor implements IAuthExecutor {

	@Override
	public AuthReport checkAllowed(Exchange exchange, Api api) {
		
		AuthReport authReport = new AuthReport();
		Object keyObj = null;
		
		Map<?, ?> parameters = exchange.getProperty(ExchangeConstantKeys.E3_REQUEST_PARAMETERS.toString(), Map.class);
		if (parameters == null) {
			if(logger.isDebugEnabled()) {
				logger.debug("Request parameters not set");
			}
			authReport.setBadRequest(true);
		} else {
		
			keyObj = parameters.get(keyName);
			if (keyObj == null) { // No parameter by keyName, checking for a header "headerName"
				keyObj = exchange.getIn().getHeader(headerName, String.class); 
				if (keyObj == null) {		
					// Abort
					if(logger.isDebugEnabled()) {
						logger.debug("Unable to find url parameter or header matching the provisioned api key name");
					}
					authReport.setBadRequest(true);
				}
			}
		}
		
		// if not a bad request
		if(!authReport.isBadRequest()) {
		
			String authKey = keyObj.toString();
			if(logger.isDebugEnabled()) {
				logger.debug("authKey= " + authKey);
			}
			
			// remove the credential from URL
			removeHttpQueryValue(exchange, keyName+"="+authKey);
			
			// remove the credential from Header
			exchange.getIn().removeHeader(headerName);
	
			//Call AuthManager
			try {
				authReport = dataAccess.checkAllowed(api, authKey);
			} catch(DataAccessRuntimeException e) {
					logger.error("Data Access Issue", e);
			} catch(Exception e) {
					logger.error("Data Access Issue", e);
			}
		}

		return authReport;
	}

	public  AppKeyExecutor(String keyname, String headerName, IAuthDataAccess dataAccess);

}