Welcome to my encyclopedia of shitty code!
-
Groovy: Log Annotation
PROBLEM My personal goal of 2017 is to write less useless-yet-neccessary code, such as initializing a logger:- SOLUTION Groovy provides several useful annotations that allow us to inject a logger instance into the class. Here’s a rewrite of the above example:- If we insist of using the same variable ( LOGGER ), we can do… Read More…
-
UnboundID: The entry contains attribute ‘XXXX’ which is not defined in the schema
PROBLEM Let’s assume we have the following LDIF file containing custom attribute(s), such as managedBy:- When running the code on UnboundID’s In-Memory Directory Server, the following exception is thrown:- SOLUTION The problem is caused by the fact that the default schema does not match Microsoft’s Active Directory schema. Hence, attribute(s), such as managedBy, would cause… Read More…
-
LdapTemplate: javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name ‘…’
BACKGROUND Let’s assume we have the following LDAP configuration… When running any LDAP query, the following exception is thrown:- SOLUTION There are 3 solutions to this problem. Query against Gobal Catalog To prevent the referral issues when dealing with Active Directory, we may query against the Global Catalog by using port 3268. The possible downside… Read More…
-
LdapTemplate: AttributesMapper vs ContextMapper
BACKGROUND When using Spring’s LdapTemplate, there are two ways to transform the queried results: AttributesMapper and ContextMapper. Here’s the comparison between these mapper classes. AttributesMapper If you are migrating your existing LDAP queries to Spring’s LdapTemplate, AttributesMapper seems ideal because you can copy most of the code over because it provides javax.naming.directory.Attributes. However, you have… Read More…
-
Spring: Component Scan Selected Classes
PROBLEM Let’s assume we have a package with the following classes where each class is either annotated with Spring’s @Service, @Component, @Controller or @Repository. When writing unit test, we want Spring to component scan class A and class B. SOLUTION Before we begin, we configure Log4j to log Spring in debug level. Step 1 If… Read More…
-
JAXB2: Adding toString() to Generated Java Classes
PROBLEM By default, the generated Java class prints the memory address when toString() is invoked. However, sometimes it is helpful to have a more meaningful toString() for debugging purposes. SOLUTION To fix this, configure maven-jaxb2-plugin to generate toString() based on the fields in the class:- Read More…
-
Spring Security SAML: Replacing SHA-1 with SHA-256 on Signature and Digest Algorithms
PROBLEM By default, Spring Security SAML’s SAMLBootstrap uses SHA1withRSA for signature algorithm and SHA-1 for digest algorithm. For example, the above configuration will generate the following SAML request payload when using HTTP-POST binding:- Unfortunately, SHA-1 is now deemed insecure due to “Freestart Collision” attack. Further, most modern browsers have ceased to trust SHA-1 code signing… Read More…
-
Spring Security SAML: Handling IdP’s Public Certificate When Loading Metadata Over HTTPS
PROBLEM By default, when loading IdP’s metadata over HTTPS (ex: https://adfs-server/federationmetadata/2007-06/federationmetadata.xml), Spring Security SAML will perform the trust verification configured in JDK. However, there are times we do not have direct access to JDK home directory especially if the web apps are hosted on someone else’s JEE or PaaS servers. SOLUTION To fix this, the… Read More…
About Author

This author has 20+ years of experience in software engineering and cloud engineering. In an industry where knowledge becomes obsolete in the next three months, he learns anything that crosses his path indiscriminately. He floats from one technology to another like a moth and stings the problem sets like a mosquito. This author codes Java while drinking Espresso and writes Spock specifications while listening to Groovy beats. He masters Google Cloud Platform just like how he masters the art of predicting the movement of dark clouds over his backyard, where 60% of the time, he is right every time.
This author suffers from the Dunning-Kruger effect, where he overestimates his competence and underestimates his ignorance. Technology buzzwords never faze him, for he does not know enough to be afraid of in the first place. GCP, GCS, GCR, GKE, GWT… everything sounds the same to him. He never fears acronyms, synonyms, or antonyms, for he has ChatGPT in his back pocket. This author is a jack of all trades but a master of none. He writes like he knows all the answers, yet he googles for better solutions from elsewhere. He fakes it until he makes it; if he doesn’t, that’s okay because he has the attention span of a squirrel. The blog posts are his buried walnuts, in case he needs them one day.
In conclusion, this author is full of something. He apologizes in advance if you are trying to solve your company’s real problems with his shitty solutions. There, he has successfully written paragraphs of nonsense because every professional blogging website needs a section about the author, with a too-cool-to-smile portrait staring sideways into the abyss.