Decrypt a JWE using list of keys that are stored in DB using JAVA 8 Lambda The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceConverting array to list in Javalist comprehension vs. lambda + filterRetrieving a List from a java.util.stream.Stream in Java 8Java 8 Lambda function that throws exception?Ways to iterate over a list in JavaJava 8 List<V> into Map<K, V>Find first element by predicateJava Lambda Stream Distinct() on arbitrary key?Java 8 lambdas using if else on list streamHow to use a Java 8 Lambda expression to convert a List of one type to a List of its subtype
The following signatures were invalid: EXPKEYSIG 1397BC53640DB551
Do working physicists consider Newtonian mechanics to be "falsified"?
Why did all the guest students take carriages to the Yule Ball?
Can undead you have reanimated wait inside a portable hole?
How to test the equality of two Pearson correlation coefficients computed from the same sample?
Derivation tree not rendering
RT6224D-based step down circuit yields 0V - why?
How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time
How can I protect witches in combat who wear limited clothing?
Difference between "generating set" and free product?
How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?
First use of “packing” as in carrying a gun
Button changing its text & action. Good or terrible?
Is there a writing software that you can sort scenes like slides in PowerPoint?
Why is superheterodyning better than direct conversion?
The variadic template constructor of my class cannot modify my class members, why is that so?
How is simplicity better than precision and clarity in prose?
What do you call a plan that's an alternative plan in case your initial plan fails?
Relations between two reciprocal partial derivatives?
Keeping a retro style to sci-fi spaceships?
Create an outline of font
What was the last x86 CPU that did not have the x87 floating-point unit built in?
Single author papers against my advisor's will?
He got a vote 80% that of Emmanuel Macron’s
Decrypt a JWE using list of keys that are stored in DB using JAVA 8 Lambda
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceConverting array to list in Javalist comprehension vs. lambda + filterRetrieving a List from a java.util.stream.Stream in Java 8Java 8 Lambda function that throws exception?Ways to iterate over a list in JavaJava 8 List<V> into Map<K, V>Find first element by predicateJava Lambda Stream Distinct() on arbitrary key?Java 8 lambdas using if else on list streamHow to use a Java 8 Lambda expression to convert a List of one type to a List of its subtype
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I Have a JWE which is to be decrypted using list of keys stored in DB. I have to try each key until I find the one that actually decrypts.
I am trying to do it in JAVA 8 way, writing Lambdas But I am unable to understand how to do it.
I have written following code
List<String> listKeys = myMapper.getDistinctEncKeyIds().stream() .map(MyMapper::encrypTionIdsfromDbData).collect(Collectors.toList());
This gives me list of keys and I am writing normal java code
for(int i=0; i<listKeys.size();i++)
try
decryptedToken= decrypt(token,listKeys.get(i));
catch(Exception e)
log.info("key not found: %s", e);
I want to convert it into JAVA 8 lambda code because that takes less no of lines and is easier to use something like this
myMapper.getDistinctEncKeyIds().stream()
.map(myMapper::encrypTionIdsfromDbData)
.filter(key-> decrypt(token,key))
.findFirst();
But I have two issues here
- Decrypt Method actually returns a key and filter takes a method which returns a boolean
- Decrypt method throws JOSEException, again I get an error in filter and I have to write try/catch block in the lambda
My Aim is to find the key that actually decrypts this token and return that key. I am not getting how to write it in java 8. Thanks in advance.
java lambda
add a comment |
I Have a JWE which is to be decrypted using list of keys stored in DB. I have to try each key until I find the one that actually decrypts.
I am trying to do it in JAVA 8 way, writing Lambdas But I am unable to understand how to do it.
I have written following code
List<String> listKeys = myMapper.getDistinctEncKeyIds().stream() .map(MyMapper::encrypTionIdsfromDbData).collect(Collectors.toList());
This gives me list of keys and I am writing normal java code
for(int i=0; i<listKeys.size();i++)
try
decryptedToken= decrypt(token,listKeys.get(i));
catch(Exception e)
log.info("key not found: %s", e);
I want to convert it into JAVA 8 lambda code because that takes less no of lines and is easier to use something like this
myMapper.getDistinctEncKeyIds().stream()
.map(myMapper::encrypTionIdsfromDbData)
.filter(key-> decrypt(token,key))
.findFirst();
But I have two issues here
- Decrypt Method actually returns a key and filter takes a method which returns a boolean
- Decrypt method throws JOSEException, again I get an error in filter and I have to write try/catch block in the lambda
My Aim is to find the key that actually decrypts this token and return that key. I am not getting how to write it in java 8. Thanks in advance.
java lambda
What doesdecryptreturn when it cannot decrypt a key?
– Amardeep Bhowmick
Mar 22 at 6:21
I run decrypt(token,key) in a loop passing each key and it returns the key which decrypts. This logic works fine. My question is hot to call decrypt after getting the keys in this lambda and return the key which has decrypted it. "myMapper.getDistinctEncKeyIds().stream() .map(myMapper::encrypTionIdsfromDbData) "
– ankita m
Mar 22 at 6:45
Your imperative style of writing the code is also incomplete in terms of the final operation and initial assignments if there are any. Due to which the question is quite unclear imho.
– Naman
Mar 22 at 7:13
add a comment |
I Have a JWE which is to be decrypted using list of keys stored in DB. I have to try each key until I find the one that actually decrypts.
I am trying to do it in JAVA 8 way, writing Lambdas But I am unable to understand how to do it.
I have written following code
List<String> listKeys = myMapper.getDistinctEncKeyIds().stream() .map(MyMapper::encrypTionIdsfromDbData).collect(Collectors.toList());
This gives me list of keys and I am writing normal java code
for(int i=0; i<listKeys.size();i++)
try
decryptedToken= decrypt(token,listKeys.get(i));
catch(Exception e)
log.info("key not found: %s", e);
I want to convert it into JAVA 8 lambda code because that takes less no of lines and is easier to use something like this
myMapper.getDistinctEncKeyIds().stream()
.map(myMapper::encrypTionIdsfromDbData)
.filter(key-> decrypt(token,key))
.findFirst();
But I have two issues here
- Decrypt Method actually returns a key and filter takes a method which returns a boolean
- Decrypt method throws JOSEException, again I get an error in filter and I have to write try/catch block in the lambda
My Aim is to find the key that actually decrypts this token and return that key. I am not getting how to write it in java 8. Thanks in advance.
java lambda
I Have a JWE which is to be decrypted using list of keys stored in DB. I have to try each key until I find the one that actually decrypts.
I am trying to do it in JAVA 8 way, writing Lambdas But I am unable to understand how to do it.
I have written following code
List<String> listKeys = myMapper.getDistinctEncKeyIds().stream() .map(MyMapper::encrypTionIdsfromDbData).collect(Collectors.toList());
This gives me list of keys and I am writing normal java code
for(int i=0; i<listKeys.size();i++)
try
decryptedToken= decrypt(token,listKeys.get(i));
catch(Exception e)
log.info("key not found: %s", e);
I want to convert it into JAVA 8 lambda code because that takes less no of lines and is easier to use something like this
myMapper.getDistinctEncKeyIds().stream()
.map(myMapper::encrypTionIdsfromDbData)
.filter(key-> decrypt(token,key))
.findFirst();
But I have two issues here
- Decrypt Method actually returns a key and filter takes a method which returns a boolean
- Decrypt method throws JOSEException, again I get an error in filter and I have to write try/catch block in the lambda
My Aim is to find the key that actually decrypts this token and return that key. I am not getting how to write it in java 8. Thanks in advance.
java lambda
java lambda
asked Mar 22 at 6:16
ankita mankita m
83
83
What doesdecryptreturn when it cannot decrypt a key?
– Amardeep Bhowmick
Mar 22 at 6:21
I run decrypt(token,key) in a loop passing each key and it returns the key which decrypts. This logic works fine. My question is hot to call decrypt after getting the keys in this lambda and return the key which has decrypted it. "myMapper.getDistinctEncKeyIds().stream() .map(myMapper::encrypTionIdsfromDbData) "
– ankita m
Mar 22 at 6:45
Your imperative style of writing the code is also incomplete in terms of the final operation and initial assignments if there are any. Due to which the question is quite unclear imho.
– Naman
Mar 22 at 7:13
add a comment |
What doesdecryptreturn when it cannot decrypt a key?
– Amardeep Bhowmick
Mar 22 at 6:21
I run decrypt(token,key) in a loop passing each key and it returns the key which decrypts. This logic works fine. My question is hot to call decrypt after getting the keys in this lambda and return the key which has decrypted it. "myMapper.getDistinctEncKeyIds().stream() .map(myMapper::encrypTionIdsfromDbData) "
– ankita m
Mar 22 at 6:45
Your imperative style of writing the code is also incomplete in terms of the final operation and initial assignments if there are any. Due to which the question is quite unclear imho.
– Naman
Mar 22 at 7:13
What does
decrypt return when it cannot decrypt a key?– Amardeep Bhowmick
Mar 22 at 6:21
What does
decrypt return when it cannot decrypt a key?– Amardeep Bhowmick
Mar 22 at 6:21
I run decrypt(token,key) in a loop passing each key and it returns the key which decrypts. This logic works fine. My question is hot to call decrypt after getting the keys in this lambda and return the key which has decrypted it. "myMapper.getDistinctEncKeyIds().stream() .map(myMapper::encrypTionIdsfromDbData) "
– ankita m
Mar 22 at 6:45
I run decrypt(token,key) in a loop passing each key and it returns the key which decrypts. This logic works fine. My question is hot to call decrypt after getting the keys in this lambda and return the key which has decrypted it. "myMapper.getDistinctEncKeyIds().stream() .map(myMapper::encrypTionIdsfromDbData) "
– ankita m
Mar 22 at 6:45
Your imperative style of writing the code is also incomplete in terms of the final operation and initial assignments if there are any. Due to which the question is quite unclear imho.
– Naman
Mar 22 at 7:13
Your imperative style of writing the code is also incomplete in terms of the final operation and initial assignments if there are any. Due to which the question is quite unclear imho.
– Naman
Mar 22 at 7:13
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293906%2fdecrypt-a-jwe-using-list-of-keys-that-are-stored-in-db-using-java-8-lambda%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293906%2fdecrypt-a-jwe-using-list-of-keys-that-are-stored-in-db-using-java-8-lambda%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does
decryptreturn when it cannot decrypt a key?– Amardeep Bhowmick
Mar 22 at 6:21
I run decrypt(token,key) in a loop passing each key and it returns the key which decrypts. This logic works fine. My question is hot to call decrypt after getting the keys in this lambda and return the key which has decrypted it. "myMapper.getDistinctEncKeyIds().stream() .map(myMapper::encrypTionIdsfromDbData) "
– ankita m
Mar 22 at 6:45
Your imperative style of writing the code is also incomplete in terms of the final operation and initial assignments if there are any. Due to which the question is quite unclear imho.
– Naman
Mar 22 at 7:13