cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/2] cxf git commit: Finished Java 8 DateTime work
Date Wed, 22 Mar 2017 11:14:09 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a4b98454d -> 06588cac6


http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerRealmTest.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerRealmTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerRealmTest.java
index 951ab1f..0fa3827 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerRealmTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerRealmTest.java
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.sts.token.renewer;
 
+import java.time.Instant;
 import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -273,13 +273,14 @@ public class SAMLTokenRenewerRealmTest extends org.junit.Assert {
         providerParameters.getTokenRequirements().setRenewing(renewing);
 
         if (ttlMs != 0) {
-            ZonedDateTime creationTime = ZonedDateTime.now(ZoneOffset.UTC);
-            ZonedDateTime expirationTime = creationTime.plusNanos(ttlMs * 1000000L);
-
             Lifetime lifetime = new Lifetime();
-            lifetime.setCreated(DateUtil.getDateTimeFormatter(true).format(creationTime));
-            lifetime.setExpires(DateUtil.getDateTimeFormatter(true).format(expirationTime));
+            
+            Instant creationTime = Instant.now();
+            Instant expirationTime = creationTime.plusNanos(ttlMs * 1000000L);
 
+            lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
+            lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
+            
             providerParameters.getTokenRequirements().setLifetime(lifetime);
         }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerTest.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerTest.java
index 359ea76..77b772b 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerTest.java
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.sts.token.renewer;
 
+import java.time.Instant;
 import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
 import java.util.Properties;
 
 import javax.security.auth.callback.CallbackHandler;
@@ -577,12 +577,13 @@ public class SAMLTokenRenewerTest extends org.junit.Assert {
         providerParameters.getTokenRequirements().setRenewing(renewing);
 
         if (ttlMs != 0) {
-            ZonedDateTime creationTime = ZonedDateTime.now(ZoneOffset.UTC);
-            ZonedDateTime expirationTime = creationTime.plusNanos(ttlMs * 1000000L);
-
             Lifetime lifetime = new Lifetime();
-            lifetime.setCreated(DateUtil.getDateTimeFormatter(true).format(creationTime));
-            lifetime.setExpires(DateUtil.getDateTimeFormatter(true).format(expirationTime));
+            
+            Instant creationTime = Instant.now();
+            Instant expirationTime = creationTime.plusNanos(ttlMs * 1000000L);
+
+            lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
+            lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
             
             providerParameters.getTokenRequirements().setLifetime(lifetime);
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
index 7d396f7..0d5af95 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
@@ -21,8 +21,8 @@ package org.apache.cxf.sts.token.validator;
 import java.io.IOException;
 import java.net.URI;
 import java.security.Principal;
+import java.time.Instant;
 import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -579,12 +579,12 @@ public class SAMLTokenValidatorTest extends org.junit.Assert {
             );
 
         if (ttlMs != 0) {
-            ZonedDateTime creationTime = ZonedDateTime.now(ZoneOffset.UTC);
-            ZonedDateTime expirationTime = creationTime.plusNanos(ttlMs * 1000000L);
-
             Lifetime lifetime = new Lifetime();
-            lifetime.setCreated(DateUtil.getDateTimeFormatter(true).format(creationTime));
-            lifetime.setExpires(DateUtil.getDateTimeFormatter(true).format(expirationTime));
+            Instant creationTime = Instant.now();
+            Instant expirationTime = creationTime.plusNanos(ttlMs * 1000000L);
+
+            lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
+            lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
 
             providerParameters.getTokenRequirements().setLifetime(lifetime);
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
index e91f60a..8cfcf8a 100644
--- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
+++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
@@ -24,8 +24,8 @@ import java.io.InputStream;
 import java.net.URL;
 import java.security.PublicKey;
 import java.security.cert.X509Certificate;
+import java.time.Instant;
 import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Base64;
 import java.util.HashMap;
@@ -796,17 +796,17 @@ public class SimpleBatchSTSClient implements Configurable, InterceptorProvider
{
     }
 
     protected void addLifetime(XMLStreamWriter writer) throws XMLStreamException {
-        ZonedDateTime creationTime = ZonedDateTime.now(ZoneOffset.UTC);
-        ZonedDateTime expirationTime = creationTime.plusSeconds(ttl); 
+        Instant creationTime = Instant.now();
+        Instant expirationTime = creationTime.plusSeconds(ttl);
 
         writer.writeStartElement("wst", "Lifetime", namespace);
         writer.writeNamespace("wsu", WSConstants.WSU_NS);
         writer.writeStartElement("wsu", "Created", WSConstants.WSU_NS);
-        writer.writeCharacters(DateUtil.getDateTimeFormatter(true).format(creationTime));
+        writer.writeCharacters(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
         writer.writeEndElement();
 
         writer.writeStartElement("wsu", "Expires", WSConstants.WSU_NS);
-        writer.writeCharacters(DateUtil.getDateTimeFormatter(true).format(expirationTime));
+        writer.writeCharacters(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
         writer.writeEndElement();
         writer.writeEndElement();
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/caching/CachingTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/caching/CachingTest.java
b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/caching/CachingTest.java
index 8aa2ec0..2449094 100644
--- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/caching/CachingTest.java
+++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/caching/CachingTest.java
@@ -19,8 +19,7 @@
 package org.apache.cxf.systest.sts.caching;
 
 import java.net.URL;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
@@ -196,7 +195,7 @@ public class CachingTest extends AbstractBusClientServerTestBase {
         assertNotNull(tok);
 
         // Make the token "about to expire"
-        tok.setExpires(ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(5L).toInstant());
+        tok.setExpires(Instant.now().plusSeconds(5L));
         assertTrue(tok.isAboutToExpire(10L));
 
         doubleIt(port, 25);

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenOutInterceptorTest.java
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenOutInterceptorTest.java
index 0f0d319..0dcde8b 100644
--- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenOutInterceptorTest.java
+++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenOutInterceptorTest.java
@@ -26,8 +26,7 @@ import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -329,7 +328,7 @@ public class STSTokenOutInterceptorTest extends AbstractBusClientServerTestBase
         Assert.assertNotNull(token);
         Assert.assertEquals(TOKEN_TYPE_SAML_2_0, token.getTokenType());
         Assert.assertNotNull(token.getId());
-        Assert.assertTrue(token.getExpires().isAfter(ZonedDateTime.now(ZoneOffset.UTC).toInstant()));
+        Assert.assertTrue(token.getExpires().isAfter(Instant.now()));
         Assert.assertEquals("Assertion", token.getToken().getLocalName());
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenRetrieverTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenRetrieverTest.java
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenRetrieverTest.java
index 024e41a..33f7b93 100644
--- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenRetrieverTest.java
+++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSTokenRetrieverTest.java
@@ -26,8 +26,7 @@ import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -267,7 +266,7 @@ public class STSTokenRetrieverTest extends AbstractBusClientServerTestBase
{
         Assert.assertNotNull(token);
         Assert.assertEquals(TOKEN_TYPE_SAML_2_0, token.getTokenType());
         Assert.assertNotNull(token.getId());
-        Assert.assertTrue(token.getExpires().isAfter(ZonedDateTime.now(ZoneOffset.UTC).toInstant()));
+        Assert.assertTrue(token.getExpires().isAfter(Instant.now()));
         Assert.assertEquals("Assertion", token.getToken().getLocalName());
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
----------------------------------------------------------------------
diff --git a/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
b/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
index c489dba..87c9edf 100644
--- a/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
+++ b/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
@@ -22,8 +22,7 @@ package org.apache.cxf.xkms.x509.validator;
 import java.security.cert.CertificateExpiredException;
 import java.security.cert.CertificateNotYetValidException;
 import java.security.cert.X509Certificate;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 import java.util.Date;
 import java.util.List;
 import java.util.logging.Logger;
@@ -46,10 +45,10 @@ public class DateValidator implements Validator {
      * @return the validity state of the certificate
      */
     public boolean isCertificateValid(X509Certificate certificate) {
-        ZonedDateTime dateTime = ZonedDateTime.now(ZoneOffset.UTC);
+        Instant now = Instant.now();
 
         try {
-            certificate.checkValidity(Date.from(dateTime.toInstant()));
+            certificate.checkValidity(Date.from(now));
         } catch (CertificateNotYetValidException e) {
             return false;
         } catch (CertificateExpiredException e) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAlgorithmTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAlgorithmTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAlgorithmTest.java
index bca5529..5ba27f6 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAlgorithmTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAlgorithmTest.java
@@ -21,9 +21,9 @@ package org.apache.cxf.systest.jaxrs.security.jose.jwt;
 
 import java.net.URL;
 import java.security.Security;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -92,7 +92,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase {
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -132,7 +132,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -175,7 +175,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -217,7 +217,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -260,7 +260,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -300,7 +300,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -337,7 +337,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -377,7 +377,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -413,7 +413,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -450,7 +450,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -491,7 +491,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -529,7 +529,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -565,7 +565,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -600,7 +600,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -640,7 +640,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -682,7 +682,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -721,7 +721,7 @@ public class JWTAlgorithmTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAuthnAuthzTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAuthnAuthzTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAuthnAuthzTest.java
index cdf303a..4d3c2f4 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAuthnAuthzTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jose/jwt/JWTAuthnAuthzTest.java
@@ -21,9 +21,9 @@ package org.apache.cxf.systest.jaxrs.security.jose.jwt;
 
 import java.net.URL;
 import java.security.Security;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -85,7 +85,7 @@ public class JWTAuthnAuthzTest extends AbstractBusClientServerTestBase {
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -125,7 +125,7 @@ public class JWTAuthnAuthzTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -162,7 +162,7 @@ public class JWTAuthnAuthzTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
         // The endpoint requires a role of "boss"
         claims.setProperty("role", "boss");
@@ -204,7 +204,7 @@ public class JWTAuthnAuthzTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(toList(address));
 
         JwtToken token = new JwtToken(claims);
@@ -240,7 +240,7 @@ public class JWTAuthnAuthzTest extends AbstractBusClientServerTestBase
{
         JwtClaims claims = new JwtClaims();
         claims.setSubject("alice");
         claims.setIssuer("DoubleItSTSIssuer");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setProperty("role", "manager");
         claims.setAudiences(toList(address));
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
index 5405f47..8345b46 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
@@ -18,8 +18,7 @@
  */
 package org.apache.cxf.systest.jaxrs.security.oauth2.common;
 
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -210,10 +209,10 @@ public final class OAuth2TestUtils {
         if (issuer != null) {
             claims.setIssuer(issuer);
         }
-        ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
-        claims.setIssuedAt(now.toEpochSecond());
+        Instant now = Instant.now();
+        claims.setIssuedAt(now.getEpochSecond());
         if (expiry) {
-            claims.setExpiryTime(now.plusSeconds(60L).toEpochSecond());
+            claims.setExpiryTime(now.plusSeconds(60L).getEpochSecond());
         }
         if (audience != null) {
             claims.setAudiences(Collections.singletonList(audience));

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/AuthorizationGrantNegativeTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/AuthorizationGrantNegativeTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/AuthorizationGrantNegativeTest.java
index fc4c398..9a15bba 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/AuthorizationGrantNegativeTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/AuthorizationGrantNegativeTest.java
@@ -20,8 +20,7 @@
 package org.apache.cxf.systest.jaxrs.security.oauth2.grants;
 
 import java.net.URL;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 import java.util.Collections;
 import java.util.Properties;
 
@@ -818,9 +817,9 @@ public class AuthorizationGrantNegativeTest extends AbstractBusClientServerTestB
         JwtClaims claims = new JwtClaims();
         claims.setSubject("consumer-id");
         claims.setIssuer("DoubleItSTSIssuer");
-        ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
-        claims.setIssuedAt(now.toEpochSecond());
-        claims.setExpiryTime(now.plusSeconds(60L).toEpochSecond());
+        Instant now = Instant.now();
+        claims.setIssuedAt(now.getEpochSecond());
+        claims.setExpiryTime(now.plusSeconds(60L).getEpochSecond());
         String audience = "https://localhost:" + PORT + "/services/token";
         claims.setAudiences(Collections.singletonList(audience));
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
index f9bd8e4..d9fcdd0 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
@@ -18,8 +18,7 @@
  */
 package org.apache.cxf.systest.jaxrs.security.oidc;
 
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
+import java.time.Instant;
 import java.util.List;
 
 import org.apache.cxf.rs.security.oauth2.common.UserSubject;
@@ -36,9 +35,9 @@ public class IdTokenProviderImpl implements IdTokenProvider {
     public IdToken getIdToken(String clientId, UserSubject authenticatedUser, List<String>
scopes) {
         IdToken token = new IdToken();
 
-        ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
-        token.setIssuedAt(now.toEpochSecond());
-        token.setExpiryTime(now.plusSeconds(60L).toEpochSecond());
+        Instant now = Instant.now();
+        token.setIssuedAt(now.getEpochSecond());
+        token.setExpiryTime(now.plusSeconds(60L).getEpochSecond());
         token.setAudience(clientId);
         token.setSubject(authenticatedUser.getLogin());
         token.setIssuer("OIDC IdP");

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
index 686e12e..7ea6986 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
@@ -26,8 +26,8 @@ import java.security.NoSuchAlgorithmException;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
+import java.time.Instant;
 import java.util.Collections;
-import java.util.Date;
 
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.Response;
@@ -608,7 +608,7 @@ public class OIDCFlowTest extends AbstractBusClientServerTestBase {
 
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("consumer-id");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(
             Collections.singletonList("https://localhost:" + PORT + "/unsignedjwtservices/"));
 
@@ -646,7 +646,7 @@ public class OIDCFlowTest extends AbstractBusClientServerTestBase {
 
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("consumer-id");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(
             Collections.singletonList("https://localhost:" + PORT + "/unsignedjwtservices/"));
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/06588cac/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java
index b2d5e21..3412529 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java
@@ -19,8 +19,8 @@
 package org.apache.cxf.systest.jaxrs.security.oidc;
 
 import java.net.URL;
+import java.time.Instant;
 import java.util.Collections;
-import java.util.Date;
 
 import javax.ws.rs.client.ResponseProcessingException;
 import javax.ws.rs.core.Form;
@@ -245,7 +245,7 @@ public class OIDCNegativeTest extends AbstractBusClientServerTestBase
{
 
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("consumer-id");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(
             Collections.singletonList("https://localhost:" + PORT + "/unsignedjwtservices/"));
         claims.setProperty("response_type", "token");
@@ -287,7 +287,7 @@ public class OIDCNegativeTest extends AbstractBusClientServerTestBase
{
 
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("consumer-id");
-        claims.setIssuedAt(new Date().getTime() / 1000L);
+        claims.setIssuedAt(Instant.now().getEpochSecond());
         claims.setAudiences(
             Collections.singletonList("https://localhost:" + PORT + "/unsignedjwtservices/"));
         claims.setProperty("client_id", "consumer-id2");


Mime
View raw message