fix date after review

This commit is contained in:
ggmaleva 2021-02-24 19:03:59 +03:00
parent adad92d240
commit b4d1fa1fd8

View File

@ -17,10 +17,6 @@ import org.keycloak.representations.AccessToken;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -46,9 +42,7 @@ public class BouncerContextFactory {
AccessToken accessToken = keycloakService.getAccessToken(); AccessToken accessToken = keycloakService.getAccessToken();
User user = userService.findById(accessToken.getSubject()); User user = userService.findById(accessToken.getSubject());
user.setRealm(new Entity().setId(bouncerProperties.getRealm())); user.setRealm(new Entity().setId(bouncerProperties.getRealm()));
String expiration = ZonedDateTime String expiration = Instant.ofEpochSecond(accessToken.getExp()).toString();
.ofInstant(Instant.ofEpochSecond(accessToken.getExp()), ZoneOffset.UTC)
.format(DateTimeFormatter.ISO_INSTANT);
Auth auth = new Auth() Auth auth = new Auth()
.setToken(new Token().setId(accessToken.getId())) .setToken(new Token().setId(accessToken.getId()))
.setMethod(bouncerProperties.getAuthMethod()) .setMethod(bouncerProperties.getAuthMethod())
@ -65,14 +59,7 @@ public class BouncerContextFactory {
Deployment deployment = new Deployment(); Deployment deployment = new Deployment();
deployment.setId(bouncerProperties.getDeploymentId()); deployment.setId(bouncerProperties.getDeploymentId());
env.setDeployment(deployment) env.setDeployment(deployment)
.setNow(ZonedDateTime .setNow(Instant.now().toString());
.now()
.truncatedTo(ChronoUnit.SECONDS)
.format(DateTimeFormatter.ISO_INSTANT));
return env; return env;
} }
public static void main(String[] args) {
System.out.println(Instant.now().toString());
}
} }