Skip to content

Commit 52b29e8

Browse files
authored
Merge pull request #3 from skumar3006/develop
Develop
2 parents 1a20922 + e8ad503 commit 52b29e8

File tree

9 files changed

+173
-9
lines changed

9 files changed

+173
-9
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"info": {
3+
"_postman_id": "2b4658ae-097a-49a8-b1c9-25fbb587278e",
4+
"name": "auth_sandeep",
5+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6+
},
7+
"item": [
8+
{
9+
"name": "get token",
10+
"request": {
11+
"auth": {
12+
"type": "basic",
13+
"basic": [
14+
{
15+
"key": "password",
16+
"value": "sandeep.kumar",
17+
"type": "string"
18+
},
19+
{
20+
"key": "username",
21+
"value": "sandeep.kumar@pepcus.com",
22+
"type": "string"
23+
}
24+
]
25+
},
26+
"method": "POST",
27+
"header": [
28+
{
29+
"key": "Accept",
30+
"value": "application/json",
31+
"type": "text"
32+
},
33+
{
34+
"key": "Content-Type",
35+
"value": "application/json",
36+
"type": "text"
37+
}
38+
],
39+
"body": {
40+
"mode": "urlencoded",
41+
"urlencoded": [
42+
{
43+
"key": "grant_type",
44+
"value": "password",
45+
"type": "text"
46+
},
47+
{
48+
"key": "username",
49+
"value": "sandeep",
50+
"type": "text"
51+
},
52+
{
53+
"key": "password",
54+
"value": "sandeep123",
55+
"type": "text"
56+
}
57+
]
58+
},
59+
"url": {
60+
"raw": "localhost:8080/oauth/token",
61+
"host": [
62+
"localhost"
63+
],
64+
"port": "8080",
65+
"path": [
66+
"oauth",
67+
"token"
68+
]
69+
}
70+
},
71+
"response": []
72+
},
73+
{
74+
"name": "get api",
75+
"protocolProfileBehavior": {
76+
"disableBodyPruning": true
77+
},
78+
"request": {
79+
"auth": {
80+
"type": "noauth"
81+
},
82+
"method": "GET",
83+
"header": [
84+
{
85+
"key": "Accept",
86+
"value": "application/json",
87+
"type": "text"
88+
},
89+
{
90+
"key": "Content-Type",
91+
"value": "application/json",
92+
"type": "text"
93+
},
94+
{
95+
"key": "Authorization",
96+
"value": "bearer 608e6937-04cf-41bc-b335-68e892761864",
97+
"type": "text"
98+
}
99+
],
100+
"body": {
101+
"mode": "urlencoded",
102+
"urlencoded": []
103+
},
104+
"url": {
105+
"raw": "localhost:8080/owners",
106+
"host": [
107+
"localhost"
108+
],
109+
"port": "8080",
110+
"path": [
111+
"owners"
112+
]
113+
}
114+
},
115+
"response": []
116+
}
117+
],
118+
"protocolProfileBehavior": {}
119+
}

data/database

11.2 KB
Binary file not shown.

pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

@@ -68,13 +69,28 @@
6869
<dependency>
6970
<groupId>org.springframework.security.oauth</groupId>
7071
<artifactId>spring-security-oauth2</artifactId>
71-
<version>2.3.3.RELEASE</version>
72+
<version>2.3.5.RELEASE</version>
7273
</dependency>
74+
7375
<dependency>
7476
<groupId>org.modelmapper</groupId>
7577
<artifactId>modelmapper</artifactId>
7678
<version>2.3.5</version>
7779
</dependency>
7880
</dependencies>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-site-plugin</artifactId>
86+
<version>3.7.1</version>
87+
</plugin>
88+
<plugin>
89+
<groupId>org.apache.maven.plugins</groupId>
90+
<artifactId>maven-project-info-reports-plugin</artifactId>
91+
<version>3.0.0</version>
92+
</plugin>
93+
</plugins>
7994

95+
</build>
8096
</project>

src/main/java/sandeep/demo/controller/OwnerController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,10 @@ public HttpStatus deleteById(@PathVariable Integer ownerId) {
5353
return HttpStatus.ACCEPTED;
5454
}
5555

56+
@GetMapping(value = "/name/{firstName}")
57+
public List<OwnerBO> byExample(@PathVariable String firstName) {
58+
List<OwnerBO> owners = ownerManager.getByExample(firstName);
59+
return owners;
60+
}
5661

5762
}

src/main/java/sandeep/demo/manager/OwnerManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
import java.util.Optional;
66

77
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.data.domain.Example;
89
import org.springframework.stereotype.Component;
910

1011
import sandeep.demo.entity.Owner;
12+
import sandeep.demo.entity.data.res.Person;
1113
import sandeep.demo.model.ModelEntityMapper;
1214
import sandeep.demo.model.OwnerBO;
1315
import sandeep.demo.repository.OwnerRepository;
@@ -45,5 +47,21 @@ public OwnerBO getById(Integer ownerId) {
4547
public void deleteById(Integer ownerId) {
4648
ownerRepository.deleteById(ownerId);
4749
}
50+
51+
public List<OwnerBO> getByExample(String name){
52+
53+
54+
Owner owner = new Owner();
55+
owner.setFirstName(name);
56+
Example<Owner> example = Example.of(owner);
57+
List<Owner> results = ownerRepository.findAll(example);
58+
results.forEach(action-> {
59+
System.out.println("action "+action.getId());
60+
});
61+
List<OwnerBO> list = new ArrayList<>();
62+
results.forEach(o -> list.add(ModelEntityMapper.convertToBO(o)));
63+
return list;
64+
65+
}
4866

4967
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package sandeep.demo.repository;
22

3+
import org.springframework.data.jpa.repository.JpaRepository;
34
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
4-
import org.springframework.data.repository.CrudRepository;
55

66
import sandeep.demo.entity.Owner;
77

8-
public interface OwnerRepository extends CrudRepository<Owner, Integer>, JpaSpecificationExecutor<Owner>{
8+
public interface OwnerRepository extends JpaRepository<Owner, Integer>, JpaSpecificationExecutor<Owner>{
99

1010
}

src/main/java/sandeep/demo/spring/security/AuthorizationServerConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.springframework.context.annotation.Bean;
66
import org.springframework.context.annotation.Configuration;
77
import org.springframework.security.authentication.AuthenticationManager;
8-
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
98
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
109
import org.springframework.security.crypto.password.PasswordEncoder;
1110
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
@@ -41,10 +40,10 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
4140
@Override
4241
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
4342

44-
clients.inMemory().withClient("sandeep")
43+
clients.inMemory().withClient("sandeep.kumar@pepcus.com")
4544
.authorizedGrantTypes("password", "authorization_code", "refresh_token", "implicit")
46-
.authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT").scopes("read", "write", "trust").secret("{noop}secret")
47-
.accessTokenValiditySeconds(120).// Access token is only valid for 2 minutes.
45+
.authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT").scopes("read", "write", "trust").secret("{noop}sandeep.kumar")
46+
.accessTokenValiditySeconds(3600).// Access token is only valid for 60 minutes.
4847
refreshTokenValiditySeconds(600);// Refresh token is only valid for 10 minutes.
4948
}
5049

src/main/resources/application.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/study
33
spring.datasource.username=postgres
44
spring.datasource.password=postgres
55
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
6+
#pring.jpa.hibernate.ddl-auto=create
67
pring.jpa.hibernate.ddl-auto=update
78
spring.datasource.driver-class-name=org.postgresql.Driver
89
flyway.baseline-on-migrate=true
910
spring.flyway.baseline-on-migrate = true
1011
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
11-
spring.data.rest.basePath=/api
12+
spring.data.rest.basePath=/api
13+
spring.banner.location=classpath:/banner/banner.txt
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/ ___| __ _ _ __ __| | ___ ___ _ __
2+
\___ \ / _` | | '_ \ / _` | / _ \ / _ \ | '_ \
3+
___) | | (_| | | | | | | (_| | | __/ | __/ | |_) |
4+
|____/ \__,_| |_| |_| \__,_| \___| \___| | .__/
5+
|_|

0 commit comments

Comments
 (0)