Skip to content

Instantly share code, notes, and snippets.

View kwart's full-sized avatar

Josef Cacek kwart

View GitHub Profile
@kwart
kwart / TsaHashName.java
Created June 25, 2014 23:32
TSA hash algorithm used in a signed PDF (jsignpdf-itxt 1.5.5)
import java.util.List;
import net.sf.jsignpdf.utils.PdfUtils;
import org.bouncycastle.tsp.TimeStampToken;
import com.lowagie.text.pdf.AcroFields;
import com.lowagie.text.pdf.PdfPKCS7;
import com.lowagie.text.pdf.PdfReader;
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg>f.fn.jquery%7C%7Ch(f))%7Bc=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd=="loaded"%7C%7Cd=="complete"))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,"1.3.2",function($,L)%7B$('%23header, .pagehead, .breadcrumb, .commit, .meta, %23footer, %23footer-push, .wiki-actions, %23last-edit, .actions, .header, .repository-sidebar, .file-navigation, .site-footer, .repository-meta, .overall-summary, .files-bubble').remove(); $('%23files, .file').css(%7B"background":"none", "border":"none"%7D); $('link').removeAttr('media'); window.print();%7D);void(0);
// http://unix.stackexchange.com/questions/30903/how-to-escape-quotes-in-shell
// http://unix.stackexchange.com/questions/4770/quoting-in-ssh-host-foo-and-ssh-host-sudo-su-user-c-foo-type-constructs
// see apache commons-lang3 StringEscapeUtils
// http://stackoverflow.com/questions/82256/how-do-i-use-sudo-to-redirect-output-to-a-location-i-dont-have-permission-to-wr?rq=1
// http://stackoverflow.com/questions/3034186/in-java-is-there-a-way-to-write-a-string-literal-without-having-to-escape-quote
public static void main(String[] args) throws IOException {
final SSHClient ssh = new SSHClient();
@kwart
kwart / ssh-host-config.patch
Created June 1, 2016 17:23
Cygwin sshd service regenerates /etc/passwd with local users when the service is started
--- ssh-host-config.orig 2016-06-01 17:05:03.676035200 +0000
+++ ssh-host-config 2016-06-01 17:08:12.793684500 +0000
@@ -475,8 +475,9 @@
csih_inform "will start automatically after the next reboot."
fi
else
- if /usr/bin/cygrunsrv -I ${service_name} -d "CYGWIN ${service_name}" -p /usr/sbin/sshd \
- -a "-D" -y tcpip "${cygwin_env[@]}" \
+ if /usr/bin/cygrunsrv -I ${service_name} -d "CYGWIN ${service_name}" -p /bin/bash \
+-a "-c '/usr/bin/mkpasswd -l -b > /etc/passwd; /usr/sbin/sshd -D'" \
@kwart
kwart / AzureNode.java
Created June 1, 2016 18:30
JClouds Azure and VM Agent on Windows - TBD
final String nodeName = initialNodeMetadata.getName();
final VirtualMachineApi vmApi = computeServiceContext.unwrapApi(AzureComputeApi.class).getVirtualMachineApiForDeploymentInService(
nodeName,nodeName);
Role role = vmApi.getRole(nodeName);
//recreate role with the provisionGuestAgent=true
vmApi.updateRole(nodeName, role);
@kwart
kwart / azure
Created July 1, 2016 06:22
Azure CLI by using Docker image microsoft/azure-cli (credentials and configuration are stored in extra docker volume)
#!/bin/sh
AZURE_VOLUME=azure-config-volume
# before using this create a Data container for the credentials:
if ! $(docker volume ls -q | grep -q $AZURE_VOLUME); then
echo
echo "Azure configuration doesn't exist!!!"
echo
echo "Creating docker volume to store the configuration"
@kwart
kwart / server.log
Created July 1, 2016 21:35
Issue hit on MS Azure
2016-07-01 16:25:42,767 INFO [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final-redhat-1
2016-07-01 16:25:53,115 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final-redhat-1
2016-07-01 16:25:53,845 INFO [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: JBoss EAP 7.0.0.GA (WildFly Core 2.1.3.Final-redhat-1) starting
2016-07-01 16:25:53,883 DEBUG [org.jboss.as.config] (MSC service thread 1-1) Configured system properties:
[Standalone] =
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
package cz.cacek.javlog.Version;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* This class represents a (number-based) version. It allows to compare the versions. Find the comparison algorithm details in
* {@link #compareTo(Version)} description.
*
@kwart
kwart / SaslFactoriesApiTest.java
Created November 23, 2016 15:16
Black-box testing of SASL factories implementations (Elytron)
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@kwart
kwart / standalone-EXTERNAL-DR19.xml
Created May 26, 2017 19:04
Wildfly - EXTERNAL SASL mechanism configured in Elytron
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:5.0">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.ee"/>
<extension module="org.jboss.as.ejb3"/>