Skip to content

Commit c555e80

Browse files
authored
Implements ExpirationTimeout in WSSecurity data type. (#536)
Issue: 94939
1 parent b87173c commit c555e80

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

common/src/main/java/com/genexus/common/interfaces/IGXWSSecurity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ public interface IGXWSSecurity
66
void setSignature(IGXWSSignature signature);
77
IGXWSEncryption getEncryption();
88
void setEncryption(IGXWSEncryption encryption);
9+
int getExpirationTimeout();
10+
void setExpirationTimeout(int expiresTimeout);
911
}
1012

java/src/main/java/com/genexus/ws/security/GXWSSecurity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class GXWSSecurity implements IGXWSSecurity
88
{
99
private IGXWSSignature signature;
1010
private IGXWSEncryption encryption;
11+
private int expirationTimeout;
1112

1213
public GXWSSecurity()
1314
{
@@ -33,6 +34,16 @@ public IGXWSEncryption getEncryption()
3334
public void setEncryption(IGXWSEncryption encryption)
3435
{
3536
this.encryption = encryption;
36-
}
37+
}
38+
39+
public int getExpirationTimeout()
40+
{
41+
return expirationTimeout;
42+
}
43+
44+
public void setExpirationTimeout(int expirationTimeout)
45+
{
46+
this.expirationTimeout = expirationTimeout;
47+
}
3748
}
3849

wrapperjakarta/src/main/java/com/genexus/ws/GXHandlerConsumerChain.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.ws.security.message.WSSecEncrypt;
1818
import org.apache.ws.security.message.WSSecHeader;
1919
import org.apache.ws.security.message.WSSecSignature;
20+
import org.apache.ws.security.message.WSSecTimestamp;
2021
import org.w3c.dom.*;
2122
import java.io.InputStream;
2223
import java.io.ByteArrayInputStream;
@@ -123,9 +124,11 @@ public boolean handleMessage(SOAPMessageContext messageContext)
123124
//ws-security
124125
IGXWSSignature wsSignature = null;
125126
IGXWSEncryption wsEncryption = null;
127+
int expirationTimeout = 0;
126128
if (location.getWSSecurity() != null) {
127129
wsSignature = location.getWSSecurity().getSignature();
128130
wsEncryption = location.getWSSecurity().getEncryption();
131+
expirationTimeout = location.getWSSecurity().getExpirationTimeout();
129132
}
130133

131134
if (Boolean.TRUE.equals(outboundProperty) && soapHeaderRaw == null && ((wsSignature != null && !wsSignature.getAlias().isEmpty()) || (wsEncryption != null && !wsEncryption.getAlias().isEmpty())))
@@ -149,6 +152,13 @@ public boolean handleMessage(SOAPMessageContext messageContext)
149152
sign.setKeyIdentifierType(wsSignature.getKeyIdentifierType());
150153
sign.setUserInfo(wsSignature.getAlias(), wsSignature.getKeystore().getPassword());
151154
signedDoc = sign.build(doc, signatureCrypto, secHeader);
155+
156+
if (expirationTimeout > 0)
157+
{
158+
WSSecTimestamp timestamp = new WSSecTimestamp();
159+
timestamp.setTimeToLive(expirationTimeout);
160+
signedDoc = timestamp.build(signedDoc, secHeader);
161+
}
152162
}
153163

154164
//Encryption

wrapperjavax/src/main/java/com/genexus/ws/GXHandlerConsumerChain.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.ws.security.message.WSSecEncrypt;
1818
import org.apache.ws.security.message.WSSecHeader;
1919
import org.apache.ws.security.message.WSSecSignature;
20+
import org.apache.ws.security.message.WSSecTimestamp;
2021
import org.w3c.dom.*;
2122
import java.io.InputStream;
2223
import java.io.ByteArrayInputStream;
@@ -123,9 +124,11 @@ public boolean handleMessage(SOAPMessageContext messageContext)
123124
//ws-security
124125
IGXWSSignature wsSignature = null;
125126
IGXWSEncryption wsEncryption = null;
127+
int expirationTimeout = 0;
126128
if (location.getWSSecurity() != null) {
127129
wsSignature = location.getWSSecurity().getSignature();
128130
wsEncryption = location.getWSSecurity().getEncryption();
131+
expirationTimeout = location.getWSSecurity().getExpirationTimeout();
129132
}
130133

131134
if (Boolean.TRUE.equals(outboundProperty) && soapHeaderRaw == null && ((wsSignature != null && !wsSignature.getAlias().isEmpty()) || (wsEncryption != null && !wsEncryption.getAlias().isEmpty())))
@@ -149,6 +152,13 @@ public boolean handleMessage(SOAPMessageContext messageContext)
149152
sign.setKeyIdentifierType(wsSignature.getKeyIdentifierType());
150153
sign.setUserInfo(wsSignature.getAlias(), wsSignature.getKeystore().getPassword());
151154
signedDoc = sign.build(doc, signatureCrypto, secHeader);
155+
156+
if (expirationTimeout > 0)
157+
{
158+
WSSecTimestamp timestamp = new WSSecTimestamp();
159+
timestamp.setTimeToLive(expirationTimeout);
160+
signedDoc = timestamp.build(signedDoc, secHeader);
161+
}
152162
}
153163

154164
//Encryption

0 commit comments

Comments
 (0)