Skip to content

Commit

Permalink
MOSIP-35176 Added loggers (#1573)
Browse files Browse the repository at this point in the history
Signed-off-by: kameshsr <[email protected]>
  • Loading branch information
kameshsr authored Sep 30, 2024
1 parent 3bf0cb5 commit 5bf79b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
Expand Down Expand Up @@ -31,13 +33,16 @@ public class IntentVerificationConfig implements ApplicationContextAware, Embedd
private Map<String, String> mappings = null;
private StringValueResolver resolver = null;

private static final Logger logger = LoggerFactory.getLogger(IntentVerificationConfig.class);

@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.resolver = resolver;
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
logger.debug("inside setApplicationContext");
mappings = new HashMap<>();
for (String beanName : applicationContext.getBeanDefinitionNames()) {
//Skip processing this intentVerificationConfig bean.
Expand All @@ -47,19 +52,25 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
if (!((ConfigurableApplicationContext) applicationContext).getBeanFactory().getBeanDefinition(beanName)
.isLazyInit()) {
Object obj = applicationContext.getBean(beanName);
logger.debug("bean-"+ beanName);
Class<?> objClazz = obj.getClass();
logger.debug("objClazz"+ objClazz);
if (AopUtils.isAopProxy(obj)) {

objClazz = AopUtils.getTargetClass(obj);
}

for (Method method : objClazz.getDeclaredMethods()) {
logger.debug("method name-"+method);
if (method.isAnnotationPresent(PreAuthenticateContentAndVerifyIntent.class)) {
PreAuthenticateContentAndVerifyIntent preAuthenticateContent = method
.getAnnotation(PreAuthenticateContentAndVerifyIntent.class);

String topic = preAuthenticateContent.topic();
logger.debug("topic- "+topic);

String callback = preAuthenticateContent.callback();
logger.debug("callback- "+callback);
if (topic.startsWith("${") && topic.endsWith("}")) {
topic = resolver.resolveStringValue(topic);
}
Expand All @@ -68,6 +79,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
callback = resolver.resolveStringValue(callback);
}
mappings.put(callback, topic);
logger.debug("mapping"+ mappings);
}
}
IntentVerificationFilter intentVerificationFilter = applicationContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public IntentVerificationFilter(IntentVerifier intentVerifier) {

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
logger.debug("inside doFilterInternal");
logger.debug("HttpServletRequest request- "+request);
String topic=matchCallbackURL(request.getRequestURI());
if (request.getMethod().equals(HttpMethod.GET.name()) && topic!=null) {
String topicReq = request.getParameter(WebSubClientConstants.HUB_TOPIC);
Expand Down

0 comments on commit 5bf79b8

Please sign in to comment.