public IAMOAuthBearerToken()

in src/main/java/software/amazon/msk/auth/iam/IAMOAuthBearerToken.java [53:69]


    public IAMOAuthBearerToken(String token) throws URISyntaxException {
        if(StringUtils.isEmpty(token)) {
            throw new IllegalArgumentException("Token can not be empty");
        }
        this.value = token;
        byte[] tokenBytes = token.getBytes(StandardCharsets.UTF_8);
        byte[] decodedBytes = Base64.getUrlDecoder().decode(tokenBytes);
        final String decodedPresignedUrl = new String(decodedBytes, StandardCharsets.UTF_8);
        final URI uri = new URI(decodedPresignedUrl);

        Map<String, List<String>> params = URIUtils.parseQueryParams(uri);
        int lifeTimeSeconds = Integer.parseInt(params.get(SignerConstant.X_AMZ_EXPIRES).get(0));
        final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
        final LocalDateTime signedDate = LocalDateTime.parse(params.get(SignerConstant.X_AMZ_DATE).get(0), dateFormat);
        this.startTimeMs = signedDate.toInstant(ZoneOffset.UTC).toEpochMilli();
        this.lifetimeMs = this.startTimeMs + (lifeTimeSeconds * 1000L);
    }