Skip to content

Instantly share code, notes, and snippets.

@andreybleme
andreybleme / UserController.java
Created April 1, 2017 15:36
andreybleme.com | JWT com Springboot
package com.jwtme.controllers;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserController {
@RequestMapping("/users")
@andreybleme
andreybleme / return.json
Created April 1, 2017 16:22
andreybleme.com | JWT com Springboot
{"users":[{"name":"Lucas", "country":"Brazil"},{"name":"Jackie","country":"China"}]}
@andreybleme
andreybleme / WebSecurityConfig.java
Created April 1, 2017 16:42
andreybleme.com | JWT com Springboot
package com.jwtme.security;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@andreybleme
andreybleme / TokenAuthenticationService.java
Created April 1, 2017 17:01
andreybleme.com | JWT com Springboot
package com.jwtme.security;
import java.util.Collections;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@andreybleme
andreybleme / JWTLoginFilter.java
Created April 1, 2017 17:09
andreybleme.com | JWT com Springboot
package com.jwtme.security;
import java.io.IOException;
import java.util.Collections;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@andreybleme
andreybleme / JWTAuthenticationFilter.java
Created April 1, 2017 17:15
andreybleme.com | JWT com Springboot
package com.jwtme.security;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@andreybleme
andreybleme / AccountCredentials.java
Created April 1, 2017 17:30
andreybleme.com | JWT com Springboot
package com.jwtme.security;
public class AccountCredentials {
private String username;
private String password;
public String getUsername() {
return username;
}
@andreybleme
andreybleme / pom.xml
Last active April 1, 2017 18:54
andreybleme.com | JWT com Springboot
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
@andreybleme
andreybleme / Main.java
Created May 14, 2017 14:03
andreybleme.com | Avaliando desenvolvedores: a falácia das métricas
exibirProduto(1);
exibirProduto(2);
exibirProduto(3);
exibirProduto(4);
exibirProduto(5);
@andreybleme
andreybleme / ImprovedMain.java
Last active May 14, 2017 14:08
andreybleme.com | Avaliando desenvolvedores: a falácia das métricas
for (numeroDoProduto = 1; numeroDoProduto <= 5; numeroDoProduto++) {
exibirProduto(numeroDoProduto);
}