Part 2: OSLC CM only with Jena Framework (simplyfied)

In Part 1 we extend the OSLC Examples with some Jena Code. The reason for this was the problem with
the self signed Certificate of the Jazz Server.
In Part 2 we will change the Trustmanager to accept everything. Details about this at
This is only for testing and not for a productive environment.

package net.jazz.oslc.consumer.examples;

* Thanks to

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.StmtIterator;

* This first example describes how to access to the Root Services document
* (https://localhost:9443/jazz/rootservices) using the Apache HttpClient APIs
* A Jazz Team server must be started.
public class ConnectHttps {

public static void main(String[] args) throws Exception{

//============== Code to adapt to your own configuration =============//
String server = "https://localhost:9443/ccm"; // Set the Public URI of your RTC server

String rootServices = server + "/rootservices";

TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public[] getAcceptedIssuers() {
return null;

public void checkClientTrusted(X509Certificate[] certs, String authType) { }

public void checkServerTrusted(X509Certificate[] certs, String authType) { }


SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new;

// Create all-trusting host name verifier
HostnameVerifier allHostsValid = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
// Install the all-trusting host verifier
* end of the fix

//create Jena Model/Graph
Model model = ModelFactory.createDefaultModel();;
//Print RDF as N3
//model.write(System.out, "N3");

StmtIterator statements = model.listStatements((Resource)null, model.createProperty(""), (RDFNode)null );

//Get workitem catalog
RDFNode object =;




  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: