Created Appointment creation flow.

This commit is contained in:
piyushkag
2024-12-04 21:07:06 +05:30
parent 8654e8ab0c
commit 80e1eefd29
33 changed files with 1519 additions and 10 deletions

View File

@@ -51,6 +51,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
@@ -580,4 +581,35 @@ public class Utils {
// Clear the RequestContextHolder after task execution
RequestContextHolder.resetRequestAttributes();
}
public static String generateAuthTokenForLoginToOdessa() {
try {
// Your weak secret key
String secretKey = GepafinConstant.AUTH_JWT_SECRET_KEY;
// Header
String header = GepafinConstant.JWT_ALGO_HEADER;
String encodedHeader = Base64.getUrlEncoder().withoutPadding().encodeToString(header.getBytes(StandardCharsets.UTF_8));
// Payload
String payload = "{\"iat\":" + (System.currentTimeMillis() / 1000) + "}";
String encodedPayload = Base64.getUrlEncoder().withoutPadding().encodeToString(payload.getBytes(StandardCharsets.UTF_8));
// Combine header and payload
String dataToSign = encodedHeader + "." + encodedPayload;
// Sign the token manually
Mac mac = Mac.getInstance(GepafinConstant.HMAC_ALGO);
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), GepafinConstant.HMAC_ALGO);
mac.init(secretKeySpec);
byte[] signatureBytes = mac.doFinal(dataToSign.getBytes(StandardCharsets.UTF_8));
String signature = Base64.getUrlEncoder().withoutPadding().encodeToString(signatureBytes);
// Return the final JWT
return dataToSign + "." + signature;
} catch (Exception e) {
throw new RuntimeException("Failed to generate JWT token", e);
}
}
}