Merge branch 'master' into pr/846-tim-session
This commit is contained in:
commit
0bc2aad035
@ -20,12 +20,10 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Olga on 7/20/2016.
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/mail")
|
@RequestMapping("/mail")
|
||||||
public class MailController {
|
public class MailController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public EmailServiceImpl emailService;
|
public EmailServiceImpl emailService;
|
||||||
|
|
||||||
@ -33,7 +31,6 @@ public class MailController {
|
|||||||
private String attachmentPath;
|
private String attachmentPath;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("templateSimpleMessage")
|
|
||||||
public SimpleMailMessage template;
|
public SimpleMailMessage template;
|
||||||
|
|
||||||
private static final Map<String, Map<String, String>> labels;
|
private static final Map<String, Map<String, String>> labels;
|
||||||
|
@ -248,8 +248,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<org.springframework.version>4.2.5.RELEASE</org.springframework.version>
|
<org.springframework.version>4.3.4.RELEASE</org.springframework.version>
|
||||||
<org.springframework.security.version>4.0.4.RELEASE</org.springframework.security.version>
|
<org.springframework.security.version>4.2.0.RELEASE</org.springframework.security.version>
|
||||||
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
|
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
|
||||||
<jackson.version>2.7.8</jackson.version>
|
<jackson.version>2.7.8</jackson.version>
|
||||||
|
|
||||||
|
@ -112,6 +112,11 @@
|
|||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.maxmind.geoip2</groupId>
|
||||||
|
<artifactId>geoip2</artifactId>
|
||||||
|
<version>2.8.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -146,7 +151,7 @@
|
|||||||
<version>${maven-surefire-plugin.version}</version>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<!-- <exclude>**/*ProductionTest.java</exclude> -->
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.baeldung.spring.controller;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.baeldung.spring.form.GeoIP;
|
||||||
|
import com.baeldung.spring.service.RawDBDemoGeoIPLocationService;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class GeoIPTestController {
|
||||||
|
private RawDBDemoGeoIPLocationService locationService;
|
||||||
|
public GeoIPTestController() throws IOException {
|
||||||
|
locationService
|
||||||
|
= new RawDBDemoGeoIPLocationService();
|
||||||
|
}
|
||||||
|
@RequestMapping(value="/GeoIPTest", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public GeoIP getLocation(
|
||||||
|
@RequestParam(value="ipAddress", required=true) String ipAddress) throws Exception {
|
||||||
|
|
||||||
|
return locationService.getLocation(ipAddress);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.baeldung.spring.form;
|
||||||
|
|
||||||
|
public class GeoIP {
|
||||||
|
private String ipAddress;
|
||||||
|
private String city;
|
||||||
|
private String latitude;
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
public GeoIP() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GeoIP(String ipAddress) {
|
||||||
|
this.ipAddress = ipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GeoIP(String ipAddress, String city, String latitude, String longitude) {
|
||||||
|
this.ipAddress = ipAddress;
|
||||||
|
this.city = city;
|
||||||
|
this.latitude = latitude;
|
||||||
|
this.longitude = longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIpAddress() {
|
||||||
|
return ipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIpAddress(String ipAddress) {
|
||||||
|
this.ipAddress = ipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLatitude() {
|
||||||
|
return latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitude(String latitude) {
|
||||||
|
this.latitude = latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLongitude() {
|
||||||
|
return longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitude(String longitude) {
|
||||||
|
this.longitude = longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.baeldung.spring.service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import com.baeldung.spring.form.GeoIP;
|
||||||
|
import com.maxmind.geoip2.DatabaseReader;
|
||||||
|
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||||
|
import com.maxmind.geoip2.model.CityResponse;
|
||||||
|
|
||||||
|
public class RawDBDemoGeoIPLocationService{
|
||||||
|
private DatabaseReader dbReader;
|
||||||
|
|
||||||
|
public RawDBDemoGeoIPLocationService() throws IOException {
|
||||||
|
File database = new File("C:\\Users\\Parth Joshi\\Desktop\\GeoLite2-City.mmdb\\GeoLite2-City.mmdb");
|
||||||
|
dbReader = new DatabaseReader.Builder(database).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GeoIP getLocation(String ip) throws IOException, GeoIp2Exception {
|
||||||
|
InetAddress ipAddress = InetAddress.getByName(ip);
|
||||||
|
CityResponse response = dbReader.city(ipAddress);
|
||||||
|
|
||||||
|
String cityName = response.getCity().getName();
|
||||||
|
String latitude = response.getLocation().getLatitude().toString();
|
||||||
|
String longitude = response.getLocation().getLongitude().toString();
|
||||||
|
return new GeoIP(ip, cityName, latitude, longitude);
|
||||||
|
}
|
||||||
|
}
|
84
spring-mvc-xml/src/main/webapp/GeoIpTest.jsp
Normal file
84
spring-mvc-xml/src/main/webapp/GeoIpTest.jsp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="ISO-8859-1">
|
||||||
|
<title>Geo IP Test</title>
|
||||||
|
|
||||||
|
<!--jquery dep -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready (function () {
|
||||||
|
// getting the public ip address from api and setting on text box
|
||||||
|
// ip api : https://www.ipify.org/
|
||||||
|
$.get( "https://api.ipify.org?format=json", function( data ) {
|
||||||
|
console.log(data);
|
||||||
|
$("#ip").val(data.ip) ;
|
||||||
|
});
|
||||||
|
|
||||||
|
function showLocationOnMap (location) {
|
||||||
|
var map;
|
||||||
|
|
||||||
|
map = new google.maps.Map(document.getElementById('map'), {
|
||||||
|
center: {lat: Number(location.latitude), lng: Number(location.longitude)},
|
||||||
|
zoom: 15
|
||||||
|
});
|
||||||
|
|
||||||
|
var marker = new google.maps.Marker({
|
||||||
|
position: {lat: Number(location.latitude), lng: Number(location.longitude)},
|
||||||
|
map: map,
|
||||||
|
title: "Public IP:"+location.ipAddress+" @ "+location.city
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$( "#ipForm" ).submit(function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
$.ajax({
|
||||||
|
url: "GeoIPTest",
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/x-www-form-urlencoded; charset=UTF-8", // send as JSON
|
||||||
|
data: $.param( {ipAddress : $("#ip").val()} ),
|
||||||
|
|
||||||
|
complete: function(data) {
|
||||||
|
console.log ("Request complete");
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
success: function(data) {
|
||||||
|
$("#status").html(JSON.stringify(data));
|
||||||
|
|
||||||
|
if (data.ipAddress !=null) {
|
||||||
|
console.log ("Success:"+data.ipAddress);
|
||||||
|
showLocationOnMap(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function(err) {
|
||||||
|
console.log(err);
|
||||||
|
$("#status").html("Error:"+JSON.stringify(data));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
|
||||||
|
<form id="ipForm" action="GeoIPTest" method="POST">
|
||||||
|
<input type="text" name = "ipAddress" id = "ip"/>
|
||||||
|
<input type="submit" name="submit" value="submit" />
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div id="status"></div>
|
||||||
|
|
||||||
|
<div id="map" style="height: 500px; width:100%; position:absolute"></div>
|
||||||
|
<!--AIzaSyDDr65sVtJtlbliOTAeXyZSDPvG9NROjJA -->
|
||||||
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA4vsDQWHeOrDnzS98XMXl5hgwA9raaQZ8"
|
||||||
|
async defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.baeldung.geoip;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.maxmind.geoip2.DatabaseReader;
|
||||||
|
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||||
|
import com.maxmind.geoip2.model.CityResponse;
|
||||||
|
|
||||||
|
|
||||||
|
public class GeoIpIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception {
|
||||||
|
File database = new File("C:\\Users\\Parth Joshi\\Desktop\\GeoLite2-City.mmdb\\GeoLite2-City.mmdb");
|
||||||
|
DatabaseReader dbReader = new DatabaseReader.Builder(database).build();
|
||||||
|
|
||||||
|
InetAddress ipAddress = InetAddress.getByName("202.47.112.9");
|
||||||
|
CityResponse response = dbReader.city(ipAddress);
|
||||||
|
|
||||||
|
String countryName = response.getCountry().getName();
|
||||||
|
String cityName = response.getCity().getName();
|
||||||
|
String postal = response.getPostal().getCode();
|
||||||
|
String state = response.getLeastSpecificSubdivision().getName();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-rest</artifactId>
|
<artifactId>spring-rest</artifactId>
|
||||||
@ -9,7 +10,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.3.5.RELEASE</version>
|
<version>1.4.2.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -24,6 +25,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
|
|
||||||
@ -49,7 +54,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.3.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- web -->
|
<!-- web -->
|
||||||
|
|
||||||
@ -94,7 +99,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.2.1</version>
|
<version>3.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- logging -->
|
||||||
@ -166,7 +171,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.protobuf</groupId>
|
<groupId>com.google.protobuf</groupId>
|
||||||
<artifactId>protobuf-java</artifactId>
|
<artifactId>protobuf-java</artifactId>
|
||||||
<version>2.6.1</version>
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.protobuf-java-format</groupId>
|
||||||
|
<artifactId>protobuf-java-format</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -206,6 +216,7 @@
|
|||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
@ -240,6 +251,36 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>integration</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>none</exclude>
|
||||||
|
</excludes>
|
||||||
|
<includes>
|
||||||
|
<include>**/*IntegrationTest.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>live</id>
|
<id>live</id>
|
||||||
<build>
|
<build>
|
||||||
@ -292,6 +333,7 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -299,13 +341,13 @@
|
|||||||
|
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||||
<mysql-connector-java.version>5.1.39</mysql-connector-java.version>
|
<mysql-connector-java.version>5.1.40</mysql-connector-java.version>
|
||||||
|
|
||||||
<!-- various -->
|
<!-- various -->
|
||||||
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
|
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
|
||||||
|
|
||||||
<!-- util -->
|
<!-- util -->
|
||||||
<guava.version>19.0</guava.version>
|
<guava.version>20.0</guava.version>
|
||||||
<commons-lang3.version>3.4</commons-lang3.version>
|
<commons-lang3.version>3.4</commons-lang3.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
@ -323,7 +365,7 @@
|
|||||||
<logback.version>1.1.3</logback.version>
|
<logback.version>1.1.3</logback.version>
|
||||||
|
|
||||||
<!-- Maven plugins -->
|
<!-- Maven plugins -->
|
||||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
<cargo-maven2-plugin.version>1.6.0</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.6.0</cargo-maven2-plugin.version>
|
||||||
@ -332,6 +374,7 @@
|
|||||||
<com.squareup.okhttp3.version>3.4.1</com.squareup.okhttp3.version>
|
<com.squareup.okhttp3.version>3.4.1</com.squareup.okhttp3.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<reporting>
|
<reporting>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -345,4 +388,5 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package org.baeldung.example.spring;
|
package org.baeldung.config;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
@EnableScheduling
|
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan("org.baeldung")
|
@ComponentScan("org.baeldung")
|
||||||
public class AnotherBootApp extends WebMvcConfigurerAdapter {
|
public class Application extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
SpringApplication.run(AnotherBootApp.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -17,9 +17,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Please note that main web configuration is in src/main/webapp/WEB-INF/api-servlet.xml
|
* Please note that main web configuration is in src/main/webapp/WEB-INF/api-servlet.xml
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan({ "org.baeldung.web" })
|
@ComponentScan({ "org.baeldung.web" })
|
||||||
@ -33,13 +31,14 @@ public class WebConfig extends WebMvcConfigurerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
|
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
|
||||||
messageConverters.add(createXmlHttpMessageConverter());
|
|
||||||
// messageConverters.add(new MappingJackson2HttpMessageConverter());
|
|
||||||
|
|
||||||
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
|
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
|
||||||
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
|
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
|
||||||
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
|
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
|
||||||
// messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
|
// messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
|
||||||
|
|
||||||
|
// messageConverters.add(createXmlHttpMessageConverter());
|
||||||
|
// messageConverters.add(new MappingJackson2HttpMessageConverter());
|
||||||
|
|
||||||
messageConverters.add(new ProtobufHttpMessageConverter());
|
messageConverters.add(new ProtobufHttpMessageConverter());
|
||||||
messageConverters.add(new KryoHttpMessageConverter());
|
messageConverters.add(new KryoHttpMessageConverter());
|
||||||
super.configureMessageConverters(messageConverters);
|
super.configureMessageConverters(messageConverters);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.baeldung.web.controller;
|
package org.baeldung.web.controller;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;
|
|
||||||
|
|
||||||
import org.baeldung.web.dto.Foo;
|
import org.baeldung.web.dto.Foo;
|
||||||
import org.baeldung.web.dto.FooProtos;
|
import org.baeldung.web.dto.FooProtos;
|
||||||
@ -26,7 +25,7 @@ public class FooController {
|
|||||||
@RequestMapping(method = RequestMethod.GET, value = "/foos/{id}")
|
@RequestMapping(method = RequestMethod.GET, value = "/foos/{id}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Foo findById(@PathVariable final long id) {
|
public Foo findById(@PathVariable final long id) {
|
||||||
return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4));
|
return new Foo(id, randomAlphabetic(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// API - write
|
// API - write
|
||||||
|
2
spring-rest/src/main/resources/application.properties
Normal file
2
spring-rest/src/main/resources/application.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
server.port= 8082
|
||||||
|
server.context-path=/spring-rest
|
@ -0,0 +1,5 @@
|
|||||||
|
package org.baeldung.client;
|
||||||
|
|
||||||
|
public interface Consts {
|
||||||
|
int APPLICATION_PORT = 8082;
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.baeldung.client;
|
||||||
|
|
||||||
|
import static org.baeldung.client.Consts.APPLICATION_PORT;
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.mockito.Matchers.notNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.baeldung.web.dto.Foo;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
public class RestTemplateBasicLiveTest {
|
||||||
|
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
private static final String fooResourceUrl = "http://localhost:" + APPLICATION_PORT + "/spring-rest/foos";
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void beforeTest() {
|
||||||
|
restTemplate = new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenResourceUrl_whenSendGetForRequestEntity_thenStatusOk() throws IOException {
|
||||||
|
ResponseEntity<String> response = restTemplate.getForEntity(fooResourceUrl + "/1", String.class);
|
||||||
|
|
||||||
|
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenResourceUrl_whenSendGetForRequestEntity_thenBodyCorrect() throws IOException {
|
||||||
|
ResponseEntity<String> response = restTemplate.getForEntity(fooResourceUrl + "/1", String.class);
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JsonNode root = mapper.readTree(response.getBody());
|
||||||
|
JsonNode name = root.path("name");
|
||||||
|
assertThat(name.asText(), is(notNull()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenResourceUrl_whenRetrievingResource_thenCorrect() throws IOException {
|
||||||
|
final Foo foo = restTemplate.getForObject(fooResourceUrl + "/1", Foo.class);
|
||||||
|
|
||||||
|
assertThat(foo.getName(), notNullValue());
|
||||||
|
assertThat(foo.getId(), is(1L));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.web.controller.redirect;
|
package org.baeldung.web.controller.redirect;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.flash;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.flash;
|
||||||
@ -24,7 +24,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/api-servlet.xml")
|
@ContextConfiguration("file:src/main/webapp/WEB-INF/api-servlet.xml")
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class RedirectControllerTest {
|
public class RedirectControllerIntegrationTest {
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@ -38,30 +38,30 @@ public class RedirectControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingXMLConfig_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
public void whenRedirectOnUrlWithUsingXMLConfig_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithXMLConfig")).andExpect(status().is3xxRedirection()).andExpect(view().name("RedirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithXMLConfig")))
|
mockMvc.perform(get("/redirectWithXMLConfig")).andExpect(status().is3xxRedirection()).andExpect(view().name("RedirectedUrl")).andExpect(model().attribute("attribute", equalTo("redirectWithXMLConfig")))
|
||||||
.andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithXMLConfig"));
|
.andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithXMLConfig"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingRedirectPrefix_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
public void whenRedirectOnUrlWithUsingRedirectPrefix_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithRedirectPrefix")).andExpect(status().is3xxRedirection()).andExpect(view().name("redirect:/redirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithRedirectPrefix")))
|
mockMvc.perform(get("/redirectWithRedirectPrefix")).andExpect(status().is3xxRedirection()).andExpect(view().name("redirect:/redirectedUrl")).andExpect(model().attribute("attribute", equalTo("redirectWithRedirectPrefix")))
|
||||||
.andExpect(redirectedUrl("/redirectedUrl?attribute=redirectWithRedirectPrefix"));
|
.andExpect(redirectedUrl("/redirectedUrl?attribute=redirectWithRedirectPrefix"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingRedirectAttributes_thenStatusRedirectionAndRedirectedOnUrlAndAddedAttributeToFlashScope() throws Exception {
|
public void whenRedirectOnUrlWithUsingRedirectAttributes_thenStatusRedirectionAndRedirectedOnUrlAndAddedAttributeToFlashScope() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithRedirectAttributes")).andExpect(status().is3xxRedirection()).andExpect(flash().attribute("flashAttribute", is("redirectWithRedirectAttributes")))
|
mockMvc.perform(get("/redirectWithRedirectAttributes")).andExpect(status().is3xxRedirection()).andExpect(flash().attribute("flashAttribute", equalTo("redirectWithRedirectAttributes")))
|
||||||
.andExpect(model().attribute("attribute", is("redirectWithRedirectAttributes"))).andExpect(model().attribute("flashAttribute", is(nullValue()))).andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithRedirectAttributes"));
|
.andExpect(model().attribute("attribute", equalTo("redirectWithRedirectAttributes"))).andExpect(model().attribute("flashAttribute", equalTo(nullValue()))).andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithRedirectAttributes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingRedirectView_thenStatusRedirectionAndRedirectedOnUrlAndAddedAttributeToFlashScope() throws Exception {
|
public void whenRedirectOnUrlWithUsingRedirectView_thenStatusRedirectionAndRedirectedOnUrlAndAddedAttributeToFlashScope() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithRedirectView")).andExpect(status().is3xxRedirection()).andExpect(model().attribute("attribute", is("redirectWithRedirectView"))).andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithRedirectView"));
|
mockMvc.perform(get("/redirectWithRedirectView")).andExpect(status().is3xxRedirection()).andExpect(model().attribute("attribute", equalTo("redirectWithRedirectView"))).andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithRedirectView"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingForwardPrefix_thenStatusOkAndForwardedOnUrl() throws Exception {
|
public void whenRedirectOnUrlWithUsingForwardPrefix_thenStatusOkAndForwardedOnUrl() throws Exception {
|
||||||
mockMvc.perform(get("/forwardWithForwardPrefix")).andExpect(status().isOk()).andExpect(view().name("forward:/redirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithForwardPrefix"))).andExpect(forwardedUrl("/redirectedUrl"));
|
mockMvc.perform(get("/forwardWithForwardPrefix")).andExpect(status().isOk()).andExpect(view().name("forward:/redirectedUrl")).andExpect(model().attribute("attribute", equalTo("redirectWithForwardPrefix"))).andExpect(forwardedUrl("/redirectedUrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = WebConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class ExampleControllerTest {
|
public class ExampleControllerIntegrationTest {
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
19
spring-security-rest-full/.springBeans
Normal file
19
spring-security-rest-full/.springBeans
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beansProjectDescription>
|
||||||
|
<version>1</version>
|
||||||
|
<pluginVersion><![CDATA[3.8.2.201610040608-RELEASE]]></pluginVersion>
|
||||||
|
<configSuffixes>
|
||||||
|
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||||
|
</configSuffixes>
|
||||||
|
<enableImports><![CDATA[false]]></enableImports>
|
||||||
|
<configs>
|
||||||
|
<config>java:org.baeldung.security.spring.SecurityWithoutCsrfConfig</config>
|
||||||
|
</configs>
|
||||||
|
<autoconfigs>
|
||||||
|
<config>src/main/webapp/WEB-INF/api-servlet.xml</config>
|
||||||
|
<config>java:org.baeldung.spring.Application</config>
|
||||||
|
<config>java:org.baeldung.security.spring.SecurityWithCsrfConfig</config>
|
||||||
|
</autoconfigs>
|
||||||
|
<configSets>
|
||||||
|
</configSets>
|
||||||
|
</beansProjectDescription>
|
@ -10,7 +10,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.3.8.RELEASE</version>
|
<version>1.4.2.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -109,14 +109,12 @@
|
|||||||
<!-- Querydsl -->
|
<!-- Querydsl -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysema.querydsl</groupId>
|
<groupId>com.querydsl</groupId>
|
||||||
<artifactId>querydsl-apt</artifactId>
|
<artifactId>querydsl-apt</artifactId>
|
||||||
<version>${querydsl.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysema.querydsl</groupId>
|
<groupId>com.querydsl</groupId>
|
||||||
<artifactId>querydsl-jpa</artifactId>
|
<artifactId>querydsl-jpa</artifactId>
|
||||||
<version>${querydsl.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Rsql -->
|
<!-- Rsql -->
|
||||||
@ -161,7 +159,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xml-apis</groupId>
|
<groupId>xml-apis</groupId>
|
||||||
<artifactId>xml-apis</artifactId>
|
<artifactId>xml-apis</artifactId>
|
||||||
<version>${xml-apis.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javassist</groupId>
|
<groupId>org.javassist</groupId>
|
||||||
@ -358,7 +355,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>target/generated-sources/java</outputDirectory>
|
<outputDirectory>target/generated-sources/java</outputDirectory>
|
||||||
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
|
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@ -467,16 +464,13 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<org.springframework.version>4.2.5.RELEASE</org.springframework.version>
|
|
||||||
<org.springframework.security.version>4.0.4.RELEASE</org.springframework.security.version>
|
|
||||||
|
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
<mysql-connector-java.version>5.1.40</mysql-connector-java.version>
|
||||||
<spring-data-jpa.version>1.8.2.RELEASE</spring-data-jpa.version>
|
|
||||||
|
|
||||||
<rsql.version>2.0.0</rsql.version>
|
<rsql.version>2.0.0</rsql.version>
|
||||||
<querydsl.version>3.6.2</querydsl.version>
|
<querydsl.version>4.1.4</querydsl.version>
|
||||||
|
|
||||||
<!-- marshalling -->
|
<!-- marshalling -->
|
||||||
<jackson.version>2.7.8</jackson.version>
|
<jackson.version>2.7.8</jackson.version>
|
||||||
@ -505,7 +499,7 @@
|
|||||||
<rest-assured.version>2.9.0</rest-assured.version>
|
<rest-assured.version>2.9.0</rest-assured.version>
|
||||||
|
|
||||||
<!-- Maven plugins -->
|
<!-- Maven plugins -->
|
||||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||||
|
@ -3,10 +3,10 @@ package org.baeldung.persistence.dao;
|
|||||||
import org.baeldung.persistence.model.MyUser;
|
import org.baeldung.persistence.model.MyUser;
|
||||||
import org.baeldung.web.util.SearchCriteria;
|
import org.baeldung.web.util.SearchCriteria;
|
||||||
|
|
||||||
import com.mysema.query.types.expr.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
import com.mysema.query.types.path.NumberPath;
|
import com.querydsl.core.types.dsl.NumberPath;
|
||||||
import com.mysema.query.types.path.PathBuilder;
|
import com.querydsl.core.types.dsl.PathBuilder;
|
||||||
import com.mysema.query.types.path.StringPath;
|
import com.querydsl.core.types.dsl.StringPath;
|
||||||
|
|
||||||
public class MyUserPredicate {
|
public class MyUserPredicate {
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.baeldung.web.util.SearchCriteria;
|
import org.baeldung.web.util.SearchCriteria;
|
||||||
|
|
||||||
import com.mysema.query.types.expr.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
|
||||||
public final class MyUserPredicatesBuilder {
|
public final class MyUserPredicatesBuilder {
|
||||||
private final List<SearchCriteria> params;
|
private final List<SearchCriteria> params;
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
|||||||
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
|
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
|
||||||
import org.springframework.data.querydsl.binding.QuerydslBindings;
|
import org.springframework.data.querydsl.binding.QuerydslBindings;
|
||||||
|
|
||||||
import com.mysema.query.types.path.StringPath;
|
import com.querydsl.core.types.dsl.StringPath;
|
||||||
|
|
||||||
public interface MyUserRepository extends JpaRepository<MyUser, Long>, QueryDslPredicateExecutor<MyUser>, QuerydslBinderCustomizer<QMyUser> {
|
public interface MyUserRepository extends JpaRepository<MyUser, Long>, QueryDslPredicateExecutor<MyUser>, QuerydslBinderCustomizer<QMyUser> {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.spring;
|
package org.baeldung.security.spring;
|
||||||
|
|
||||||
import org.baeldung.web.error.CustomAccessDeniedHandler;
|
import org.baeldung.web.error.CustomAccessDeniedHandler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
@ -29,8 +29,8 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
|||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.mysema.query.types.Predicate;
|
import com.querydsl.core.types.Predicate;
|
||||||
import com.mysema.query.types.expr.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
|
||||||
import cz.jirutka.rsql.parser.RSQLParser;
|
import cz.jirutka.rsql.parser.RSQLParser;
|
||||||
import cz.jirutka.rsql.parser.ast.Node;
|
import cz.jirutka.rsql.parser.ast.Node;
|
||||||
|
@ -4,8 +4,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import org.baeldung.security.spring.SecurityWithoutCsrfConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import org.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.SecurityWithoutCsrfConfig;
|
|
||||||
import org.baeldung.spring.WebConfig;
|
import org.baeldung.spring.WebConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -4,6 +4,7 @@ import static org.springframework.security.test.web.servlet.request.SecurityMock
|
|||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import org.baeldung.security.spring.SecurityWithCsrfConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import org.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.WebConfig;
|
import org.baeldung.spring.WebConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.security.csrf;
|
package org.baeldung.security.spring;
|
||||||
|
|
||||||
import org.baeldung.web.error.CustomAccessDeniedHandler;
|
import org.baeldung.web.error.CustomAccessDeniedHandler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
@ -3,8 +3,8 @@ package org.baeldung.web.interceptor;
|
|||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import org.baeldung.security.spring.SecurityWithoutCsrfConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import org.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.SecurityWithoutCsrfConfig;
|
|
||||||
import org.baeldung.spring.WebConfig;
|
import org.baeldung.spring.WebConfig;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -5,8 +5,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.baeldung.security.spring.SecurityWithoutCsrfConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import org.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.SecurityWithoutCsrfConfig;
|
|
||||||
import org.baeldung.spring.WebConfig;
|
import org.baeldung.spring.WebConfig;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.baeldung.web.interceptor;
|
package org.baeldung.web.interceptor;
|
||||||
|
|
||||||
|
import org.baeldung.security.spring.SecurityWithoutCsrfConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import org.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.SecurityWithoutCsrfConfig;
|
|
||||||
import org.baeldung.spring.WebConfig;
|
import org.baeldung.spring.WebConfig;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user