Doorgaan naar hoofdcontent

Posts

On SSL certificate generation

 So, more stuff I always forget... how to properly generate SSL certs. Well, easiest is with openssl (of course) Something like: openssl req -new -newkey rsa:2048 -nodes  -sha256 -subj "/C=NL/ST=Utrecht/L=Utrecht/O=Cooperatieve Rabobank U.A./OU=RASS Groep ICT/CN=my-common-name.host.nl" -keyout somename-prod.key -out somename-prod.csr   That can get you a certificate sign request (csr) and the appropriate key.   Of course, you want to then import those keys into a keystore. The trick to doing that is to convert it to a pkcs12 format where it can have the certificate and the key combined.   openssl pkcs12 -export -inkey somename-prod.key -in somename-prod.rabobank.nl.crt -out somename-prod.p12  Note that the crt is the signed certificate, acquired through getting the csr generated above approved..   This p12 file you can import using something like KeyStore Explorer.   After that, you can also append the root certificates of the original cert, to en...
Recente posts

Junit 5 never runs in maven

We've had it so, so often. Junit 5 is a bitch to run in maven. First there were issues with the surefire plugin. Make sure that is updated. Then there were issues with the versions you need to use together. Whelp, that was all set up right. And of course... still no junit 5 A fun thing was seeing this: [INFO] --- maven-surefire-plugin:3.1.2:test (default-test) @ my-project --- [INFO] Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider   Yeah, that's not how it should go. This forces the junit 4 provider... Which is not the junit 5 generic one. After a lot of digging, it turns out that surefire determines which provider to use... through some magic from the classpath. Of course, nowhere is there a junit4 dependency. They're all gone. Well... Except... Except... The platform dependency   < dependency > < groupId >org.junit.platform</ groupId > < artifactId >junit-platform-launcher</ artifactId > < version ...

Windows batch scripting god ( java runtime switch)

 I am a batch scripting god. After a lot of pain, I managed to create a script which allows me to switch jvm's easily. For posterity, and my own flex skills, the script: @echo off rem set your local path to all the JVM's here. set jvmdir=c:\code\apps\jvms if NOT EXIST %jvmdir% goto invaliddir rem a little bit of manipulation rem first we remove everything before the jvms dir call set __temp=%%path:*%jvmdir%\=%% rem then we determine everything that follows after the next slash set __lastbit=%__temp:*\=% rem then we remove that lastbit, leaving only the entire directory and a \ at the end. call set __currentpath=%%__temp:%__lastbit%=%% rem then we remove the \ at the end set __currentjvm=%__currentpath:\=% if "%~1"=="" goto missingarg if NOT EXIST %jvmdir%\%1 goto unknowndir set __currentpath=%jvmdir%\%__currentjvm% set __replacement=%jvmdir%\%1 call SET path=%%path:%__currentpath%=%__replacement%%% CALL SET JAVA_HOME=%%JAVA_HOME:%__currentpath%=%__replacemen...

Java sux with regexes

 Java supports regexes right? Nothing to it! that is so nice about it Only after 15 years, I find out that it does have performance problems. https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5050507  Is a bug for regexes in java. Of course, they're rare. But how did I hit it? Well, doing stuff you shouldn't of course. In this case, parsing Json, by searching for a value of a certain key. That's straightforward, right? "key"\s:\s"([^"]+)" Well, it would be nice like that, but there's this tiny exception... the value can contain quotes as well. Okay, so we exclude them. Numerous posts tell you how to do it. The trick is to use an or, in essence saying: 'the string \" OR any character which is not a "`  We can see that in action  here All languages support it.   but.... not java. No, it has problems with these groups. It gives stack overflows. And it's a known fact. So, is this the end? I thought so. But then, I started diggi...

Thread binding data

In an application we work with threads, but for ease of usage, we may not want to pass around the same objects all the time. It helps in our method signature, signifying the objects we perfrom our function on, but sometimes, it feels rather unnecessary. For example, let's assume we have a request-id which we recieve, and want to pass to all outgoing requests. Or we want to prevent a certain query being performed multiple times by caching the result. These are request-scoped data items. Since every request runs in it's own thread, we can use threadlocals. In spring, we can do a bit better, by using a ThreadLocalTargetSource https://dzone.com/articles/an-alternative-approach-to-threadlocal-using-sprin-1 This allows us to get a thread-instance per request, which can be injected into our services without any knowledge of caching occuring. In essence, we create some sort of thread-tied global object. This is, of course, something which can be easily abused, and can lead...

Spring overriding beans

So we have a bean of type FunkyClass and we want to override it. How? Well, we have the @Ordered annotation, which allows us to define the order when there are multiple beans of the same type. However, what happens when we only want one? Spring does not automatically take the highest order. To override a bean, you can use the @Primary annotation :)

git partial revert

So, apparently I removed an entire directory. A long time ago in the history. But I want it back. I want it back for good. git checkout <commit id> -- <path-to-directory> Will checkout the directory nicely, thus restoring it. Also for files, etc.