Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sso
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
曲欣亮
sso
Commits
17110957
Commit
17110957
authored
Jul 04, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初次提交
parents
Pipeline
#140
canceled with stages
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
570 additions
and
0 deletions
+570
-0
.gitignore
.gitignore
+6
-0
pom.xml
pom.xml
+114
-0
SSOApplication.java
src/main/java/com/egolm/sso/SSOApplication.java
+34
-0
WsConfig.java
src/main/java/com/egolm/sso/config/WsConfig.java
+70
-0
TestService.java
src/main/java/com/egolm/sso/service/TestService.java
+16
-0
XsipSdService.java
src/main/java/com/egolm/sso/service/XsipSdService.java
+51
-0
TestServiceImpl.java
...main/java/com/egolm/sso/service/impl/TestServiceImpl.java
+45
-0
XsipSdServiceImpl.java
...in/java/com/egolm/sso/service/impl/XsipSdServiceImpl.java
+47
-0
.gitignore
src/main/resources/.gitignore
+1
-0
application-dev.properties
src/main/resources/application-dev.properties
+3
-0
application-pro.properties
src/main/resources/application-pro.properties
+3
-0
application.yml
src/main/resources/application.yml
+10
-0
server.jks
src/main/resources/ca/server.jks
+0
-0
server.properties
src/main/resources/ca/server.properties
+6
-0
log4j.properties
src/main/resources/log4j.properties
+4
-0
logback.xml
src/main/resources/logback.xml
+51
-0
TestClient.java
src/test/java/sso/TestClient.java
+109
-0
No files found.
.gitignore
0 → 100644
View file @
17110957
/target/
/.settings/
/.classpath
/.project
/application.properties
\ No newline at end of file
pom.xml
0 → 100644
View file @
17110957
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.egolm
</groupId>
<artifactId>
sso
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<properties>
<start-class>
com.egolm.sso.SSOApplication
</start-class>
</properties>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.1.0.RELEASE
</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
Finchley.SR2
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-spring-boot-starter-jaxws
</artifactId>
<version>
3.3.2
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.38
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.1.17
</version>
</dependency>
<dependency>
<groupId>
org.apache.ws.security
</groupId>
<artifactId>
wss4j
</artifactId>
<version>
1.6.19
</version>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-ws-security
</artifactId>
<version>
3.3.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.santuario
</groupId>
<artifactId>
xmlsec
</artifactId>
<version>
2.1.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-transports-http
</artifactId>
<version>
3.2.2
</version>
</dependency>
<dependency>
<groupId>
javax.ws.rs
</groupId>
<artifactId>
javax.ws.rs-api
</artifactId>
<version>
2.1.1
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<mainClass>
${start-class}
</mainClass>
<layout>
ZIP
</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
src/main/java/com/egolm/sso/SSOApplication.java
0 → 100644
View file @
17110957
package
com
.
egolm
.
sso
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.context.ApplicationContext
;
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
public
class
SSOApplication
{
private
static
ApplicationContext
applicationContext
;
public
static
void
main
(
String
[]
args
)
{
applicationContext
=
SpringApplication
.
run
(
SSOApplication
.
class
,
args
);
}
public
static
ApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
public
static
Object
getBean
(
String
name
){
return
getApplicationContext
().
getBean
(
name
);
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBean
(
clazz
);
}
public
static
<
T
>
T
getBean
(
String
name
,
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBean
(
name
,
clazz
);
}
}
src/main/java/com/egolm/sso/config/WsConfig.java
0 → 100644
View file @
17110957
package
com
.
egolm
.
sso
.
config
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.CallbackHandler
;
import
javax.xml.ws.Endpoint
;
import
org.apache.cxf.Bus
;
import
org.apache.cxf.jaxws.EndpointImpl
;
import
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor
;
import
org.apache.ws.security.WSConstants
;
import
org.apache.ws.security.handler.WSHandlerConstants
;
import
org.apache.wss4j.common.ext.WSPasswordCallback
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.egolm.sso.service.XsipSdService
;
@Configuration
public
class
WsConfig
{
@Autowired
private
Bus
bus
;
@Autowired
WSS4JInInterceptor
authInterceptor
;
@Autowired
XsipSdService
xsipSdService
;
@Bean
public
Endpoint
endpoint
()
{
EndpointImpl
endpoint
=
new
EndpointImpl
(
bus
,
xsipSdService
);
endpoint
.
setInInterceptors
(
Arrays
.
asList
(
authInterceptor
));
endpoint
.
publish
(
"/xsip"
);
return
endpoint
;
}
@Value
(
"${wsUsername}"
)
private
String
wsUername
;
@Value
(
"${wsPassword}"
)
private
String
wsPassword
;
@Bean
public
WSS4JInInterceptor
getWSS4JInInterceptor
()
{
Map
<
String
,
Object
>
properties
=
new
HashMap
<
String
,
Object
>();
properties
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
properties
.
put
(
WSHandlerConstants
.
PASSWORD_TYPE
,
WSConstants
.
PW_DIGEST
);
properties
.
put
(
WSHandlerConstants
.
PW_CALLBACK_REF
,
new
CallbackHandler
()
{
public
void
handle
(
Callback
[]
callbacks
)
{
for
(
int
i
=
0
;
i
<
callbacks
.
length
;
i
++)
{
WSPasswordCallback
pc
=
(
WSPasswordCallback
)
callbacks
[
i
];
String
username
=
pc
.
getIdentifier
();
if
(
username
.
equals
(
wsUername
))
{
pc
.
setPassword
(
wsPassword
);
}
}
}
});
WSS4JInInterceptor
interceptor
=
new
WSS4JInInterceptor
(
properties
);
return
interceptor
;
}
}
src/main/java/com/egolm/sso/service/TestService.java
0 → 100644
View file @
17110957
package
com
.
egolm
.
sso
.
service
;
import
javax.jws.WebMethod
;
import
javax.jws.WebParam
;
import
javax.jws.WebService
;
@WebService
(
targetNamespace
=
"http://service.sso.egolm.com"
)
// 服务接口全路径, 指定做SEI(Service EndPoint Interface)服务端点接口
public
interface
TestService
{
@WebMethod
// 标注该方法为webservice暴露的方法,用于向外公布,它修饰的方法是webservice方法,去掉也没影响的,类似一个注释信息。
public
String
getUser
(
@WebParam
(
name
=
"userId"
)
String
userId
);
@WebMethod
public
String
getUserName
(
@WebParam
(
name
=
"userId"
)
String
userId
);
}
src/main/java/com/egolm/sso/service/XsipSdService.java
0 → 100644
View file @
17110957
package
com
.
egolm
.
sso
.
service
;
import
javax.jws.WebMethod
;
import
javax.jws.WebService
;
@WebService
(
targetNamespace
=
"http://service.sso.egolm.com"
)
public
interface
XsipSdService
{
/**
* 001
* @param xml
*/
@WebMethod
public
void
pushMaterialMaster
(
String
xml
);
/**
* 002
* @param xml
*/
@WebMethod
public
void
pushPriceList
(
String
xml
);
/**
* 005
* @param xml
*/
@WebMethod
public
void
pushProFormaInvoice
(
String
xml
);
/**
* 007
* @param xml
*/
@WebMethod
public
void
pushShippingNotfirmation
(
String
xml
);
/**
* 008
* @param xml
*/
@WebMethod
public
void
pushSoConfirmQuotation
(
String
xml
);
/**
* 009
* @param xml
*/
@WebMethod
public
void
pushSoDnDeletion
(
String
xml
);
}
src/main/java/com/egolm/sso/service/impl/TestServiceImpl.java
0 → 100644
View file @
17110957
package
com
.
egolm
.
sso
.
service
.
impl
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.jws.WebMethod
;
import
javax.jws.WebService
;
import
org.springframework.stereotype.Component
;
import
com.egolm.sso.service.TestService
;
@Component
@WebService
(
serviceName
=
"TestService"
,
// 对外发布的服务名
targetNamespace
=
"http://service.sso.egolm.com"
,
// 指定你想要的名称空间,通常使用使用包名反转
endpointInterface
=
"com.egolm.sso.service.TestService"
)
// 服务接口全路径, 指定做SEI(Service EndPoint Interface)服务端点接口
public
class
TestServiceImpl
implements
TestService
{
private
Map
<
String
,
Map
<
String
,
String
>>
userMap
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
public
TestServiceImpl
()
{
Map
<
String
,
String
>
u1
=
new
HashMap
<
String
,
String
>();
u1
.
put
(
"userId"
,
"111"
);
u1
.
put
(
"userName"
,
"Quxl"
);
userMap
.
put
(
"111"
,
u1
);
Map
<
String
,
String
>
u2
=
new
HashMap
<
String
,
String
>();
u1
.
put
(
"userId"
,
"222"
);
u1
.
put
(
"userName"
,
"Test"
);
userMap
.
put
(
"222"
,
u2
);
}
@Override
@WebMethod
public
String
getUserName
(
String
userId
)
{
return
"userId为:"
+
userId
;
}
@Override
@WebMethod
public
String
getUser
(
String
userId
)
{
return
null
;
}
}
src/main/java/com/egolm/sso/service/impl/XsipSdServiceImpl.java
0 → 100644
View file @
17110957
package
com
.
egolm
.
sso
.
service
.
impl
;
import
javax.jws.WebMethod
;
import
javax.jws.WebService
;
import
org.springframework.stereotype.Component
;
import
com.egolm.sso.service.XsipSdService
;
@Component
@WebService
(
serviceName
=
"XsipSdService"
,
targetNamespace
=
"http://service.sso.egolm.com"
,
endpointInterface
=
"com.egolm.sso.service.XsipSdService"
)
public
class
XsipSdServiceImpl
implements
XsipSdService
{
@Override
@WebMethod
public
void
pushMaterialMaster
(
String
xml
)
{
System
.
out
.
println
(
xml
);
}
@Override
public
void
pushPriceList
(
String
xml
)
{
System
.
out
.
println
(
xml
);
}
@Override
public
void
pushProFormaInvoice
(
String
xml
)
{
System
.
out
.
println
(
xml
);
}
@Override
public
void
pushShippingNotfirmation
(
String
xml
)
{
System
.
out
.
println
(
xml
);
}
@Override
public
void
pushSoConfirmQuotation
(
String
xml
)
{
System
.
out
.
println
(
xml
);
}
@Override
public
void
pushSoDnDeletion
(
String
xml
)
{
System
.
out
.
println
(
xml
);
}
}
src/main/resources/.gitignore
0 → 100644
View file @
17110957
/application.properties
src/main/resources/application-dev.properties
0 → 100644
View file @
17110957
wsUsername
=
test
wsPassword
=
78258c537d6e4d5fb210a57d05619fb6
\ No newline at end of file
src/main/resources/application-pro.properties
0 → 100644
View file @
17110957
wsUsername
=
schneider
wsPassword
=
f14d4a80f823438a875b1924384c944c
\ No newline at end of file
src/main/resources/application.yml
0 → 100644
View file @
17110957
server
:
port
:
8080
spring
:
profiles
:
active
:
dev
cxf
:
path
:
/sso/services
servlet
:
load-on-startup
:
-1
\ No newline at end of file
src/main/resources/ca/server.jks
0 → 100644
View file @
17110957
File added
src/main/resources/ca/server.properties
0 → 100644
View file @
17110957
org.apache.ws.security.crypto.provider
=
org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type
=
jks
org.apache.ws.security.crypto.merlin.keystore.password
=
storepass
org.apache.ws.security.crypto.merlin.keystore.alias
=
serverprivatekey
org.apache.ws.security.crypto.merlin.file
=
ca/server.jks
\ No newline at end of file
src/main/resources/log4j.properties
0 → 100644
View file @
17110957
log4j.rootLogger
=
info,appender
log4j.appender.appender
=
org.apache.log4j.ConsoleAppender
log4j.appender.appender.layout
=
org.apache.log4j.TTCCLayout
\ No newline at end of file
src/main/resources/logback.xml
0 → 100644
View file @
17110957
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<appender
name=
"siftingAppender"
class=
"ch.qos.logback.classic.sift.SiftingAppender"
>
<discriminator>
<key>
context
</key>
<DefaultValue>
logback
</DefaultValue>
</discriminator>
<sift>
<appender
name=
"rollingFileAppender"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<FileNamePattern>
/data/logs/sso/${context}-%d{yyyy-MM-dd}.log
</FileNamePattern>
<MaxHistory>
30
</MaxHistory>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
</encoder>
</appender>
</sift>
</appender>
<root
level=
"INFO"
>
<appender-ref
ref=
"siftingAppender"
/>
</root>
<springProfile
name=
"dev"
>
<root
level=
"INFO"
>
<appender-ref
ref=
"siftingAppender"
/>
</root>
</springProfile>
<springProfile
name=
"pro"
>
<root
level=
"INFO"
>
<appender-ref
ref=
"siftingAppender"
/>
</root>
</springProfile>
<!-- <logger name="com.microsoft" level="INFO" />
<logger name="com.alibaba" level="INFO" />
<logger name="springfox" level="ERROR" />
<logger name="javax" level="ERROR" />
<logger name="java" level="ERROR" />
<logger name="net" level="ERROR" />
<logger name="org" level="INFO" />
<logger name="io" level="INFO" /> -->
</configuration>
\ No newline at end of file
src/test/java/sso/TestClient.java
0 → 100644
View file @
17110957
package
sso
;
import
java.io.BufferedReader
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.CallbackHandler
;
import
org.apache.cxf.endpoint.Client
;
import
org.apache.cxf.endpoint.ClientImpl
;
import
org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory
;
import
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor
;
import
org.apache.ws.security.WSConstants
;
import
org.apache.ws.security.handler.WSHandlerConstants
;
import
org.apache.wss4j.common.ext.WSPasswordCallback
;
import
org.junit.Before
;
import
org.junit.Test
;
import
com.alibaba.fastjson.JSON
;
public
class
TestClient
{
private
final
String
username
=
"test"
;
private
final
String
password
=
"78258c537d6e4d5fb210a57d05619fb6"
;
private
Client
wsClient
;
@Before
public
void
init
()
{
JaxWsDynamicClientFactory
factory
=
JaxWsDynamicClientFactory
.
newInstance
();
ClientImpl
client
=
(
ClientImpl
)
factory
.
createClient
(
"http://localhost:8080/sso/services/xsip?wsdl"
);
Map
<
String
,
Object
>
properties
=
new
HashMap
<
String
,
Object
>();
properties
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
properties
.
put
(
WSHandlerConstants
.
USER
,
username
);
properties
.
put
(
WSHandlerConstants
.
PASSWORD_TYPE
,
WSConstants
.
PW_DIGEST
);
properties
.
put
(
WSHandlerConstants
.
PW_CALLBACK_REF
,
new
CallbackHandler
()
{
public
void
handle
(
Callback
[]
callbacks
)
{
for
(
int
i
=
0
;
i
<
callbacks
.
length
;
i
++)
{
WSPasswordCallback
pc
=
(
WSPasswordCallback
)
callbacks
[
i
];
pc
.
setPassword
(
password
);
}
}
});
WSS4JOutInterceptor
interceptor
=
new
WSS4JOutInterceptor
();
interceptor
.
setProperties
(
properties
);
client
.
setOutInterceptors
(
Arrays
.
asList
(
interceptor
));
wsClient
=
client
;
}
private
String
readText
(
String
path
)
throws
IOException
{
BufferedReader
br
=
null
;
try
{
br
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
path
)));
String
line
=
null
;
StringBuffer
sb
=
new
StringBuffer
();
while
((
line
=
br
.
readLine
())
!=
null
)
{
sb
.
append
(
line
);
}
return
sb
.
toString
();
}
finally
{
br
.
close
();
}
}
@Test
public
void
test001
()
throws
Exception
{
String
xml
=
this
.
readText
(
"D:/data/sso/001.XML"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushMaterialMaster"
,
xml
)));
}
@Test
public
void
test002
()
throws
Exception
{
String
xml
=
this
.
readText
(
"D:/data/sso/002.XML"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushPriceList"
,
xml
)));
}
@Test
public
void
test005
()
throws
Exception
{
String
xml
=
this
.
readText
(
"D:/data/sso/005.XML"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushProFormaInvoice"
,
xml
)));
}
@Test
public
void
test007
()
throws
Exception
{
String
xml
=
this
.
readText
(
"D:/data/sso/007.XML"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushShippingNotfirmation"
,
xml
)));
}
@Test
public
void
test008
()
throws
Exception
{
String
xml1
=
this
.
readText
(
"D:/data/sso/008-1.XML"
);
String
xml2
=
this
.
readText
(
"D:/data/sso/008-2.XML"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushSoConfirmQuotation"
,
xml1
)));
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushSoConfirmQuotation"
,
xml2
)));
}
@Test
public
void
test010
()
throws
Exception
{
// String xml = this.readText("D:/data/sso/010.XML");
String
xml
=
"文件样例暂时没有"
;
System
.
out
.
println
(
JSON
.
toJSONString
(
wsClient
.
invoke
(
"pushSoDnDeletion"
,
xml
)));
}
}
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