Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sap-service
Project
Project
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
曲欣亮
sap-service
Commits
9f588e72
Commit
9f588e72
authored
Aug 15, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
02b6810c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
15 deletions
+90
-15
SAPServiceFactory.java
src/main/java/com/egolm/sso/clients/SAPServiceFactory.java
+83
-3
SI004INVENTORYSyncOutServiceTask.java
...TORY_SyncOutService/SI004INVENTORYSyncOutServiceTask.java
+1
-3
SI009SOCREATIONAsynOutServiceTask.java
...ION_AsynOutService/SI009SOCREATIONAsynOutServiceTask.java
+1
-3
SI011ACTUALSALESSyncOutServiceTask.java
...ES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
+1
-3
application.yml
src/main/resources/application.yml
+4
-3
No files found.
src/main/java/com/egolm/sso/clients/SAPServiceFactory.java
View file @
9f588e72
package
com
.
egolm
.
sso
.
clients
;
package
com
.
egolm
.
sso
.
clients
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.security.KeyStore
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.net.ssl.KeyManager
;
import
javax.net.ssl.KeyManagerFactory
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.TrustManagerFactory
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.CallbackHandler
;
import
javax.security.auth.callback.CallbackHandler
;
import
javax.xml.namespace.QName
;
import
javax.xml.namespace.QName
;
...
@@ -13,7 +20,10 @@ import javax.xml.ws.Service;
...
@@ -13,7 +20,10 @@ import javax.xml.ws.Service;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.cxf.configuration.jsse.TLSClientParameters
;
import
org.apache.cxf.endpoint.Client
;
import
org.apache.cxf.frontend.ClientProxy
;
import
org.apache.cxf.frontend.ClientProxy
;
import
org.apache.cxf.transport.http.HTTPConduit
;
import
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor
;
import
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor
;
import
org.apache.ws.security.handler.WSHandlerConstants
;
import
org.apache.ws.security.handler.WSHandlerConstants
;
import
org.apache.wss4j.common.ext.WSPasswordCallback
;
import
org.apache.wss4j.common.ext.WSPasswordCallback
;
...
@@ -25,23 +35,37 @@ import org.springframework.stereotype.Component;
...
@@ -25,23 +35,37 @@ import org.springframework.stereotype.Component;
public
class
SAPServiceFactory
{
public
class
SAPServiceFactory
{
Log
logger
=
LogFactory
.
getLog
(
SAPServiceFactory
.
class
);
Log
logger
=
LogFactory
.
getLog
(
SAPServiceFactory
.
class
);
@Value
(
"${schneider.username}"
)
@Value
(
"${schneider.username}"
)
private
String
username
;
private
String
username
;
@Value
(
"${schneider.password}"
)
@Value
(
"${schneider.password}"
)
private
String
password
;
private
String
password
;
@Value
(
"CLIENT_KEYSTORE.FILEPATH"
)
private
String
keyStoreFile
;
@Value
(
"CLIENT_KEYSTORE.PASSWORD"
)
private
String
keyStorePassword
;
public
<
T
>
T
create
(
Class
<
T
>
requiredType
,
URL
wsdlLocation
,
QName
serviceQName
)
{
public
<
T
>
T
create
(
Class
<
T
>
requiredType
,
URL
wsdlLocation
,
QName
serviceQName
)
{
assert
requiredType
!=
null
:
"WebService requiredType cannot be null"
;
assert
requiredType
!=
null
:
"WebService requiredType cannot be null"
;
assert
wsdlLocation
!=
null
:
"WebService wsdlLocation cannot be null"
;
assert
wsdlLocation
!=
null
:
"WebService wsdlLocation cannot be null"
;
assert
serviceQName
!=
null
:
"WebService serviceQName cannot be null"
;
assert
serviceQName
!=
null
:
"WebService serviceQName cannot be null"
;
Service
dyService
=
Service
.
create
(
wsdlLocation
,
serviceQName
);
Service
dyService
=
Service
.
create
(
wsdlLocation
,
serviceQName
);
T
service
=
dyService
.
getPort
(
requiredType
);
T
service
=
dyService
.
getPort
(
requiredType
);
ClientProxy
.
getClient
(
service
).
getOutInterceptors
().
add
(
getWSS4JOutInterceptor
());
Client
client
=
ClientProxy
.
getClient
(
service
);
client
.
getOutInterceptors
().
add
(
this
.
getWSS4JOutInterceptor
());
HTTPConduit
httpConduit
=
(
HTTPConduit
)
client
.
getConduit
();
TLSClientParameters
tlsParams
=
httpConduit
.
getTlsClientParameters
();
tlsParams
=
tlsParams
==
null
?
new
TLSClientParameters
()
:
tlsParams
;
tlsParams
.
setSecureSocketProtocol
(
"SSL"
);
tlsParams
.
setKeyManagers
(
getKeyManagers
());
tlsParams
.
setTrustManagers
(
getTrustManagers
());
httpConduit
.
setTlsClientParameters
(
tlsParams
);
return
service
;
return
service
;
}
}
private
static
String
absolutePath
=
null
;
private
static
String
absolutePath
=
null
;
public
URL
getAbsoluteURL
(
String
WSDLPATH
)
throws
MalformedURLException
{
public
URL
getAbsoluteURL
(
String
WSDLPATH
)
throws
MalformedURLException
{
...
@@ -78,5 +102,61 @@ public class SAPServiceFactory {
...
@@ -78,5 +102,61 @@ public class SAPServiceFactory {
public
enum
PasswordType
{
public
enum
PasswordType
{
PasswordText
,
PasswordNone
,
PasswordDigest
PasswordText
,
PasswordNone
,
PasswordDigest
}
}
private
static
TrustManager
[]
trustManagers
=
null
;
private
static
KeyManager
[]
keyManagers
=
null
;
private
TrustManager
[]
getTrustManagers
()
{
if
(
trustManagers
==
null
)
{
FileInputStream
fis
=
null
;
try
{
String
alg
=
TrustManagerFactory
.
getDefaultAlgorithm
();
TrustManagerFactory
factory
=
TrustManagerFactory
.
getInstance
(
alg
);
fis
=
new
FileInputStream
(
new
File
(
keyStoreFile
));
KeyStore
ks
=
KeyStore
.
getInstance
(
"JKS"
);
ks
.
load
(
fis
,
keyStorePassword
.
toCharArray
());
fis
.
close
();
factory
.
init
(
ks
);
trustManagers
=
factory
.
getTrustManagers
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Load TrustManager fail ["
+
keyStoreFile
+
"]"
,
e
);
}
finally
{
if
(
fis
!=
null
)
{
try
{
fis
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
keyStoreFile
,
e
);
}
}
}
}
return
trustManagers
;
}
private
KeyManager
[]
getKeyManagers
()
{
if
(
keyManagers
==
null
)
{
FileInputStream
fis
=
null
;
try
{
fis
=
new
FileInputStream
(
new
File
(
keyStoreFile
));
String
alg
=
KeyManagerFactory
.
getDefaultAlgorithm
();
KeyManagerFactory
factory
=
KeyManagerFactory
.
getInstance
(
alg
);
KeyStore
ks
=
KeyStore
.
getInstance
(
"JKS"
);
ks
.
load
(
fis
,
keyStorePassword
.
toCharArray
());
factory
.
init
(
ks
,
keyStorePassword
.
toCharArray
());
keyManagers
=
factory
.
getKeyManagers
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Load KeyManager fail ["
+
keyStoreFile
+
"]"
,
e
);
}
finally
{
if
(
fis
!=
null
)
{
try
{
fis
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
keyStoreFile
,
e
);
}
}
}
}
return
keyManagers
;
}
}
}
src/main/java/com/egolm/sso/clients/SI_004_INVENTORY_SyncOutService/SI004INVENTORYSyncOutServiceTask.java
View file @
9f588e72
...
@@ -9,7 +9,6 @@ import java.util.Map;
...
@@ -9,7 +9,6 @@ import java.util.Map;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.cxf.frontend.ClientProxy
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
...
@@ -66,8 +65,7 @@ public class SI004INVENTORYSyncOutServiceTask {
...
@@ -66,8 +65,7 @@ public class SI004INVENTORYSyncOutServiceTask {
}
}
public
void
runTask
()
throws
MalformedURLException
{
public
void
runTask
()
throws
MalformedURLException
{
SI004INVENTORYSyncOut
service
=
new
SI004INVENTORYSyncOutService
(
factory
.
getAbsoluteURL
(
WSDLPATH
)).
getPort
(
SI004INVENTORYSyncOut
.
class
);
SI004INVENTORYSyncOut
service
=
factory
.
create
(
SI004INVENTORYSyncOut
.
class
,
factory
.
getAbsoluteURL
(
WSDLPATH
),
SI004INVENTORYSyncOutService
.
SERVICE
);
ClientProxy
.
getClient
(
service
).
getOutInterceptors
().
add
(
factory
.
getWSS4JOutInterceptor
());
this
.
sendData
(
service
);
this
.
sendData
(
service
);
}
}
...
...
src/main/java/com/egolm/sso/clients/SI_009_SO_CREATION_AsynOutService/SI009SOCREATIONAsynOutServiceTask.java
View file @
9f588e72
...
@@ -9,7 +9,6 @@ import java.util.Map;
...
@@ -9,7 +9,6 @@ import java.util.Map;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.cxf.frontend.ClientProxy
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
...
@@ -65,8 +64,7 @@ public class SI009SOCREATIONAsynOutServiceTask {
...
@@ -65,8 +64,7 @@ public class SI009SOCREATIONAsynOutServiceTask {
}
}
public
void
runTask
()
throws
MalformedURLException
{
public
void
runTask
()
throws
MalformedURLException
{
SI009SOCREATIONAsynOut
service
=
new
SI009SOCREATIONAsynOutService
(
factory
.
getAbsoluteURL
(
WSDLPATH
)).
getPort
(
SI009SOCREATIONAsynOut
.
class
);
SI009SOCREATIONAsynOut
service
=
factory
.
create
(
SI009SOCREATIONAsynOut
.
class
,
factory
.
getAbsoluteURL
(
WSDLPATH
),
SI009SOCREATIONAsynOutService
.
SERVICE
);
ClientProxy
.
getClient
(
service
).
getOutInterceptors
().
add
(
factory
.
getWSS4JOutInterceptor
());
this
.
sendData
(
service
);
this
.
sendData
(
service
);
}
}
...
...
src/main/java/com/egolm/sso/clients/SI_011_ACTUAL_SALES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
View file @
9f588e72
...
@@ -9,7 +9,6 @@ import java.util.Map;
...
@@ -9,7 +9,6 @@ import java.util.Map;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.cxf.frontend.ClientProxy
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
...
@@ -66,8 +65,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
...
@@ -66,8 +65,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
}
public
void
runTask
()
throws
MalformedURLException
{
public
void
runTask
()
throws
MalformedURLException
{
SI011ACTUALSALESSyncOut
service
=
new
SI011ACTUALSALESSyncOutService
(
factory
.
getAbsoluteURL
(
WSDLPATH
)).
getPort
(
SI011ACTUALSALESSyncOut
.
class
);
SI011ACTUALSALESSyncOut
service
=
factory
.
create
(
SI011ACTUALSALESSyncOut
.
class
,
factory
.
getAbsoluteURL
(
WSDLPATH
),
SI011ACTUALSALESSyncOutService
.
SERVICE
);
ClientProxy
.
getClient
(
service
).
getOutInterceptors
().
add
(
factory
.
getWSS4JOutInterceptor
());
this
.
sendData
(
service
);
this
.
sendData
(
service
);
}
}
...
...
src/main/resources/application.yml
View file @
9f588e72
CLIENT_KEYSTORE
:
FILEPATH
:
SSL/sap.keystore
PASSWORD
:
123456
isUsedTestController
:
true
isUsedTestController
:
true
xmlRoot
:
xml
xmlRoot
:
xml
systemId
:
system
systemId
:
system
...
@@ -34,6 +37,4 @@ spring:
...
@@ -34,6 +37,4 @@ spring:
cxf
:
cxf
:
path
:
/api/services
path
:
/api/services
servlet
:
servlet
:
load-on-startup
:
-1
load-on-startup
:
-1
logging
:
\ No newline at end of file
file
:
logs/spring.log
\ 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