* @param auth
* @return authReport instance
*/
private AuthReport getAuthReport(Api api, Auth auth) {
AuthReport authReport = new AuthReport();
if(api != null) {
// check if the API is active (status)
authReport.setApiActive(api.getStatus().isActive());
if(authReport.isApiActive()) {
List<CallDescriptor> descriptors = null;
if(auth != null) {
authReport.setAuthActive(auth.getStatus().isActive());
// with auth
descriptors = this.dataManager.getMatchingPolicies(api, auth);
if (descriptors != null) {
// check if a policy exists
boolean foundPolicy = false;
for (CallDescriptor callDescriptor : descriptors) {
if (callDescriptor.getPolicy() != null) {
foundPolicy = true;
break;
}
}
if (foundPolicy) {
authReport.setAuthIdentity(new AuthIdentity());
authReport.getAuthIdentity().setApi(api);
authReport.getAuthIdentity().setAuth(auth);
authReport.getAuthIdentity().getCallDescriptors().addAll(descriptors);
} else {
if(logger.isDebugEnabled()) {
logger.debug("No policy found");
}
authReport.setHasNoPolicy(true);
}
} else {
if(logger.isDebugEnabled()) {
logger.debug("Auth does not match with API");
}
authReport.setNotAuthorized(true);
}
} else {
if(logger.isDebugEnabled()) {
logger.debug("No auth found for API");
}
authReport.setAuthNotFound(true);
}
}
} else {
if(logger.isDebugEnabled()) {
logger.debug("No api found " + api.getId());
}
authReport.setApiNotFound(true);
}
return authReport;
}