-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encrypt and decrypt chat lsp communication (#55)
* Initialize encryption server and implement LspEncryptionManager * Send chat request with encryption and decryption * Clean up Encryption classes * Fix checkstyle errors * Clean up Connection Provider * Clean LspJsonWebTokenHandler * Update class name to LspJsonWebToken * Decrypt partial result notification * Remove unused * Remove singleton on LspEncryptionManager * Revert "Remove singleton on LspEncryptionManager" This reverts commit 9b6ea01. * Update name of message to encryptedMessage * Encrypt quick actions * Fix encryption for chat and quick actions * Respond to pr comments * Fix checkstyle errors * Fix typos and copyright
- Loading branch information
Showing
13 changed files
with
252 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
plugin/src/software/aws/toolkits/eclipse/amazonq/chat/models/EncryptedChatParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
package software.aws.toolkits.eclipse.amazonq.chat.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public record EncryptedChatParams( | ||
@JsonProperty("message") String message, // Message as encrypted jwt | ||
@JsonProperty("partialResultToken") String partialResultToken) { | ||
} |
10 changes: 10 additions & 0 deletions
10
plugin/src/software/aws/toolkits/eclipse/amazonq/chat/models/EncryptedQuickActionParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
package software.aws.toolkits.eclipse.amazonq.chat.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public record EncryptedQuickActionParams( | ||
@JsonProperty("message") String message, // Message as encrypted jwt | ||
@JsonProperty("partialResultToken") String partialResultToken) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/encryption/LspEncryptionKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.encryption; | ||
|
||
import java.util.Base64; | ||
|
||
import javax.crypto.KeyGenerator; | ||
import javax.crypto.SecretKey; | ||
|
||
import software.aws.toolkits.eclipse.amazonq.exception.AmazonQPluginException; | ||
|
||
public final class LspEncryptionKey { | ||
private SecretKey key; | ||
|
||
public LspEncryptionKey() { | ||
this.key = generateKey(); | ||
} | ||
|
||
public SecretKey getKey() { | ||
return key; | ||
} | ||
|
||
public String getKeyAsBase64() { | ||
return base64Encode(key); | ||
} | ||
|
||
private String base64Encode(final SecretKey key) { | ||
return Base64.getEncoder().encodeToString(key.getEncoded()); | ||
} | ||
|
||
public static SecretKey generateKey() { | ||
try { | ||
KeyGenerator keyGen = KeyGenerator.getInstance("AES"); | ||
keyGen.init(256); | ||
return keyGen.generateKey(); | ||
} catch (Exception e) { | ||
throw new AmazonQPluginException("Error occurred while generating lsp encryption key", e); | ||
} | ||
} | ||
} |
Oops, something went wrong.