content: package com.alifetvaci.credit.authservice.service;
  
  import io.jsonwebtoken.Jwts;
  import io.jsonwebtoken.SignatureAlgorithm;
  import io.jsonwebtoken.io.Decoders;
  import io.jsonwebtoken.security.Keys;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.stereotype.Service;
  
  import java.security.Key;
  import java.util.Date;
  
  @Service
  public class JwtService {
      @Value("${security.jwt.secret-key}")
      private String secretKey;
  
      @Value("${security.jwt.expiration-time}")
      private long jwtExpiration;
  
      private long getExpirationTime() {
          return jwtExpiration;
      }
  
      public String buildToken(String subject) {
          return Jwts
                  .builder()
                  .setSubject(subject)
                  .setIssuedAt(new Date(System.currentTimeMillis()))
                  .setExpiration(new Date(System.currentTimeMillis() + getExpirationTime()))
                  .signWith(getSignInKey(), SignatureAlgorithm.HS256)
                  .compact();
      }
  
      private Key getSignInKey() {
          byte[] keyBytes = Decoders.BASE64.decode(secretKey);
          return Keys.hmacShaKeyFor(keyBytes);
      }
  }