Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
warehouse-management
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
warehouse-management
Commits
5c290618
Commit
5c290618
authored
May 08, 2021
by
Alex Pinto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed google validation of token
parent
f272d0f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
21 deletions
+53
-21
pom.xml
pom.xml
+6
-0
AuthenticationController.java
...oject/warehouse/controllers/AuthenticationController.java
+22
-0
WarehouseController.java
...nalproject/warehouse/controllers/WarehouseController.java
+0
-12
SessionService.java
...ascendfinalproject/warehouse/services/SessionService.java
+25
-9
No files found.
pom.xml
View file @
5c290618
...
@@ -74,6 +74,12 @@
...
@@ -74,6 +74,12 @@
<artifactId>
httpclient
</artifactId>
<artifactId>
httpclient
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
com.google.api-client
</groupId>
<artifactId>
google-api-client
</artifactId>
<version>
1.31.2
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/com/ascendfinalproject/warehouse/controllers/AuthenticationController.java
0 → 100644
View file @
5c290618
package
com
.
ascendfinalproject
.
warehouse
.
controllers
;
import
com.ascendfinalproject.warehouse.models.Session
;
import
com.ascendfinalproject.warehouse.services.SessionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
value
=
""
)
public
class
AuthenticationController
{
@Autowired
SessionService
sessionService
;
@CrossOrigin
@PostMapping
(
value
=
"/auth"
)
public
ResponseEntity
<
Session
>
authenticate
(
@RequestBody
Session
session
)
{
return
sessionService
.
authenticate
(
session
);
}
}
src/main/java/com/ascendfinalproject/warehouse/controllers/WarehouseController.java
View file @
5c290618
...
@@ -18,9 +18,6 @@ public class WarehouseController {
...
@@ -18,9 +18,6 @@ public class WarehouseController {
@Autowired
@Autowired
WarehouseOrderService
orderService
;
WarehouseOrderService
orderService
;
@Autowired
SessionService
sessionService
;
@CrossOrigin
@CrossOrigin
@GetMapping
(
value
=
"/orders"
)
@GetMapping
(
value
=
"/orders"
)
public
Flux
<
WarehouseOrder
>
getOrders
()
{
public
Flux
<
WarehouseOrder
>
getOrders
()
{
...
@@ -45,14 +42,5 @@ public class WarehouseController {
...
@@ -45,14 +42,5 @@ public class WarehouseController {
return
orderService
.
updateOrder
(
order
,
id
);
return
orderService
.
updateOrder
(
order
,
id
);
}
}
@CrossOrigin
@PostMapping
(
value
=
"/authenticate"
)
public
Session
authenticate
(
@RequestBody
Session
session
)
{
if
(
sessionService
.
tokenExists
(
session
))
{
return
session
;
}
return
sessionService
.
saveToken
(
session
);
}
}
}
src/main/java/com/ascendfinalproject/warehouse/services/SessionService.java
View file @
5c290618
package
com
.
ascendfinalproject
.
warehouse
.
services
;
package
com
.
ascendfinalproject
.
warehouse
.
services
;
import
com.ascendfinalproject.warehouse.models.Session
;
import
com.ascendfinalproject.warehouse.models.Session
;
import
com.ascendfinalproject.warehouse.repositories.SessionRepository
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.
beans.factory.annotation.Autowired
;
import
org.springframework.
http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
@Service
@Service
public
class
SessionService
{
public
class
SessionService
{
@Autowired
public
ResponseEntity
<
Session
>
authenticate
(
Session
session
)
{
SessionRepository
sessionRepository
;
int
status
=
404
;
try
{
URL
url
=
new
URL
(
"https://oauth2.googleapis.com/tokeninfo?id_token="
+
session
.
getToken
());
HttpURLConnection
con
=
(
HttpURLConnection
)
url
.
openConnection
();
con
.
setRequestMethod
(
"GET"
);
status
=
con
.
getResponseCode
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Bad Request: "
+
status
);
}
if
(
status
==
200
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
ACCEPTED
)
.
body
(
session
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
)
.
body
(
null
);
public
Session
saveToken
(
Session
session
)
{
return
sessionRepository
.
save
(
session
);
}
public
boolean
tokenExists
(
Session
session
)
{
return
sessionRepository
.
existsById
(
session
.
getToken
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment