Skip to content

Instantly share code, notes, and snippets.

@jdennaho
jdennaho / RuntimeTargetNamespace.java
Last active December 16, 2015 07:19
set targetNamespace at runtime on JAX-WS proxy when using org.apache.cxf.jaxws.JaxWsProxyFactoryBean
public <T> T getServiceClient(Class<T> interfaceClass, final String targetNamespace) {
JaxWsProxyFactoryBean interfaceFactory = new JaxWsProxyFactoryBean();
interfaceFactory.setServiceFactory(new JaxWsServiceFactoryBean() {
@Override
protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf, Method m) {
intf.setName(new QName(targetNamespace, intf.getName().getLocalPart())); //overwrite the default namespace with target
return super.createOperation(serviceInfo,intf,m);
}
});
}
@jdennaho
jdennaho / SSHDServer.java
Last active April 18, 2021 14:23
How to use a PublickeyAuthenticator with Apache MINA SSHD
private static final String knownKey = "{SSH2.PUBLIC.KEY}";
public void start() {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(22999);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
public boolean authenticate(String username, PublicKey key, ServerSession session) {
if(key instanceof RSAPublicKey) {
@jdennaho
jdennaho / gist:920d44c1f8350ff55801
Created November 3, 2014 22:59
Debugging in JAXB Unmarshalling
//If you need to Debug JAXB this is your ticket.
//Don't use this for production just when debugging.
unmarshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationHandler());
@jdennaho
jdennaho / create-secret-file.groovy
Created May 3, 2016 20:49
Jenkins Credential Binding Plugin: creating a secret file programmatically
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import org.jenkinsci.plugins.plaincredentials.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import org.apache.commons.fileupload.FileItem
//Replace file-id, file-description, filepath and filename with appropriate values for your file