Skip to content

Instantly share code, notes, and snippets.

View KomanRudden's full-sized avatar

Koman Rudden KomanRudden

  • BMW
  • South Africa
View GitHub Profile
@KomanRudden
KomanRudden / jax-rs jersey
Last active August 29, 2015 13:56
JAX-RS 1.0 Client examples - Jersey
package i.am.koman.wsclients;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import javax.ws.rs.core.MediaType;
public class Jersey_Client {
public static void main(String args[]) {
@KomanRudden
KomanRudden / jax-rs resteasy
Last active August 29, 2015 13:56
JAX-RS 1.0 Client examples - RESTEasy
package i.am.koman.wsclients;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.core.MediaType;
public class RESTEasy_Client {
public static void main(String args[]) throws Exception {
@KomanRudden
KomanRudden / jax-rs apache
Last active August 29, 2015 13:56
JAX-RS 1.0 Client examples - Apache HTTPClient
package i.am.koman.wsclients;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ApacheHTTP_Client {
@KomanRudden
KomanRudden / Password Hashing
Last active July 5, 2019 07:57
Password and Salt hashing
final byte[] hashedPassword = PasswordUtil.getHashedPassword(password, user.getSalt());
String encodedPassword = Base64.encodeBase64String(hashedPassword);
if (user.getPassword() == null || !user.getPassword().equals(encodedPassword)) {
throw new SmartDevicesSalesSecurityException("Incorrect password entered");
}
@KomanRudden
KomanRudden / AdeptraClientService
Last active March 9, 2017 06:15
Mocking Web Service
package za.co.fnb.cbs.plexus.business.service.ejb.adeptra;
import javax.ejb.Stateless;
import za.co.fnb.cbs.plexus.business.service.ws.adeptra.artefacts.Adeptra;
import za.co.fnb.cbs.plexus.business.service.ws.adeptra.artefacts.Adeptra_Service;
import za.co.fnb.cbs.plexus.business.service.ws.adeptra.artefacts.CaseData;
import za.co.fnb.cbs.plexus.business.service.ws.adeptra.artefacts.CaseResponseType;
import za.co.fnb.cbs.plexus.business.service.ws.adeptra.artefacts.CaseResponseType1;
/**
@KomanRudden
KomanRudden / Apache CXF
Last active August 29, 2015 14:23
Apache CXF
If the above "wsdlLocation" doesn't work add "classpath:" before wsdl/adpetra.wsdl.
The above plugin creates the atrefact as below
@WebServiceClient(name = "Adeptra",
wsdlLocation = "wsdl/adeptra.wsdl",
targetNamespace = "http://www.adeptra.net/Adeptra/")
public class Adeptra_Service extends Service {
public final static URL WSDL_LOCATION;
@KomanRudden
KomanRudden / JBoss standalone properties
Created July 6, 2015 08:50
SOAP web service client - binding endpoint url to client
<system-properties>
<property name="adeptra.endpoint.url" value="https://gateway1-cqa.adeptra.eu/fnb/fnbZAFRMOriginations"/>
</system-properties>
@KomanRudden
KomanRudden / Absent Code error - Persistence
Created July 6, 2015 11:39
Persistence Absent Code error
https://developer.jboss.org/blogs/donnamishelly/2011/04/29/jboss-java-ee-api-specs-project
@KomanRudden
KomanRudden / Test logging
Last active February 10, 2016 09:15
Test logging - src/test/resources
Add the log4j.properties file to the src/test/resources folder
@KomanRudden
KomanRudden / Apache CXF JAX-RS Client
Created July 15, 2015 07:42
Apache CXF JAX-RS Client
List<JacksonJsonProvider> providers = new ArrayList<>();
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.addUntouchable(Response.class);
providers.add(provider);
WebClient client = WebClient.create("http://<hostname>/path/to/service", providers);
client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
client.post(myCustomDTO);
//MyCustomDTO will be an object (basic POJO) that can be JSON'd as required
<--Maven Dependencies-->