Skip to content

Commit

Permalink
hjk
Browse files Browse the repository at this point in the history
  • Loading branch information
crivera committed Aug 15, 2016
1 parent c5e31c1 commit bf183e1
Show file tree
Hide file tree
Showing 21 changed files with 22,772 additions and 90 deletions.
18 changes: 15 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@
<optional>true</optional>
</dependency>

<!-- dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> <dependency> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId> </dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -120,6 +126,12 @@
<version>3.1</version>
</dependency>

<dependency>
<groupId>org.bitbucket.b_c</groupId>
<artifactId>jose4j</artifactId>
<version>0.4.4</version>
</dependency>

</dependencies>

<build>
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/com/config/WebHandlerInterceptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.model.User;
import com.utils.Constants;

public class WebHandlerInterceptor extends HandlerInterceptorAdapter {

/**
*
* @param env
* @param userService
*/
public WebHandlerInterceptor() {

}

/*
* (non-Javadoc)
*
* @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#
* preHandle(javax.servlet.http .HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object)
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null && (auth.getPrincipal() instanceof User)) {
User user = (User) auth.getPrincipal();
request.setAttribute(Constants.TOKEN, user.getToken());
}
return true;
}

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
super.postHandle(request, response, handler, modelAndView);
}

}
Loading

0 comments on commit bf183e1

Please sign in to comment.