SOAP SSL + UserNameToken (Java JAX-WS)

SOAPHandler<SOAPMessageContext>
SOAPMessage soapMsg = context.getMessage();
 SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
 SOAPHeader soapHeader = soapEnv.getHeader();
// if no header, add one
 if (soapHeader == null) {
 soapHeader = soapEnv.addHeader();
 }
 SOAPFactory soapFactory = SOAPFactory.newInstance();
// WSSecurity <Security> header
 SOAPElement wsSecHeaderElm = soapFactory.createElement(
 SOAP_ENV_HEADER_LOCAL_NAME,
 SOAP_ENV_HEADER_PRE,
 SOAP_ENV_HEADER_XML_NS);

 SOAPElement userNameTokenElm = soapFactory.createElement(SOAP_ENV_HEADER_USERNAME_TOKEN,
 SOAP_ENV_HEADER_PRE,
 SOAP_ENV_HEADER_XML_NS);

 SOAPElement userNameElm = soapFactory.createElement(SOAP_ENV_HEADER_USERNAME_ELEMENT,
 SOAP_ENV_HEADER_PRE,
 SOAP_ENV_HEADER_XML_NS);

 userNameElm.addTextNode("UserName");
SOAPElement passwdElm = soapFactory.createElement(SOAP_ENV_HEADER_PASSWORD_ELEMENT,
 SOAP_ENV_HEADER_PRE,
 SOAP_ENV_HEADER_XML_NS);
 passwdElm.addTextNode("Password");
userNameTokenElm.addChildElement(userNameElm);
 userNameTokenElm.addChildElement(passwdElm);
// add child elements to the root element
wsSecHeaderElm.addChildElement(userNameTokenElm);
// add SOAP element for header to SOAP header object
soapHeader.addChildElement(wsSecHeaderElm);
soapMsg.saveChanges();
soapMsg.writeTo(System.out);
public final static String SOAP_ENV_HEADER_XML_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
public final static String SOAP_ENV_HEADER_LOCAL_NAME = "Security";
public final static String SOAP_ENV_HEADER_PRE = "wsse";
public final static String SOAP_ENV_HEADER_USERNAME_TOKEN = "UsernameToken";
public final static String SOAP_ENV_HEADER_USERNAME_ELEMENT = "Username";
public final static String SOAP_ENV_HEADER_PASSWORD_ELEMENT = "Password";

import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFactory;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

@WebServiceClient(name = "XMLWayService",
 wsdlLocation = "xmls.wsdl",
 targetNamespace = "http://xmlservice.com")
 @HandlerChain(file = "handler-chain.xml")
 public class XMLService extends Service {
// this doesn't work with jboss eap 6.1
//System.setProperty("javax.xml.bind.JAXBContext",
// "com.sun.xml.internal.bind.v2.ContextFactory");  
 System.setProperty("javax.net.ssl.keyStore", SOAP_KEYSTORE);
 System.setProperty("javax.net.ssl.keyStorePassword", SOAP_KEYSTORE_PASSWORD);
 System.setProperty("javax.net.ssl.trustStore", SOAP_KEYSTORE);
 System.setProperty("javax.net.ssl.trustStorePassword", SOAP_KEYSTORE_PASSWORD);

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <javaee:handler-chains
 xmlns:javaee="http://java.sun.com/xml/ns/javaee"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <javaee:handler-chain>
 <javaee:handler>
 <javaee:handler-class>UserNameTokenInjectHandler</javaee:handler-class>
 </javaee:handler>
 </javaee:handler-chain>
 </javaee:handler-chains>
mvn dependency:tree

 

 

keytool -genkey -alias svs -keyalg RSA -keystore keystore.jks -keysize 2048
Run as JVM parameter in JUnit eclipse
 -Djavax.net.debug=ssl,trustmanager -Djava.net.preferIPv4Stack=true

 

Notes:
-Djavax.net.ssl.keyStore=keystore.jks

http://stackoverflow.com/questions/6908948/java-sun-security-provider-certpath-suncertpathbuilderexception-unable-to-find

maybe cert changed?

http://code.naishe.in/2011/07/looks-like-article-no-more-unable-to.html
http://magicmonster.com/kb/prg/java/ssl/pkix_path_building_failed.html
keytool -list -v -keystore keystore.jks > java_cacerts.txt

keytool -list -v -keystore keystore.jks > java_cacerts.txt

keytool -import -alias example -keystore keystore.jks -file site.der
keytool -import -alias example -keystore keystore.jks -file root.cer

http://stackoverflow.com/questions/14162159/supplying-a-different-version-of-jaxb-for-jax-ws-in-java-1-6

with jaxws-api.jar added to lib/endorsed
System.setProperty(“javax.xml.bind.JAXBContext”,
“com.sun.xml.internal.bind.v2.ContextFactory”);
https://jaxb.java.net/guide/Migrating_JAXB_2_0_applications_to_JavaSE_6.html

-Djavax.net.debug=ssl,trustmanager

 

http://anonsvn.jboss.org/repos/jbossws/stack/cxf/branches/wstrust/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustTestCase.java
http://docs.jboss.org/jbossweb/7.0.x/ssl-howto.html#Download and Install JSSE
https://confluence.atlassian.com/display/JIRAKB/Unable+to+Connect+to+SSL+Services+due+to+PKIX+Path+Building+Failed+sun.security.provider.certpath.SunCertPathBuilderException

standalone.bat

jboss/standalone.conf

https://community.jboss.org/wiki/JBossWS-AS7FAQ
https://community.jboss.org/thread/169148?tstart=0
http://middlewaremagic.com/jboss/?tag=cxf
https://docs.jboss.org/author/display/JBWS/JAX-WS+Tools

jboss-eap-6binwsconsume -k myservice.wsdl

May want:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.2</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>

AutoCompletes

AutoComplete

Every solution needs JavaScript if you are doing auto-complete in your browser.   There’s ways some example libraries out there for JavaScript, JQuery and some other frameworks to easily do an in-browser search.   You can also. You need AJAX or Websockets to make a call to your server implementation.

Example REST Java AutoComplete Server

Creating a Typeahead Widget with AngularJS – SitePoint

Live Search – Ajax Patterns

Autocomplete | jQuery UI

java – Autocomplete using Tries – Stack Overflow

A Simple jQuery Autocomplete Search Tutorial | Arunkumar’s Blog

Create a Simple Autocomplete With HTML5 & jQuery | Design Shack

Programming Assignment: Autocomplete Me

Tries

www.cs.princeton.edu/~rs/strings/paper.pdf

COS 226 Programming Assignment Checklist: Autocomplete

Tries

www.cise.ufl.edu/~sahni/dsaaj/enrich/c16/tries.htm

The Trie Data Structure: Examples in Java | Toptal

Trie – Wikipedia, the free encyclopedia

Tries

Trie Data Structure in Java. | Web problems and solutions.

Trie in Java

Efficient auto-complete with a ternary search tree

ijcsee.org.uk/documents/jyosthna.pdf

 

Non-Tries
Zutto development – The prefix tree: an easily-sortable map implementation for string keys

Suggest Tree: A Data Structure for Efficient Autocomplete

renepickhardt/scored-topk-prefix-retrieval

www.di.unipi.it/~ottavian/files/topk_completion_www13.pdf

Google AutoComplete Suggestions | Yeming Hu’s Homepage

Salmon Run: Three Autocomplete implementations compared

NOSQL
Redis: Implementing Auto Complete or How to build Trie on Redis • myNoSQL

Two ways of using Redis to build a NoSQL autocomplete search index | Architects Zone

javascript – MongoDB + Node.js + AJAX solution for doing autocomplete search – Stack Overflow

Brute Force
Tutorial: Create Autocomplete feature with Java – JSP / jQuery

Spring 3 MVC Autocomplete with JQuery & JSON Tutorial & Example

Hibernate
Hibernate Search based Autocomplete Suggester | Javalobby

SOLR
java – Solr Typeahead feature implementation – Stack Overflow

Querying using autocomplete/spellcheck | DataStax Enterprise 3.2 Documentation

 

 

JBOSS Forge Notes

forge 2.3.0.final

set ACCEPT_DEFAULTS true;

forge install-plugin angularjs
forge install-plugin arquillian

persistence setup –provider HIBERNATE –container JBOSS_AS7

http://www.mastertheboss.com/forge/jboss-forge-tutorial/page-2

https://www.openshift.com/blogs/day-17-jboss-forge-java-ee-6-angularjs-application-on-openshift

forge install-plugin angularjs
scaffold-x setup –scaffoldType angularjs

list-commands –all
help

1.
forge –install core
forge –install shell
forge –install addons
forge –install maven
forge –install javaee

forge –list

[todoapp] todoapp $ forge install-plugin angularjs
Once installed you can set up Angularjs scaffolding by executing the command shown below.

[todoapp] todoapp $ scaffold-x setup –scaffoldType angularjs
This will setup Angularjs in our todoapp. Now we can generate the view for Todo entity.

[todoapp] model $ scaffold-x from Todo.java

new-project –named healthcheck –topLevelPackage com.bn.vfill.healthcheck –finalName healthcheck
set ACCEPT_DEFAULTS true;
persistence setup –provider HIBERNATE –container JBOSS_AS7

Spring Boot with Spring 4 and Spring Data MongoDB

Spring Boot is starting to really look like a great way to start projects.  I have just create a simple project using it and was very impressed.

You can rapidly start up and it’s a nice style of RAD.  It’s not as command-line tool driven as Forge or ROO, but it packs everything you need in a simple

maven or gradle script.

Spring Boot / Spring 4.02 / Spring Data Resources