Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
WEBGDE-Components
web-ui
Commits
2f50318e
Commit
2f50318e
authored
Jul 05, 2023
by
Owen Ryan Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBLookup Webservice Setup
parent
74f3c81a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
208 additions
and
119 deletions
+208
-119
org.eclipse.m2e.wtp.prefs
WebGde/.settings/org.eclipse.m2e.wtp.prefs
+2
-0
org.eclipse.wst.common.project.facet.core.xml
...e/.settings/org.eclipse.wst.common.project.facet.core.xml
+12
-12
config.ini
WebGde/WebContent/WEB-INF/config/config.ini
+6
-0
config.js
WebGde/WebContent/WebGde-Widgets/config.js
+3
-3
pom.xml
WebGde/pom.xml
+2
-1
ApplicationConfig.java
.../com/svi/webgde/restservice/config/ApplicationConfig.java
+6
-1
SecuredFilter.java
...ava/com/svi/webgde/restservice/filters/SecuredFilter.java
+102
-101
GDEWebServices.java
...a/com/svi/webgde/restservice/services/GDEWebServices.java
+15
-1
DBUtil.java
...rc/main/java/com/svi/webgde/restservice/utils/DBUtil.java
+60
-0
No files found.
WebGde/.settings/org.eclipse.m2e.wtp.prefs
0 → 100644
View file @
2f50318e
eclipse.preferences.version=1
org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false
WebGde/.settings/org.eclipse.wst.common.project.facet.core.xml
View file @
2f50318e
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime
name=
"Payara Server 5 (5.202
1.1)"
/>
<fixed
facet=
"jst.web"
/>
<fixed
facet=
"java"
/>
<fixed
facet=
"wst.jsdt.web"
/>
<installed
facet=
"java"
version=
"1.8"
/>
<installed
facet=
"jst.web"
version=
"3.1"
/>
<installed
facet=
"wst.jsdt.web"
version=
"1.0"
/>
<installed
facet=
"jst.jaxrs"
version=
"2.1"
/>
<installed
facet=
"jst.jsf"
version=
"2.2"
/>
</faceted-project>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime
name=
"Payara Server 5 (5.202
2.5)"
/>
<fixed
facet=
"jst.web"
/>
<fixed
facet=
"java"
/>
<fixed
facet=
"wst.jsdt.web"
/>
<installed
facet=
"java"
version=
"1.8"
/>
<installed
facet=
"jst.web"
version=
"3.1"
/>
<installed
facet=
"wst.jsdt.web"
version=
"1.0"
/>
<installed
facet=
"jst.jaxrs"
version=
"2.1"
/>
<installed
facet=
"jst.jsf"
version=
"2.2"
/>
</faceted-project>
WebGde/WebContent/WEB-INF/config/config.ini
View file @
2f50318e
...
...
@@ -17,3 +17,9 @@ GET_ROLE_RIGHTS_URL=http://localhost:8080/gfs-explorer/svc/gfs-rest/rights/
CHECK_RIGHT_URL
=
http://localhost:8080/gfs-explorer/svc/gfs-rest/check-right/
GET_SUB_URL
=
http://localhost:8080/gfs-explorer/svc/gfs-rest/get-sub/
[MARIADB CONFIG]
JDBC_URL
=
jdbc:mariadb://localhost:3307/
DB_NAME
=
webgde_db
USERNAME
=
root
PASSWORD
=
p455w0rd
WebGde/WebContent/WebGde-Widgets/config.js
View file @
2f50318e
...
...
@@ -38,9 +38,9 @@ export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno.
export
const
ROOT_FOLDER
=
"/WebGde-Widgets"
;
//this determines if the images will be retrieved from the gfs
export
const
DOMAIN
=
"http://54.
173.201.199
:8080"
export
const
DOMAIN
=
"http://54.
211.206.117
:8080"
export
const
CONTEXTROOT
=
"gfs-explorer-ws"
export
const
GFS_URL
=
"http://54.
173.201.199
:8080"
+
"/WebGde/svc/gfs-rest"
export
const
GFS_URL
=
"http://54.
211.206.117
:8080"
+
"/WebGde/svc/gfs-rest"
export
const
FOLDER_URL
=
DOMAIN
+
"/"
+
CONTEXTROOT
+
"/svc/gfs-rest/get-folder?parentPath=/Users/"
export
const
DOWNLOAD_URL
=
DOMAIN
+
"/"
+
CONTEXTROOT
+
"/svc/gfs-rest/get-download-link"
export
const
IS_RETRIEVE_FROM_GFS
=
"N"
...
...
@@ -51,7 +51,7 @@ export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen
export
const
IS_RETRIEVE_FROM_BPO
=
"Y"
// export const BPO_URL = "http://35.171.20.94:8080/bpo-sqa/"
// export const CURRENT_NODE = "Web GDE"
export
const
BPO_URL
=
"http://54.
173.201.199
:8080/bpo/"
export
const
BPO_URL
=
"http://54.
211.206.117
:8080/bpo/"
export
const
CURRENT_NODE
=
"Web_GDE_DEV"
export
const
ENCODING_PASS
=
"PASS1"
export
const
NEXT_NODE
=
"Complete"
...
...
WebGde/pom.xml
View file @
2f50318e
...
...
@@ -42,10 +42,11 @@
<artifactId>
json-simple
</artifactId>
<version>
1.1.1
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>
org.mariadb.jdbc
</groupId>
<artifactId>
mariadb-java-client
</artifactId>
<version>
JDBC 4
.2
</version>
<version>
2.7
.2
</version>
</dependency>
</dependencies>
<build>
...
...
WebGde/src/main/java/com/svi/webgde/restservice/config/ApplicationConfig.java
View file @
2f50318e
...
...
@@ -22,7 +22,12 @@ public enum ApplicationConfig {
GET_SUBFOLDERS_URL
(
"GET_SUBFOLDERS_URL"
),
GET_SUBFILES_URL
(
"GET_SUBFILES_URL"
),
METRICS_DIR
(
"METRICS_DIR"
);
METRICS_DIR
(
"METRICS_DIR"
),
JDBC_URL
(
"JDBC_URL"
),
DB_NAME
(
"DB_NAME"
),
USERNAME
(
"USERNAME"
),
PASSWORD
(
"PASSWORD"
);
private
String
value
=
""
;
private
static
Properties
prop
;
...
...
WebGde/src/main/java/com/svi/webgde/restservice/filters/SecuredFilter.java
View file @
2f50318e
package
com
.
svi
.
webgde
.
restservice
.
filters
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
javax.annotation.Priority
;
import
javax.ws.rs.Priorities
;
import
javax.ws.rs.container.ContainerRequestContext
;
import
javax.ws.rs.container.ContainerRequestFilter
;
import
javax.ws.rs.core.Cookie
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.ext.Provider
;
import
org.apache.commons.lang3.StringUtils
;
import
com.svi.sso.jwt.utilities.JWTClaims
;
import
com.svi.sso.jwt.utilities.JWTUtility
;
import
com.svi.template.restservice.globals.AppConfig
;
import
com.svi.template.restservice.globals.GlobalConstants
;
@Secured
@Provider
@Priority
(
Priorities
.
AUTHENTICATION
)
public
class
SecuredFilter
implements
ContainerRequestFilter
{
private
static
final
GlobalConstants
GLOBAL_CONSTANTS
=
GlobalConstants
.
getInstance
();
@Override
public
void
filter
(
ContainerRequestContext
requestContext
)
throws
IOException
{
if
(
AppConfig
.
IS_COOKIE
.
getValue
().
equalsIgnoreCase
(
"Y"
))
{
if
(!
verifyCallerByCookie
(
requestContext
))
{
try
{
redirect
(
requestContext
);
}
catch
(
URISyntaxException
e
)
{
System
.
out
.
println
(
"SSO secured filter: "
+
e
.
getMessage
());
}
}
}
else
{
if
(!
verifyCallerByBearer
(
requestContext
))
{
try
{
redirect
(
requestContext
);
}
catch
(
URISyntaxException
e
)
{
System
.
out
.
println
(
"SSO secured filter: "
+
e
.
getMessage
());
}
}
}
}
private
boolean
verifyCallerByCookie
(
ContainerRequestContext
requestContext
)
{
Cookie
cookie
=
requestContext
.
getCookies
().
get
(
AppConfig
.
ACCESS_TOKEN
.
getValue
());
boolean
callerVerified
=
false
;
URI
uri
=
requestContext
.
getUriInfo
().
getAbsolutePath
();
if
(
cookie
==
null
)
{
callerVerified
=
false
;
}
else
{
try
{
String
token
=
cookie
.
getValue
();
JWTClaims
claims
=
JWTUtility
.
parseTokenSecure
(
token
,
AppConfig
.
ACCESS_SUBJECT
.
getValue
());
if
(
claims
==
null
)
{
callerVerified
=
false
;
}
else
{
requestContext
.
setProperty
(
GLOBAL_CONSTANTS
.
getJwtClaimsText
(),
claims
);
callerVerified
=
true
;
}
}
catch
(
Exception
e
)
{
callerVerified
=
false
;
}
}
return
callerVerified
;
}
private
boolean
verifyCallerByBearer
(
ContainerRequestContext
requestContext
)
{
String
bearer
=
requestContext
.
getHeaderString
(
GLOBAL_CONSTANTS
.
getAuthorizationHeaderText
());
boolean
validRequest
=
false
;
if
(
StringUtils
.
isNoneBlank
(
bearer
))
{
try
{
String
[]
splittedBearer
=
bearer
.
split
(
" "
);
String
token
=
splittedBearer
[
1
];
if
(
StringUtils
.
isNoneBlank
(
token
))
{
JWTClaims
claims
=
JWTUtility
.
parseTokenSecure
(
token
,
AppConfig
.
ACCESS_SUBJECT
.
getValue
());
if
(
claims
!=
null
)
{
requestContext
.
setProperty
(
GLOBAL_CONSTANTS
.
getJwtClaimsText
(),
claims
);
validRequest
=
true
;
}
}
}
catch
(
Exception
e
)
{
}
}
return
validRequest
;
}
private
void
redirect
(
ContainerRequestContext
requestContext
)
throws
URISyntaxException
{
requestContext
.
abortWith
(
Response
.
serverError
().
entity
(
GLOBAL_CONSTANTS
.
getForbiddenText
()).
build
());
}
}
package
com
.
svi
.
webgde
.
restservice
.
filters
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
javax.annotation.Priority
;
import
javax.ws.rs.Priorities
;
import
javax.ws.rs.container.ContainerRequestContext
;
import
javax.ws.rs.container.ContainerRequestFilter
;
import
javax.ws.rs.core.Cookie
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.ext.Provider
;
import
org.apache.commons.lang3.StringUtils
;
import
com.svi.sso.jwt.utilities.JWTClaims
;
import
com.svi.sso.jwt.utilities.JWTUtility
;
import
com.svi.template.restservice.globals.AppConfig
;
import
com.svi.template.restservice.globals.GlobalConstants
;
@Secured
@Provider
@Priority
(
Priorities
.
AUTHENTICATION
)
public
class
SecuredFilter
implements
ContainerRequestFilter
{
private
static
final
GlobalConstants
GLOBAL_CONSTANTS
=
GlobalConstants
.
getInstance
();
@Override
public
void
filter
(
ContainerRequestContext
requestContext
)
throws
IOException
{
if
(
AppConfig
.
IS_COOKIE
.
getValue
().
equalsIgnoreCase
(
"Y"
))
{
if
(!
verifyCallerByCookie
(
requestContext
))
{
try
{
redirect
(
requestContext
);
}
catch
(
URISyntaxException
e
)
{
System
.
out
.
println
(
"SSO secured filter: "
+
e
.
getMessage
());
}
}
}
else
{
if
(!
verifyCallerByBearer
(
requestContext
))
{
try
{
redirect
(
requestContext
);
}
catch
(
URISyntaxException
e
)
{
System
.
out
.
println
(
"SSO secured filter: "
+
e
.
getMessage
());
}
}
}
}
private
boolean
verifyCallerByCookie
(
ContainerRequestContext
requestContext
)
{
Cookie
cookie
=
requestContext
.
getCookies
().
get
(
AppConfig
.
ACCESS_TOKEN
.
getValue
());
boolean
callerVerified
=
false
;
URI
uri
=
requestContext
.
getUriInfo
().
getAbsolutePath
();
if
(
cookie
==
null
)
{
callerVerified
=
false
;
}
else
{
try
{
String
token
=
cookie
.
getValue
();
JWTClaims
claims
=
JWTUtility
.
parseTokenSecure
(
token
,
AppConfig
.
ACCESS_SUBJECT
.
getValue
());
if
(
claims
==
null
)
{
callerVerified
=
false
;
}
else
{
requestContext
.
setProperty
(
GLOBAL_CONSTANTS
.
getJwtClaimsText
(),
claims
);
callerVerified
=
true
;
}
}
catch
(
Exception
e
)
{
callerVerified
=
false
;
}
}
return
callerVerified
;
}
private
boolean
verifyCallerByBearer
(
ContainerRequestContext
requestContext
)
{
String
bearer
=
requestContext
.
getHeaderString
(
GLOBAL_CONSTANTS
.
getAuthorizationHeaderText
());
boolean
validRequest
=
false
;
if
(
StringUtils
.
isNoneBlank
(
bearer
))
{
try
{
String
[]
splittedBearer
=
bearer
.
split
(
" "
);
String
token
=
splittedBearer
[
1
];
if
(
StringUtils
.
isNoneBlank
(
token
))
{
JWTClaims
claims
=
JWTUtility
.
parseTokenSecure
(
token
,
AppConfig
.
ACCESS_SUBJECT
.
getValue
());
if
(
claims
!=
null
)
{
requestContext
.
setProperty
(
GLOBAL_CONSTANTS
.
getJwtClaimsText
(),
claims
);
validRequest
=
true
;
}
}
}
catch
(
Exception
e
)
{
}
}
return
validRequest
;
}
private
void
redirect
(
ContainerRequestContext
requestContext
)
throws
URISyntaxException
{
requestContext
.
abortWith
(
Response
.
serverError
().
entity
(
GLOBAL_CONSTANTS
.
getForbiddenText
()).
build
());
}
}
\ No newline at end of file
WebGde/src/main/java/com/svi/webgde/restservice/services/GDEWebServices.java
View file @
2f50318e
...
...
@@ -23,12 +23,13 @@ import javax.ws.rs.core.Response;
import
javax.ws.rs.core.Response.ResponseBuilder
;
import
javax.ws.rs.core.StreamingOutput
;
import
org.json.JSONObject
;
import
org.json.
simple.
JSONObject
;
import
com.opencsv.CSVReader
;
import
com.opencsv.CSVWriter
;
import
com.svi.webgde.restservice.object.Request
;
import
com.svi.webgde.restservice.object.XMLContents
;
import
com.svi.webgde.restservice.utils.DBUtil
;
import
com.svi.webgde.restservice.utils.XMLUtil
;
@Path
(
"/gfs-rest"
)
...
...
@@ -39,6 +40,19 @@ public class GDEWebServices {
public
Response
testWebservice
()
{
return
Response
.
ok
(
"test webservice"
).
build
();
}
@POST
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_OCTET_STREAM
)
@Path
(
"/db-test"
)
public
Response
testDb
(
JsonObject
jsonObject
)
{
JSONObject
json
=
new
JSONObject
();
String
string
=
jsonObject
.
getString
(
"dbLookup"
);
json
=
DBUtil
.
dbLookup
(
string
);
return
Response
.
ok
(
json
.
toString
()).
build
();
}
@POST
@Consumes
(
MediaType
.
APPLICATION_JSON
)
...
...
WebGde/src/main/java/com/svi/webgde/restservice/utils/DBUtil.java
0 → 100644
View file @
2f50318e
package
com
.
svi
.
webgde
.
restservice
.
utils
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.json.simple.JSONArray
;
import
org.json.simple.JSONObject
;
import
com.svi.webgde.restservice.config.ApplicationConfig
;
public
class
DBUtil
{
public
static
JSONObject
dbLookup
(
String
dbLookup
)
{
try
{
Class
.
forName
(
"org.mariadb.jdbc.Driver"
);
}
catch
(
ClassNotFoundException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
}
String
jdbcURL
=
ApplicationConfig
.
JDBC_URL
.
value
()
+
ApplicationConfig
.
DB_NAME
.
value
();
String
username
=
ApplicationConfig
.
USERNAME
.
value
();
String
password
=
ApplicationConfig
.
PASSWORD
.
value
();
System
.
out
.
println
(
"url:"
+
jdbcURL
);
String
tableName
=
dbLookup
.
substring
(
0
,
dbLookup
.
indexOf
(
"~"
));
try
(
Connection
connection
=
DriverManager
.
getConnection
(
jdbcURL
,
username
,
password
))
{
String
query
=
"SELECT * FROM "
+
tableName
;
Statement
statement
=
connection
.
createStatement
();
ResultSet
resultSet
=
statement
.
executeQuery
(
query
);
JSONObject
jsonObject
=
new
JSONObject
();
JSONArray
jsonArray
=
new
JSONArray
();
ResultSetMetaData
metaData
=
resultSet
.
getMetaData
();
int
columnCount
=
metaData
.
getColumnCount
();
while
(
resultSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
columnCount
;
i
++)
{
String
columnName
=
metaData
.
getColumnName
(
i
);
String
columnValue
=
resultSet
.
getString
(
i
);
jsonArray
.
add
(
columnValue
);
}
}
jsonObject
.
put
(
"tableData"
,
jsonArray
);
return
jsonObject
;
}
catch
(
SQLException
e
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"error"
,
"500"
);
e
.
printStackTrace
();
return
jsonObject
;
}
}
}
\ No newline at end of file
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