Win a copy of Spring Boot in Practice this week in the Spring forum!

Nigel Shrin

Ranch Hand
+ Follow
since May 18, 2009
United Kingdom (Mainland)
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nigel Shrin

Hi John,
many thanks for the links and example code, very much appreciated, I'll work through these examples at the weekend.

8 years ago
Yes, I posted it on stackexchange yesterday. I was unaware of the term cross posting, and the policy - apologies if that has offended anyone.
I haven't had a reply from either site. Are you able to help?
8 years ago
Hi, I am trying to connect a pojo holding all the required xy coordinates, to a javafx scene graph, and cannot work out how to do this. It is a simple Javafx scene graph created with scenebuilder; a circle and three lines, and an exit button.

How do I connect the pojo holding with coords to javafx scene graph?

So far I have, all within a javafx enabled project in e(fx)clipse:
1) "classA": GeometryCalculator class, includes a member class object GeometryResultsObj
The output of classA is one instance of classB. This is in a for loop to run from 1-360 degrees, overwriting classB for each change.
2) "classB": GeometryResultsObj stores, the circle diameter, circle xy centre, 3 lines xy start & end coords
3) "classC": contains main() with launch() and start()
4) "classD": GeometryGraphic.fxml with a static circle and three lines (waiting to be animated)
5) "classE": GeometryGraphicController java class, contains initialize() and initData(classB coords).

ClassA is tested and calculates ok.
ClassB is correctly populated when classA is run.
ClassC when run, displays the scenegraph with circle & lines in their original positions, with no errors.

I've tried creating an initData method on the controller class which does a set on each fxml object with a get on the relevant pojo field. If I run the controller there is no classB of coordinates to read, but it runs ok, and displays the graphic with circle and lines in their initial positions.

To run the series of outputs to the scenegraph for 1-360 events, with a next button, so they can be visually checked for incorrect logic in classA. It would also be great to add a play button, with slow & fast slider to view a continously animated output.

The structure probably isn't quite right, as the driver is the ClassA. Driving from ClassC finds no ClassB with coordinate data. ClassA could be changed quite easily to create a result object per iteration (1-360) and add these to a collection.

Can you please advise how to link the graph to the coordinates, and how this should be restructured to enable this.
The nearest I can think of is calling the method in ClassA at the beginning of the controller classE's initData function?

I haven't included code as it would be a lot to post, even a cut down version. Advice on the correct approach & structure would be very much appreciated.

Thank you!
8 years ago
Hi Richard,
I don't mind in the slightest, and I am very grateful for the time you have taken to explain some principles of encryption to me. I read your comments yesterday evening and have ordered your recommended book. I think Java is a great language, and would very much like to improve the quality of my coding.

Although I knew the line of the error, I didn't know how to fix it! I am not familiar with many of the terms & concepts at this point; PKCS1, modulus length, padding etc. I thought I was only using AES256 and not RSA as well. I did O-level maths, but did not study maths further. So please forgive my ignorance. My next attempt may not be until next weekend - the book should have arrived by then.

Thank you for taking the time & effort to further my understanding.
8 years ago
Thanks Richard,

here's the enum:

In the previous to last example I had problems trying to store the key, so I read some more and found keystore.
The current example is to a large extent based on the code from the javadoc, I use Eclipse and that forced me to put so many catch clauses in.

I'll try and modify it tonight to just use a string to encrypt.

Can you see where the exception is coming from?

Thanks again for your time,

8 years ago
I just noticed that the alias was different on line 120, so I made it the same, but this made no difference to the error message:

line 120 (was: "privateKeyAlias") now reads:

thank you!
8 years ago
I have attempted to implement KeyStore but currently get an uninitialised keystore error.
The map of objects to encrypt then serialise is created, but no attempt has been made to do this yet.
The error has occurred from trying to create a KeyStore then retrieve the SecretKey for it.

Full error from line 86:

Full code:

object in map:

thank you!
8 years ago
Thanks Richard,
I'll do that, it'll be tomorrow now, I've been playing with this most of today,
Kind regards,
8 years ago
Hi Richard

1) I don't understand why "The getSkey() call on line 3, is a setter," . Surely it is a getter .
2) I don't understand why in line 3 of getStoreKey() you need to generate a key.
3) I don't understand "skUnsealed.equals((SecretKey)sealed2.getObject(dciTemp)); " . Since 'skUnsealed' is generated by a keyGen.generateKey() it probably returns a new random key so the chances of this new key being equal to any other key is just about zero.
4) I thought you were trying to place a collection in the sealed object and not a key.

point 1 - my typo, it is a getter, apologies
point 2 - I didn't want another secret key, just a way to return the result (extracted key), looking at it again, perhaps I could have done this on line 9, at the end of the try block:

point 3 - explained by answer to point 2
point 4 - this is a test to return a saved SecretKey that is in a SealedObject and serialized so it can be reused, when I have this working, so I am working towards the collection.

I could work on a SSCCE if the above is still not clear enough.

thanks again for your help,
8 years ago
NPE retrieving SecretKey from sealed object


I am having difficult tracing this error, the exact error is:

line 45 is a test call to the routine below from main():
public static void main(String[] args) {


I am pretty sure the error is in lines 3 or 9. The reason I created an object in line 3 was to have a return variable.
The getSkey() call on line 3, is a setter, to return the static class member, and this call works in itself.

Many thanks
8 years ago
thanks Richard, much appreciated!
8 years ago
am I correct in saying the SecretKey is a system generated password in effect, so it must be stored for use in the decipher object at a later date?

thank you
8 years ago
will do; a learning curve at the moment!
thanks for your help
8 years ago
Thanks Richard, key is an instance of KeyGenerator already, I've renamed it to be keyGen to make that clearer.

the SecretKey line is new, and this is now accepted in the cipher initialisation lines (13 & 14).
It does looks more promising, not run yet.


8 years ago
Hi Ulf,

My key id was an instance of SecretKey, when I changed this to be an instance of KeyGenerator then I was able to split line 31 without errors.
However the cipher lines 15 & 16, no longer accept the key, it expects Key and not KeyGenerator.

not sure of the relationship from KeyGenerator back to Key to initialize the Cipher objects?

thanks again for your help
8 years ago