Skip to content

Instantly share code, notes, and snippets.

View Kurukshetran's full-sized avatar
🎯
Focusing

Kurukshetran Kurukshetran

🎯
Focusing
View GitHub Profile
@Kurukshetran
Kurukshetran / SpringPropertiesConfig.java
Created June 8, 2017 18:19 — forked from jeffsheets/SpringPropertiesConfig.java
Spring 4 Properties Java Configuration with Database-backed Properties along with File properties too
/**
* Example of Spring 4 Properties Java Configuration,
* with a Database Properties table to store most values
* and a small application.properties file too.
* The Database table will take precedence over the properties file with this setup
*/
@Configuration
@PropertySource(value = { "classpath:application.properties" }, ignoreResourceNotFound=true)
public class SpringPropertiesConfig {
private static final Logger log = LoggerFactory.getLogger(SpringPropertiesConfig.class);
@Kurukshetran
Kurukshetran / AWS Solutions Architect Associate
Created September 21, 2017 14:39 — forked from pareddy113/AWS Solutions Architect Associate
AWS Solutions Architect Associate 2017- ACloud Guru course
----- Interested Reads------
+ Interesting Read (Serverless Architecture of Acloud guru)
https://read.acloud.guru/serverless-the-future-of-software-architecture-d4473ffed864
----- Getting Started-------
+ Requirements
+ AWS Free Tier Account
+ PC with putty and putty keygen/ Mac
+ Optional
+ IoS/ Android App $20
@Kurukshetran
Kurukshetran / ApiController.java
Created October 17, 2017 10:56 — forked from itzg/ApiController.java
Bare bones unit test of RestController methods in a Spring Boot application.
package com.example;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/api")
@Kurukshetran
Kurukshetran / ValidDate.java
Created October 26, 2017 15:13 — forked from robinraju/ValidDate.java
Java Annotation for validating Date format in the given string
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
How to Create Your YouTube API Credentials
https://vidible.zendesk.com/hc/en-us/articles/207036056-How-to-Create-Your-YouTube-API-Credentials
Creating your YouTube API Credentials is accomplished by performing to main stages:
Stage I - Creating a Google OAuth 2.0 Web application client.
Stage II - Creating a YouTube refresh token.
@Kurukshetran
Kurukshetran / gist:1b918fa37445025712d15e56890edef1
Created November 5, 2017 17:23
J2EE - Example javax.servlet.Filter ServletResponse content modifying or use, e.g. to calculate MD5 and add to HTTP headers.
// MyFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
OutputStream out = response.getOutputStream();
ResponseWrapper wrapper = new ResponseWrapper((HttpServletResponse)response);
chain.doFilter(request, wrapper);
byte responseContent[] = wrapper.getData();
// Write copied response, should change whatever you want in 'responseContent' before sending to client
out.write(responseContent);
http.addFilterBefore(customAuthFilter(), SecurityContextPersistenceFilter.class)
.authorizeRequests()
.antMatchers("/**")
.authenticated()
.and()
.exceptionHandling().disable()
.sessionManagement().disable()
.rememberMe().disable()
.x509().disable()
.headers().disable()
@Kurukshetran
Kurukshetran / gist:9547314f37401629116d185bcfe4b246
Created January 30, 2018 14:06 — forked from yterradas/gist:7e95378640eeb597ce33
Override AnonymousAuthenticationFilter with a custom implementation.
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig
extends WebSecurityConfigurerAdapter {
@Value("${oauth.check_token.url:http://localhost:3030/oauth/token/info}")
private String checkTokenUrl;
@Autowired @Qualifier("restTemplate")
private RestOperations authRestTemplate;
@Kurukshetran
Kurukshetran / gist:025337da514e6bf2ab09022a32990559
Created January 30, 2018 14:06 — forked from yterradas/gist:0fe2ab41081e9a676f3e
Custom filter added to spring security filter chain.
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig
extends WebSecurityConfigurerAdapter {
@Value("${oauth.check_token.url:http://localhost:3030/oauth/token/info}")
private String checkTokenUrl;
@Autowired @Qualifier("restTemplate")
private RestOperations authRestTemplate;
@Kurukshetran
Kurukshetran / Iso9797Alg3MacTest.java
Created February 17, 2018 13:05 — forked from Gilmor/Iso9797Alg3MacTest.java
Iso9797Alg3 - Retail MAC Calculation in Java
package cz.monetplus.mac;
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.engines.DESEngine;
import org.bouncycastle.crypto.macs.ISO9797Alg3Mac;
import org.bouncycastle.crypto.params.KeyParameter;