Skip to content

Commit

Permalink
allow connection to a whisper server which doesn't enforce auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rpurdel committed Mar 4, 2024
1 parent 726ee2a commit 63ae0f3
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/main/java/org/jitsi/jigasi/transcription/WhisperWebsocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,29 @@ public class WhisperWebsocket

private String getJWT() throws NoSuchAlgorithmException, InvalidKeySpecException
{
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
KeyFactory kf = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKey));
PrivateKey finalPrivateKey = kf.generatePrivate(keySpecPKCS8);
JwtBuilder builder = Jwts.builder()
.setHeaderParam("kid", privateKeyName)
.setIssuedAt(now)
.setAudience(jwtAudience)
.setIssuer("jigasi")
.signWith(finalPrivateKey, SignatureAlgorithm.RS256);
long expires = nowMillis + (60 * 5 * 1000);
Date expiry = new Date(expires);
builder.setExpiration(expiry);
return builder.compact();
try
{
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
KeyFactory kf = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKey));
PrivateKey finalPrivateKey = kf.generatePrivate(keySpecPKCS8);
JwtBuilder builder = Jwts.builder()
.setHeaderParam("kid", privateKeyName)
.setIssuedAt(now)
.setAudience(jwtAudience)
.setIssuer("jigasi")
.signWith(finalPrivateKey, SignatureAlgorithm.RS256);
long expires = nowMillis + (60 * 5 * 1000);
Date expiry = new Date(expires);
builder.setExpiration(expiry);
return builder.compact();
}
catch (Exception e)
{
logger.error("Failed generating JWT for Whisper. " + e);
}
return null;
}

/**
Expand Down

0 comments on commit 63ae0f3

Please sign in to comment.