티스토리 뷰
WS-Security (Web Services Security, short WSS) is an extension to SOAP to apply security to web services. It is a member of the WS-* family of web service specifications and was published by OASIS.
The protocol specifies how integrity and confidentiality can be enforced on messages and allows the communication of various security token formats, such as SAML, Kerberos, and X.509. Its main focus is the use of XML Signature and XML Encryption to provide end-to-end security.
[추가필요한 lib]
<!-- WS-Security -->
<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.9-b14002</version>
</dependency>
[ClientPasswordCallback.java 추가생성]
import java.io.IOException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class ClientPasswordCallback implements CallbackHandler
{
@Value("${webservice.wssecurity.accept.passwd}")
private String wssecurityAcceptId;
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
WSPasswordCallback pc = (WSPasswordCallback)callbacks[0];
pc.setPassword(wssecurityAcceptId);
}
}
[consumer에 추가할 코드]
xxxxxClass {
@Value("${webservice.wssecurity.accept.id}")
private String wssecurityAcceptId;
try{
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(PSFmsTOneossGetOrgCarPort.class);
factory.setAddress("http://osb/ABCD/GetsdtddodoDfc");
PSFmsTOneossGetOrgCarPort port = (PSFmsTOneossGetOrgCarPort)factory.create();
Client client = ClientProxy.getClient(port);
Endpoint cxfEndpoint = client.getEndpoint();
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER, wssecurityAcceptId);
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordCallback.class.getName());
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
위 코드 추가 후....
위에서 생성된 port로 웹서비스 호출하면 끝
}
ps. 물론 provider에도 인증 계정정보 셋팅 필요
'WebService' 카테고리의 다른 글
WSDL (0) | 2015.12.31 |
---|
- Total
- Today
- Yesterday
- 대화로 코딩
- 메모리
- 아키텍처요소
- ai coding
- mailserver
- apache POI
- Persistent
- minikube
- 딥러닝
- POI
- Hibernate
- nvida gpu 할당
- 바이브코딩
- non-functional
- orm
- vibecoding
- 자바스크립트
- JVM
- 비기능
- 릴레이
- JPA
- 메일서버
- #iamreo
- poi셀크기
- 아키텍처비기능
- #gof #디자인패턴
- Gc
- 정규식
- memory
- non
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |