Skip to content

Instantly share code, notes, and snippets.

View athiththan11's full-sized avatar
🤙
Revamping Engineering

Athiththan Kathirgamasegaran athiththan11

🤙
Revamping Engineering
View GitHub Profile
@athiththan11
athiththan11 / DefectivePasswordValidatorServiceComponent.java
Last active July 6, 2019 05:22
Service component registration for defective password validator
@Activate
protected void activate(ComponentContext context) {
try {
context.getBundleContext().registerService(AbstractEventHandler.class.getName(),
new DefectivePasswordValidatorEventHandler(), null);
// initialize all defective passwords from the text file
DefaultDefectivePasswordValidator.getInstance().initValues();
@athiththan11
athiththan11 / DefectivePasswordValidatorEventHandler.java
Last active July 6, 2019 05:20
Handling published events using HandleEvent() method
@Override
public void handleEvent(Event event) throws IdentityEventException {
if (log.isDebugEnabled()) {
log.debug("handleEvent() invoked");
}
if (IdentityEventConstants.Event.PRE_UPDATE_CREDENTIAL.equals(event.getEventName())
|| IdentityEventConstants.Event.PRE_UPDATE_CREDENTIAL_BY_ADMIN.equals(event.getEventName())) {
@athiththan11
athiththan11 / CustomMediator.java
Last active May 10, 2019 03:49
WSO2 Class Mediator implementation to manipulate and convert payloads
package <your package namespace>;
import org.apache.synapse.MessageContext;
import org.apache.synapse.commons.json.JsonUtil;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.json.JSONObject;
public class CustomMediator extends AbstractMediator {
@athiththan11
athiththan11 / pre-commit
Last active May 9, 2025 06:45
Git Pre Commit Hook for FIXME TODO
#!/bin/sh
# An hook script to verify changes to be committed do not contain
# any 'FIXME:' comments. Called by "git commit" with no arguments.
#
# The hook should exit with non-zero status after issuing an appropriate
# message if it stops the commit.
#
# To bypass this hook, use the "--no-verify" parameter when committing.
@athiththan11
athiththan11 / User.java
Created February 14, 2019 08:19
`static` keyword usage on methods
public class User {
List<String< convertedValue = Utility.convertStringToSomething("an input string here");
}
@athiththan11
athiththan11 / SmartPhone.java
Last active February 14, 2019 08:17
`static` keyword usage on fields
public class SmartPhone {
private String modelNumber;
private String battery;
public static int numberOfObjects;
public SmartPhone (String modelNumber, String battery) {
this.modelNumber = modelNumber;
this.battery = battery;
numberOfObjects++;
@athiththan11
athiththan11 / pom.xml
Created December 15, 2018 17:15
POM element to package and deploy to a specific folder
<project>
<!-- copy this section to your existing pom.xml -->
<!-- section: deploys the built artifact to the defined path -->
<build>
<!-- replace the name -->
<finalName>{{ jar/war name }}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@athiththan11
athiththan11 / pom.xml
Created December 15, 2018 17:09
POM file to package and install multiple maven modules
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>build-all-services</groupId>
<artifactId>build-services</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<name>build-all-services</name>
<modules>
@athiththan11
athiththan11 / csrf-stp-ajax-call
Last active October 2, 2018 05:16
CSRF Synchronizer Token Pattern | Ajax call request to retrieve the generated CSRF token from server
$.ajax({
url: 'serverURL',
type: 'post',
async: false,
data: {
'csrf_request': '<?php echo $_COOKIE['csrf_session_cookie'] ?>'
},
success: function (data) {
// appending the token to an hidden input field named csrf_token
document.getElementById("csrf_token").value = data;
@athiththan11
athiththan11 / csrf-dscp-form.html
Last active August 31, 2018 09:20
CSRF Double Submit Cookies Pattern Form
<!-- csrf form -->
<form class="mt-3 mb-3" action="/src/service.php" method="POST" onSubmit="appendToken()">
<!-- csrf hidden input field -->
<input type="hidden" id="csrf_token" name="csrf_token" value="csrf" />
<div class="form-group">
<label for="php">Do you like PHP ?</label>
<input type="text" class="form-control" id="php" name="php" placeholder="not at all... ;) " required autofocus/>
</div>
<div class="form-group">