Skip to content

Commit 1740355

Browse files
SpringBootTokenAuthenticatoinHibernateExample
1 parent b8d379a commit 1740355

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3829
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>SpringBootTokenAuthenticatoinHibernateExample</groupId>
9+
<artifactId>SpringBootTokenAuthenticatoinHibernateExample</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
12+
<parent>
13+
<groupId>org.springframework.boot</groupId>
14+
<artifactId>spring-boot-starter-parent</artifactId>
15+
<version>1.3.1.RELEASE</version>
16+
</parent>
17+
18+
<organization>
19+
<name>ESpark</name>
20+
<url>http://adarshkumarsingh83.blogspot.in/</url>
21+
</organization>
22+
23+
<licenses>
24+
<license>
25+
<name>ESpark</name>
26+
<url>http://adarshkumarsingh83.blogspot.in/licenses/LICENSE-2.0.txt</url>
27+
<distribution>repo</distribution>
28+
</license>
29+
</licenses>
30+
31+
<developers>
32+
<developer>
33+
<id>adarshkumarsingh83</id>
34+
<name>Adarsh Kumar</name>
35+
<email>adarshkumarsingh83@gmail.com</email>
36+
<roles>
37+
<role>project architect</role>
38+
</roles>
39+
</developer>
40+
</developers>
41+
42+
<repositories>
43+
<repository>
44+
<id>maven2-repository.java.net</id>
45+
<name>Java.net Repository for Maven</name>
46+
<url>http://download.java.net/maven/2/</url>
47+
</repository>
48+
49+
<repository>
50+
<id>JBoss repository</id>
51+
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
52+
</repository>
53+
54+
<repository>
55+
<id>java.net</id>
56+
<url>https://maven.java.net/content/repositories/public/</url>
57+
</repository>
58+
59+
</repositories>
60+
61+
<properties>
62+
<project.name>SpringBootTokenAuthenticatoinHibernateExample</project.name>
63+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
64+
<java.version>1.7</java.version>
65+
</properties>
66+
67+
<dependencies>
68+
69+
<dependency>
70+
<groupId>org.springframework.boot</groupId>
71+
<artifactId>spring-boot-starter</artifactId>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-starter-freemarker</artifactId>
77+
</dependency>
78+
79+
<dependency>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-starter-security</artifactId>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>org.springframework.boot</groupId>
86+
<artifactId>spring-boot-starter-data-jpa</artifactId>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>mysql</groupId>
91+
<artifactId>mysql-connector-java</artifactId>
92+
<version>5.1.31</version>
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>org.apache.tomcat.embed</groupId>
97+
<artifactId>tomcat-embed-jasper</artifactId>
98+
<scope>provided</scope>
99+
</dependency>
100+
101+
<dependency>
102+
<groupId>javax.servlet</groupId>
103+
<artifactId>jstl</artifactId>
104+
</dependency>
105+
106+
<dependency>
107+
<groupId>org.springframework.boot</groupId>
108+
<artifactId>spring-boot-starter-test</artifactId>
109+
</dependency>
110+
111+
<dependency>
112+
<groupId>commons-lang</groupId>
113+
<artifactId>commons-lang</artifactId>
114+
<version>2.6</version>
115+
</dependency>
116+
117+
118+
<dependency>
119+
<groupId>joda-time</groupId>
120+
<artifactId>joda-time</artifactId>
121+
<version>2.9.1</version>
122+
</dependency>
123+
124+
<dependency>
125+
<groupId>commons-codec</groupId>
126+
<artifactId>commons-codec</artifactId>
127+
<version>1.10</version>
128+
</dependency>
129+
130+
<dependency>
131+
<groupId>net.sf.ehcache</groupId>
132+
<artifactId>ehcache-core</artifactId>
133+
<version>2.6.9</version>
134+
<exclusions>
135+
<exclusion>
136+
<artifactId>commons-logging</artifactId>
137+
<groupId>commons-logging</groupId>
138+
</exclusion>
139+
</exclusions>
140+
</dependency>
141+
142+
143+
</dependencies>
144+
145+
<build>
146+
<finalName>${project.name}</finalName>
147+
<outputDirectory>target/classes</outputDirectory>
148+
<plugins>
149+
<plugin>
150+
<artifactId>maven-compiler-plugin</artifactId>
151+
<configuration>
152+
<source>${java.version}</source>
153+
<target>${java.version}</target>
154+
<encoding>${project.build.sourceEncoding}</encoding>
155+
</configuration>
156+
</plugin>
157+
<plugin>
158+
<groupId>org.springframework.boot</groupId>
159+
<artifactId>spring-boot-maven-plugin</artifactId>
160+
</plugin>
161+
</plugins>
162+
</build>
163+
164+
165+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
mvn clean install
2+
3+
mvn spring-boot:run
4+
5+
url=> http://localhost:9090/
6+
7+
url=> http://localhost:9090/rest/authenticate/login
8+
9+
Content-Type:application/json
10+
{"username":"adarsh", "password":"adarsh"}
11+
Response:=>
12+
{
13+
"User-Name": "adarsh",
14+
"User-Password": "adarsh",
15+
"Authentication-token": "YWRhcnNoISEhMTQ1ODgwNTQyODUxNyEhIUYEkvI7jEpLVfViLgOoX6s=",
16+
"Response-Message": "LOGIN SUCCESSFUL",
17+
"Response-Status": 200
18+
}
19+
20+
------------------------------------------------------------------------------------
21+
url=> http://localhost:9090/rest/welcome
22+
Content-Type:application/json
23+
Authentication-token : YWRhcnNoISEhMTQ1ODgwNTQyODUxNyEhIUYEkvI7jEpLVfViLgOoX6s=
24+
25+
{
26+
"data": {
27+
"time": 1458915713171,
28+
"message": "welcome to the application adarkuma"
29+
},
30+
"message": "Request Process Successful"
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2015 Espark And ©Adarsh Development Services @copyright All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* - Neither the name of Espark nor the names of its
16+
* contributors may be used to endorse or promote products derived
17+
* from this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
package com.espark.adarsh;
32+
33+
import org.springframework.boot.SpringApplication;
34+
import org.springframework.boot.autoconfigure.SpringBootApplication;
35+
import org.springframework.boot.builder.SpringApplicationBuilder;
36+
import org.springframework.boot.context.web.SpringBootServletInitializer;
37+
38+
/**
39+
* @author Adarsh Kumar
40+
* @author $LastChangedBy: Adarsh Kumar$
41+
* @version $Revision: 0001 $, $Date:: 1/1/10 0:00 AM#$
42+
* @Espark @copyright all right reserve
43+
*/
44+
@SpringBootApplication
45+
public class Application extends SpringBootServletInitializer {
46+
47+
public static void main(String[] args) {
48+
SpringApplication.run(Application.class, args);
49+
}
50+
51+
@Override
52+
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
53+
return application.sources(Application.class);
54+
}
55+
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright (c) 2015 Espark And ©Adarsh Development Services @copyright All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* - Neither the name of Espark nor the names of its
16+
* contributors may be used to endorse or promote products derived
17+
* from this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
package com.espark.adarsh.bean;
33+
34+
35+
import com.fasterxml.jackson.annotation.JsonProperty;
36+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
37+
import com.fasterxml.jackson.annotation.JsonView;
38+
39+
import java.io.Serializable;
40+
41+
/**
42+
* @author Adarsh Kumar
43+
* @author $LastChangedBy: Adarsh Kumar$
44+
* @version $Revision: 0001 $, $Date:: 1/1/10 0:00 AM#$
45+
* @Espark @copyright all right reserve
46+
*/
47+
@JsonPropertyOrder({"userName", "userPassword","token","message","httpStatus"})
48+
public class ApiServerViewBean implements Serializable {
49+
50+
51+
@JsonProperty("User-Name")
52+
private String userName;
53+
54+
55+
@JsonProperty("User-Password")
56+
private String userPassword;
57+
58+
59+
@JsonProperty("Authentication-token")
60+
private String token;
61+
62+
63+
@JsonProperty("Response-Message")
64+
private String message;
65+
66+
67+
@JsonProperty("Response-Status")
68+
private Integer httpStatus;
69+
70+
public String getUserName() {
71+
return userName;
72+
}
73+
74+
public void setUserName(String userName) {
75+
this.userName = userName;
76+
}
77+
78+
public String getUserPassword() {
79+
return userPassword;
80+
}
81+
82+
public void setUserPassword(String userPassword) {
83+
this.userPassword = userPassword;
84+
}
85+
86+
public String getToken() {
87+
return token;
88+
}
89+
90+
public void setToken(String token) {
91+
this.token = token;
92+
}
93+
94+
public String getMessage() {
95+
return message;
96+
}
97+
98+
public void setMessage(String message) {
99+
this.message = message;
100+
}
101+
102+
public Integer getHttpStatus() {
103+
return httpStatus;
104+
}
105+
106+
public void setHttpStatus(Integer httpStatus) {
107+
this.httpStatus = httpStatus;
108+
}
109+
}

0 commit comments

Comments
 (0)