}
AuthType authType = AuthType.NO_AUTH;
boolean isAllowed = false;
AuthIdentity authIdentity = null;
AuthReport report = null;
AuthType reportAuth = null;
Iterator<IAuthExecutor> it = executors.iterator();
while(!isAllowed && it.hasNext()) {
IAuthExecutor executor = it.next();
AuthReport authReport = executor.checkAllowed(exchange, api);
isAllowed = authReport.isAllowed();
if (isAllowed) {
authIdentity = authReport.getAuthIdentity();
report = authReport;
} else {
if (report == null) {
report = authReport;
reportAuth = executor.getType();
} else {
if (report.compareTo(authReport) > 0) {
report = authReport;
reportAuth = executor.getType();
}
}
}
// The last executor
authType = executor.getType();
}
if (isAllowed) {
if(logger.isDebugEnabled()) {
logger.debug("Request allowed to use this Api");
}
} else {
if(logger.isDebugEnabled()) {
logger.debug("Request not allowed to use this Api");
}
handleReport(exchange, report, reportAuth);
}
// Put this in the exchange for TDRs
TDRDataService.setTxTDRProperty(TDRConstant.AUTHENTICATION, authType.value(), exchange);
// Set the authentication result in the exchange
exchange.setProperty(ExchangeConstantKeys.E3_AUTH_METHOD.toString(), authType.value());
//getting apiContext
String value = null;
if(authIdentity != null && authIdentity.getAuth() != null){
value = authIdentity.getAuth().getApiContext();
}
exchange.setProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY.toString(), authIdentity);
exchange.setProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY_APICONTEXT.toString(), value);
}