Skip to content

Instantly share code, notes, and snippets.

@Glamdring
Glamdring / HerokuController.java
Last active January 29, 2019 09:21
Controller for integrating a SaaS with Heroku
package com.yourapp.web.external;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
import com.yourapp.dto.UserDetails;
import com.yourapp.dto.UserRegistrationRequest;
import com.yourapp.entities.Application;
import com.yourapp.entities.Organization;
import com.yourapp.enums.IntegratedCloudProvider;
import com.yourapp.enums.SubscriptionPlanCode;
Year Regulations Amending regulations Council regulations Council amending regulations Commission regulations Commission amending regulations Directives Amending directives Council directives Council amending directives Commission directives Commission amending directives
1990 0 0 268 137 779 334 0 0 53 18 6 18
1991 0 0 217 119 716 410 0 0 41 27 9 26
1992 0 0 238 140 755 382 0 0 71 22 9 20
1993 0 0 211 110 633 427 0 0 43 21 24 28
1994 0 1 192 108 559 402 13 7 11 18 11 19
1995 0 0 151 115 427 425 7 3 14 14 12 22
1996 3 1 135 108 375 380 9 8 22 17 16 23
1997 1 0 137 97 331 431 11 12 7 14 11 24
1998 0 0 127 101 337 437 19 9 12 17 14 30
@Controller
@RequestMapping("/whitelabel-resources")
public class WhitelabelResourceController {
@Autowired
private WhitelabelService whitelabelService;
@GetMapping("/logo.png")
private ResponseEntity getLogo(@AuthenticationPrincipal LoginAuthenticationToken token,
@RequestParam(name = "key", required = false) String key) {
@Glamdring
Glamdring / LocalTSA.java
Last active January 17, 2019 07:17
A local TSA
@Service
public class TimestampService {
private static final Logger logger = LoggerFactory.getLogger(TimestampService.class);
public static final AlgorithmIdentifier sha512oid = getSha512Oid();
private SecureRandom random = new SecureRandom();
@Value("${timestamp.keystore.path}")
private Resource keystorePath;
@Glamdring
Glamdring / TimestampValidationService.java
Created December 17, 2017 08:39
Validating trusted timestamps
public class TimestampValidationService {
public boolean validate(String hash, String encodedTimestampToken) {
try {
byte[] tokenBytes = Base64.getDecoder().decode(encodedTimestampToken);
CMSSignedData signedData = new CMSSignedData(tokenBytes);
TimeStampToken token = new TimeStampToken(signedData);
Optional<X509CertificateHolder> certHolder = getCertificateHolder(signedData);
BcRSASignerInfoVerifierBuilder verifierBuilder = new BcRSASignerInfoVerifierBuilder(
new DefaultCMSSignatureAlgorithmNameGenerator(),
@Glamdring
Glamdring / TimestampingService.java
Last active March 26, 2019 08:20
Using trusted timestamps
public class TimestampService {
private static final Logger logger = LoggerFactory.getLogger(TimestampService.class);
private static final AlgorithmIdentifier sha512oid = getSha512Oid();
private static final ASN1ObjectIdentifier baseTsaPolicyId = new ASN1ObjectIdentifier("0.4.0.2023.1.1");
private SecureRandom random = new SecureRandom();
private static AlgorithmIdentifier getSha512Oid() {
DigestAlgorithmIdentifierFinder algorithmFinder = new DefaultDigestAlgorithmIdentifierFinder();
#! /usr/bin/env python
import sys
from boto import ec2, cloudformation
import boto.utils
def get_group_info(ec2conn, instance_id) :
reservations = ec2conn.get_all_instances(instance_id)
instance = [i for r in reservations for i in r.instances][0]
if instance.tags.has_key('aws:autoscaling:groupName'):
#!/bin/sh
# No sudo, as init scripts run as root
BUCKET_NAME=$1
STACK_NAME=$2
EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
EC2_REGION="`echo \"$EC2_AVAIL_ZONE\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
REGION_PREFIX="`echo ${EC2_REGION: : -2}`"
BIND_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
echo "Bucket name for fetching configuration is $BUCKET_NAME"
"PrivateSubnetA": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Fn::Select": [
0,
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.5.0-RELEASE</version>
<exclusions>
<exclusion>
<artifactId>leveldbjni-all</artifactId>
<groupId>org.ethereum</groupId>
</exclusion>
<exclusion>