aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources/src/main')
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLReaderNew.java353
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLWriterNew.java358
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/dbgen/PropertyNameChange.java317
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java142
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java237
5 files changed, 0 insertions, 1407 deletions
diff --git a/aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLReaderNew.java b/aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLReaderNew.java
deleted file mode 100644
index 4f3fee0..0000000
--- a/aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLReaderNew.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.dbgen;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.lang.reflect.Array;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.XMLEvent;
-
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-//import com.infrasight.model.UnicodeUtil;
-import com.thinkaurelius.titan.core.TitanGraph;
-
-/**
- * GraphMLReader writes the data from a GraphML stream to a graph.
- */
-public class GraphMLReaderNew {
- public static final Charset charset = Charset.forName("UTF8");
-
- /**
- * Input the GraphML stream data into the graph.
- * In practice, usually the provided graph is empty.
- *
- * @param graph the graph to populate with the GraphML data
- * @param titanGraph the titan graph
- * @param graphMLInputStream an InputStream of GraphML data
- * @return the map
- * @throws XMLStreamException thrown when the GraphML data is not correctly formatted
- */
- public static Map<String, Object> inputGraph(final Graph graph, final TitanGraph titanGraph, final InputStream graphMLInputStream) throws XMLStreamException {
- return inputGraph(graph, titanGraph, new InputStreamReader(graphMLInputStream, charset), 1000);
- }
-
-/* public static void inputGraphFiltered(final Graph graph, final InputStream graphMLInputStream) throws XMLStreamException {
- inputGraph(graph, UnicodeUtil.createFilteredReader(new InputStreamReader(graphMLInputStream, charset)), 1000);
- }*/
-
- private static class KeySpec {
- String attrName;
- String attrType;
-
- /**
- * Instantiates a new key spec.
- *
- * @param name the name
- * @param type the type
- */
- public KeySpec(String name, String type) {
- this.attrName = name;
- this.attrType = type;
- }
- }
-
- /**
- * Input the GraphML stream data into the graph.
- * More control over how data is streamed is provided by this method.
- *
- * @param graph the graph to populate with the GraphML data
- * @param titanGraph the titan graph
- * @param inputReader an Reader of GraphML character data
- * @param bufferSize the amount of elements to hold in memory before committing a transactions (only valid for TransactionalGraphs)
- * @return the map
- * @throws XMLStreamException thrown when the GraphML data is not correctly formatted
- */
- public static Map<String, Object> inputGraph(final Graph graph, final TitanGraph titanGraph, final Reader inputReader, int bufferSize) throws XMLStreamException {
-
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
- inputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
- inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
- XMLStreamReader reader = inputFactory.createXMLStreamReader(inputReader);
-
- //final BatchGraph<?> graph = BatchGraph.wrap(inputGraph, bufferSize);
-
- Map<String, KeySpec> keyMap = new HashMap<String, KeySpec>();
-
- // Buffered Vertex Data
- String vertexId = null;
- Map<String, Object> vertexProps = null;
- boolean inVertex = false;
-
- // Buffered Edge Data
- String edgeId = null;
- String edgeLabel = null;
- Vertex edgeInVertex = null;
- Vertex edgeOutVertex = null;
- Map<String, Object> edgeProps = null;
- boolean inEdge = false;
- Map<String, Object> vertexIdSetMap = new HashMap<String, Object>();
-
- while (reader.hasNext()) {
-
- Integer eventType = reader.next();
- if (eventType.equals(XMLEvent.START_ELEMENT)) {
- String elementName = reader.getName().getLocalPart();
-
- if (elementName.equals(GraphMLTokens.KEY)) {
- String id = reader.getAttributeValue(null, GraphMLTokens.ID);
- String attributeName = reader.getAttributeValue(null, GraphMLTokens.ATTR_NAME);
- String attributeType = reader.getAttributeValue(null, GraphMLTokens.ATTR_TYPE);
- keyMap.put(id, new KeySpec(attributeName, attributeType));
-
- } else if (elementName.equals(GraphMLTokens.NODE)) {
- vertexId = reader.getAttributeValue(null, GraphMLTokens.ID);
- inVertex = true;
- vertexProps = new HashMap<String, Object>();
-
- } else if (elementName.equals(GraphMLTokens.EDGE)) {
-
-
- edgeId = reader.getAttributeValue(null, GraphMLTokens.ID);
- edgeLabel = reader.getAttributeValue(null, GraphMLTokens.LABEL);
- edgeLabel = edgeLabel == null ? GraphMLTokens._DEFAULT : edgeLabel;
-
- String outVertexId = reader.getAttributeValue(null, GraphMLTokens.SOURCE);
- String inVertexId = reader.getAttributeValue(null, GraphMLTokens.TARGET);
-
- edgeOutVertex = graph.vertices(outVertexId).next();
- edgeInVertex = graph.vertices(inVertexId).next();
-
- if (null == edgeOutVertex) {
- edgeOutVertex = graph.addVertex(outVertexId);
- }
- if (null == edgeInVertex) {
- edgeInVertex = graph.addVertex(inVertexId);
- }
-
- inEdge = true;
- edgeProps = new HashMap<String, Object>();
-
- } else if (elementName.equals(GraphMLTokens.DATA)) {
- String key = reader.getAttributeValue(null, GraphMLTokens.KEY);
- KeySpec keySpec = keyMap.get(key);
-
- if (keySpec != null) {
- Object value = readData(reader, keySpec.attrType);
- if(value == null)
- throw new RuntimeException("Empty data");
- if (inVertex == true) {
- vertexProps.put(keySpec.attrName, value);
- } else if (inEdge == true) {
- edgeProps.put(keySpec.attrName, value);
- }
- }
-
- }
- } else if (eventType.equals(XMLEvent.END_ELEMENT)) {
- String elementName = reader.getName().getLocalPart();
-
- if (elementName.equals(GraphMLTokens.NODE)) {
-
- Vertex currentVertex = graph.vertices(vertexId).next();
- if (currentVertex != null)
- throw new RuntimeException("Duplicate vertex ID: "+vertexId);
- currentVertex = graph.addVertex(vertexId);
- Boolean hasCollection = false;
- for (Entry<String, Object> prop : vertexProps.entrySet()) {
- // multi-properties need a addProperty and need to use a TitanVertex - BluePrint
- // Vertex does not support this
- Object value = prop.getValue();
- if (value instanceof Collection) {
- hasCollection = true;
- vertexIdSetMap.put(currentVertex.id().toString() + "." + prop.getKey(), vertexProps);
- currentVertex.property("has-collection", "true");
- } else {
- currentVertex.property(prop.getKey(), value);
- }
- }
- if (hasCollection)
- System.out.println("---Found node with SET property vertex id:" + vertexId + " properties:" + vertexProps.toString());
- vertexId = null;
- vertexProps = null;
- inVertex = false;
- } else if (elementName.equals(GraphMLTokens.EDGE)) {
- Edge currentEdge = edgeOutVertex.addEdge(edgeLabel, edgeInVertex);
- //addEdge(edgeId, edgeOutVertex, edgeInVertex, edgeLabel);
-
- for (Entry<String, Object> prop : edgeProps.entrySet()) {
- currentEdge.property(prop.getKey(), prop.getValue());
- }
-
- edgeId = null;
- edgeLabel = null;
- edgeInVertex = null;
- edgeOutVertex = null;
- edgeProps = null;
- inEdge = false;
- }
-
- }
-
- }
-
- reader.close();
- graph.tx().close();
-
- return vertexIdSetMap;
-
- }
-
- /**
- * Read data.
- *
- * @param reader the reader
- * @param type the type
- * @return the object
- * @throws XMLStreamException the XML stream exception
- */
- private static Object readData(XMLStreamReader reader, String type) throws XMLStreamException {
- Collection<Object> col = new ArrayList<Object>();
-
- int pos = type.indexOf('-');
- if(pos < 0)
- return typeCastValue(reader.getElementText(), type);
- String arrayType = type.substring(0, pos);
- type = type.substring(pos+1);
-
- boolean done = false;
- while(!done) {
- Integer eventType = reader.next();
- if(eventType.equals(XMLEvent.START_ELEMENT)) {
- String text = reader.getElementText();
- Object value = typeCastValue(text, type);
- col.add(value);
- }
- if(eventType.equals(XMLEvent.END_ELEMENT)) {
- String elementName = reader.getName().getLocalPart();
- if(elementName.equals(GraphMLTokens.DATA)) {
- done = true;
- continue;
- }
- }
- }
-
- if(arrayType.equals(GraphMLTokens.ARRAY)) {
- Object arr = Array.newInstance(typeToClass(type), col.size());
- int i = 0;
- for(Object obj : col) {
- Array.set(arr, i, obj);
- i++;
- }
- return arr;
- }
- else if(arrayType.equals(GraphMLTokens.SET))
- return new HashSet<Object>(col);
- else if(type.startsWith(GraphMLTokens.LIST))
- return new HashSet<Object>(col);
-
- return col;
- }
-
- /**
- * Type to class.
- *
- * @param type the type
- * @return the class
- */
- private static Class<?> typeToClass(String type) {
- if (type.equals(GraphMLTokens.STRING))
- return String.class;
- else if (type.equals(GraphMLTokens.FLOAT))
- return Float.TYPE;
- else if (type.equals(GraphMLTokens.INT))
- return Integer.TYPE;
- else if (type.equals(GraphMLTokens.DOUBLE))
- return Double.TYPE;
- else if (type.equals(GraphMLTokens.BOOLEAN))
- return Boolean.TYPE;
- else if (type.equals(GraphMLTokens.LONG))
- return Long.TYPE;
- else
- throw new RuntimeException("Unsupported type: "+type);
- }
-
- /**
- * Type cast value.
- *
- * @param value the value
- * @param type the type
- * @return the object
- */
- private static Object typeCastValue(String value, String type) {
- if (type.equals(GraphMLTokens.STRING))
- return value;
- else if (type.equals(GraphMLTokens.FLOAT))
- return Float.valueOf(value);
- else if (type.equals(GraphMLTokens.INT))
- return Integer.valueOf(value);
- else if (type.equals(GraphMLTokens.DOUBLE))
- return Double.valueOf(value);
- else if (type.equals(GraphMLTokens.BOOLEAN))
- return Boolean.valueOf(value);
- else if (type.equals(GraphMLTokens.LONG))
- return Long.valueOf(value);
- else
- throw new RuntimeException("Unsupported type: "+type);
- }
-
-/* TitanVertex titanVertex = (TitanVertex) titanGraph.getVertex(vertexId);
- if (titanVertex != null)
- throw new RuntimeException("Duplicate vertex ID: "+vertexId);
- titanVertex = (TitanVertex) titanGraph.addVertex(vertexId);
- for (Entry<String, Object> prop : vertexProps.entrySet()) {
- // multi-properties need a addProperty and need to use a TitanVertex - BluePrint
- // Vertex does not support this
- Object value = prop.getValue();
- if (value instanceof Collection) {
- try {
- for(Object obj : ((Collection<?>)value)) {
- System.out.println("vertex id:property name:property value="+ vertexId + ":" + prop.getKey() + ":" + obj.toString());
- titanVertex.addProperty(prop.getKey(), obj.toString());
- }
- }
- catch (Exception e) {
- System.out.println("Can't set SET/LIST properties - skipping");
- }
-
- } else
- titanVertex.setProperty(prop.getKey(), prop.getValue());
- }*/
-}
diff --git a/aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLWriterNew.java b/aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLWriterNew.java
deleted file mode 100644
index 1704428..0000000
--- a/aai-resources/src/main/java/org/openecomp/aai/dbgen/GraphMLWriterNew.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.dbgen;
-
-
-import java.io.OutputStream;
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-
-/**
- * GraphMLWriter writes a Graph to a GraphML OutputStream.
- */
-public class GraphMLWriterNew {
-
- private static class KeySpec {
- String attrName;
- String attrType;
-
- /**
- * Instantiates a new key spec.
- *
- * @param name the name
- * @param type the type
- */
- public KeySpec(String name, String type) {
- this.attrName = name;
- this.attrType = type;
- }
- }
-
- /**
- * Write the data in a Graph to a GraphML OutputStream.
- *
- * @param graph the Graph to pull the data from
- * @param graphMLOutputStream the GraphML OutputStream to write the Graph data to
- * @throws XMLStreamException thrown if there is an error generating the GraphML data
- */
- public static void outputGraph(final Graph graph, final OutputStream graphMLOutputStream) throws XMLStreamException {
- Map<String, KeySpec> vertexKeyTypes = new HashMap<String, KeySpec>();
- Map<String, KeySpec> edgeKeyTypes = new HashMap<String, KeySpec>();
-
-
- Iterator<Vertex> vertices = graph.vertices();
- Vertex vertex = null;
- Iterator<VertexProperty<Object>> propertyIterator = null;
- VertexProperty<Object> property = null;
- while (vertices.hasNext()) {
- vertex = vertices.next();
- propertyIterator = vertex.properties();
- while (propertyIterator.hasNext()) {
- property = propertyIterator.next();
- Object value = property.value();
- String key = property.key();
- if(value == null)
- continue;
- String type = getStringType(value);
- if(type == null)
- continue;
- String id = key+"-"+type;
- if (!vertexKeyTypes.containsKey(id)) {
- vertexKeyTypes.put(id, new KeySpec(key, type));
- }
- }
- }
- Iterator<Edge> edges = graph.edges();
- Edge edge = null;
- Iterator<Property<Object>> edgePropertyIterator = null;
- Property<Object> edgeProperty = null;
-
- while (edges.hasNext()) {
- edge = edges.next();
- edgePropertyIterator = edge.properties();
- while (edgePropertyIterator.hasNext()) {
- edgeProperty = edgePropertyIterator.next();
- Object value = edgeProperty.value();
- String key = edgeProperty.key();
- if(value == null)
- continue;
- String type = getStringType(value);
- if(type == null)
- continue;
- String id = key+"-"+type;
- if (!edgeKeyTypes.containsKey(id)) {
- edgeKeyTypes.put(id, new KeySpec(key, type));
- }
- }
- }
- outputGraph(graph, graphMLOutputStream, vertexKeyTypes, edgeKeyTypes);
- }
-
- /**
- * Write the data in a Graph to a GraphML OutputStream.
- *
- * @param graph the Graph to pull the data from
- * @param graphMLOutputStream the GraphML OutputStream to write the Graph data to
- * @param vertexKeyTypes a Map of the data types of the vertex keys
- * @param edgeKeyTypes a Map of the data types of the edge keys
- * @throws XMLStreamException thrown if there is an error generating the GraphML data
- */
- public static void outputGraph(final Graph graph, final OutputStream graphMLOutputStream, final Map<String, KeySpec> vertexKeyTypes, final Map<String, KeySpec> edgeKeyTypes) throws XMLStreamException {
- XMLOutputFactory inputFactory = XMLOutputFactory.newInstance();
- XMLStreamWriter writer = inputFactory.createXMLStreamWriter(graphMLOutputStream, "UTF8");
-
- writer.writeStartDocument("UTF-8", "1.0");
- writer.writeStartElement(GraphMLTokens.GRAPHML);
- writer.writeAttribute(GraphMLTokens.XMLNS, GraphMLTokens.GRAPHML_XMLNS);
- //<key id="weight" for="edge" attr.name="weight" attr.type="float"/>
- for (Map.Entry<String, KeySpec> entry : vertexKeyTypes.entrySet()) {
- writer.writeStartElement(GraphMLTokens.KEY);
- writer.writeAttribute(GraphMLTokens.ID, entry.getKey());
- writer.writeAttribute(GraphMLTokens.FOR, GraphMLTokens.NODE);
- writer.writeAttribute(GraphMLTokens.ATTR_NAME, entry.getValue().attrName);
- writer.writeAttribute(GraphMLTokens.ATTR_TYPE, entry.getValue().attrType);
- writer.writeEndElement();
- }
- for (Map.Entry<String, KeySpec> entry : edgeKeyTypes.entrySet()) {
- writer.writeStartElement(GraphMLTokens.KEY);
- writer.writeAttribute(GraphMLTokens.ID, entry.getKey());
- writer.writeAttribute(GraphMLTokens.FOR, GraphMLTokens.EDGE);
- writer.writeAttribute(GraphMLTokens.ATTR_NAME, entry.getValue().attrName);
- writer.writeAttribute(GraphMLTokens.ATTR_TYPE, entry.getValue().attrType);
- writer.writeEndElement();
- }
-
- writer.writeStartElement(GraphMLTokens.GRAPH);
- writer.writeAttribute(GraphMLTokens.ID, GraphMLTokens.G);
- writer.writeAttribute(GraphMLTokens.EDGEDEFAULT, GraphMLTokens.DIRECTED);
- Iterator<Vertex> vertices = graph.vertices();
- Vertex vertex = null;
- Iterator<VertexProperty<Object>> propertyIterator = null;
- VertexProperty<Object> property = null;
- while (vertices.hasNext()) {
- vertex = vertices.next();
- writer.writeStartElement(GraphMLTokens.NODE);
- writer.writeAttribute(GraphMLTokens.ID, vertex.id().toString());
- propertyIterator = vertex.properties();
- while (propertyIterator.hasNext()) {
- property = propertyIterator.next();
- String key = property.key();
- writeData(writer, key, property.value());
- }
- writer.writeEndElement();
- }
-
- Iterator<Edge> edges = graph.edges();
- Edge edge = null;
- Iterator<Property<Object>> edgePropertyIterator = null;
- Property<Object> edgeProperty = null;
-
- while (edges.hasNext()) {
- edge = edges.next();
- edgePropertyIterator = edge.properties();
- writer.writeStartElement(GraphMLTokens.EDGE);
- writer.writeAttribute(GraphMLTokens.ID, edge.id().toString());
- writer.writeAttribute(GraphMLTokens.SOURCE, edge.outVertex().id().toString());
- writer.writeAttribute(GraphMLTokens.TARGET, edge.inVertex().id().toString());
- writer.writeAttribute(GraphMLTokens.LABEL, edge.label());
-
- while (edgePropertyIterator.hasNext()) {
- edgeProperty = edgePropertyIterator.next();
- String key = edgeProperty.key();
- writeData(writer, key, edgeProperty.value());
- }
- writer.writeEndElement();
- }
-
- writer.writeEndElement(); // graph
- writer.writeEndElement(); // graphml
- writer.writeEndDocument();
-
- writer.flush();
- writer.close();
-
- }
-
- /**
- * Write data.
- *
- * @param writer the writer
- * @param key the key
- * @param value the value
- * @throws XMLStreamException the XML stream exception
- */
- private static void writeData(XMLStreamWriter writer, String key, Object value) throws XMLStreamException {
- if(value == null)
- return;
- String type = getStringType(value);
- if(type == null)
- return;
- String id = key+"-"+type;
-
- writer.writeStartElement(GraphMLTokens.DATA);
- writer.writeAttribute(GraphMLTokens.KEY, id);
- if(type.startsWith(GraphMLTokens.ARRAY) ||
- type.startsWith(GraphMLTokens.LIST) ||
- type.startsWith(GraphMLTokens.SET))
- writeDataArray(writer, value);
- else
- writer.writeCharacters(propertyValueToString(value));
- writer.writeEndElement();
- }
-
- /**
- * Write data array.
- *
- * @param writer the writer
- * @param value the value
- * @throws XMLStreamException the XML stream exception
- */
- private static void writeDataArray(XMLStreamWriter writer, Object value) throws XMLStreamException {
- if(value.getClass().isArray()) {
- for(int i = 0; i < Array.getLength(value); i++) {
- writer.writeStartElement(GraphMLTokens.ITEM);
- writer.writeCharacters(Array.get(value, i).toString());
- writer.writeEndElement();
- }
- }
- else if(value instanceof Collection) {
- for(Object obj : ((Collection<?>)value)) {
- writer.writeStartElement(GraphMLTokens.ITEM);
- writer.writeCharacters(obj.toString());
- writer.writeEndElement();
- }
- }
- }
-
- /**
- * Gets the string type.
- *
- * @param object the object
- * @return the string type
- */
- private static String getStringType(final Object object) {
- if(object.getClass().isArray())
- return GraphMLTokens.ARRAY+"-"+getStringType(object.getClass().getComponentType());
- if(object instanceof Collection) {
- String colType;
- if(object instanceof Set)
- colType = GraphMLTokens.SET;
- else if(object instanceof List)
- colType = GraphMLTokens.LIST;
- else
- throw new RuntimeException("Unhandled Collection type: "+object.getClass());
-
- Collection<?> col = (Collection<?>)object;
- if(col.size() == 0)
- return null;
- return colType+"-"+getStringType(col.iterator().next());
- }
- if (object instanceof String)
- return GraphMLTokens.STRING;
- else if (object instanceof Integer)
- return GraphMLTokens.INT;
- else if (object instanceof Long)
- return GraphMLTokens.LONG;
- else if (object instanceof Float)
- return GraphMLTokens.FLOAT;
- else if (object instanceof Double)
- return GraphMLTokens.DOUBLE;
- else if (object instanceof Boolean)
- return GraphMLTokens.BOOLEAN;
- else
- throw new RuntimeException("Unsupported type: "+object.getClass());
- }
-
- /**
- * Gets the string type.
- *
- * @param clazz the clazz
- * @return the string type
- */
- private static String getStringType(final Class<?> clazz) {
- if(clazz.equals(String.class))
- return GraphMLTokens.STRING;
- else if(clazz.equals(Integer.TYPE) || clazz.equals(Integer.class))
- return GraphMLTokens.INT;
- else if(clazz.equals(Long.TYPE) || clazz.equals(Long.class))
- return GraphMLTokens.LONG;
- else if(clazz.equals(Float.TYPE) || clazz.equals(Float.class))
- return GraphMLTokens.FLOAT;
- else if(clazz.equals(Double.TYPE) || clazz.equals(Double.class))
- return GraphMLTokens.DOUBLE;
- else if(clazz.equals(Boolean.TYPE) || clazz.equals(Boolean.class))
- return GraphMLTokens.BOOLEAN;
- else
- throw new RuntimeException("Unsupported array item type: "+clazz);
- }
-
- /**
- * Property value to string.
- *
- * @param value the value
- * @return the string
- */
- private static String propertyValueToString(Object value) {
- if(value == null)
- return null;
-
- if(value.getClass().isArray()) {
- String str = "[";
- for(int i = 0; i < Array.getLength(value); i++) {
- if(i > 0)
- str += ", ";
- str += Array.get(value, i);
- }
- str += "]";
- return str;
- }
- else if(value instanceof Collection) {
- String str = "[";
- int i = 0;
- for(Object obj : ((Collection<?>)value)) {
- if(i > 0)
- str += ", ";
- str += obj.toString();
- i++;
- }
- str += "]";
- return str;
- }
- return value.toString();
- }
-
-}
diff --git a/aai-resources/src/main/java/org/openecomp/aai/dbgen/PropertyNameChange.java b/aai-resources/src/main/java/org/openecomp/aai/dbgen/PropertyNameChange.java
deleted file mode 100644
index 3f7f351..0000000
--- a/aai-resources/src/main/java/org/openecomp/aai/dbgen/PropertyNameChange.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.dbgen;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-
-import org.openecomp.aai.dbmap.AAIGraph;
-import org.openecomp.aai.logging.ErrorLogHelper;
-import org.openecomp.aai.util.AAIConfig;
-import org.openecomp.aai.util.AAIConstants;
-import com.att.eelf.configuration.Configuration;
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanProperty;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
-
-
-public class PropertyNameChange {
-
- /**
- * The main method.
- *
- * @param args the arguments
- */
- public static void main(String[] args) {
-
- // Set the logging file properties to be used by EELFManager
- Properties props = System.getProperties();
- props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_SCHEMA_MOD_LOGBACK_PROPS);
- props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
-
- // NOTE -- We're just working with properties that are used for NODES for now.
-
- TitanGraph graph = null;
- TitanManagement graphMgt = null;;
- Boolean preserveData = true;
- String propName = "";
- String targetPropName = "";
- String targetNodeType = "";
- String skipCommit = "";
- boolean noCommit = false;
-
-
- String usageString = "Usage: PropertyNameChange propertyName targetPropertyName nodeType(or NA) skipCommit(true|false) \n";
- if( args.length != 4 ){
- String emsg = "Four Parameters are required. \n" + usageString;
- System.out.println( emsg );
- System.exit(1);
- }
- else {
- propName = args[0];
- targetPropName = args[1];
- targetNodeType = args[2];
- skipCommit = args[3];
- if ( skipCommit.toLowerCase().equals("true"))
- noCommit = true;
- }
-
- if( propName.equals("") ){
- String emsg = "Bad parameter - propertyName cannot be empty. \n" + usageString;
- System.out.println( emsg );
- System.exit(1);
- }
-
-
-
- try {
- AAIConfig.init();
- ErrorLogHelper.loadProperties();
- }
- catch( Exception ae ){
- String emsg = "Problem with either AAIConfig.init() or ErrorLogHelper.LoadProperties(). ";
- System.out.println( emsg + "[" + ae.getMessage() + "]");
- System.exit(1);
- }
-
-
- System.out.println(">>> Processing will begin in 5 seconds (unless interrupted). <<<");
- try {
- // Give them a chance to back out of this
- Thread.sleep(5000);
- } catch ( java.lang.InterruptedException ie) {
- System.out.println( " DB Schema Update has been aborted. ");
- System.exit(1);
- }
-
- try {
- System.out.println(" ---- NOTE --- about to open graph (takes a little while)\n");
-
- graph = AAIGraph.getInstance().getGraph();
- if( graph == null ){
- String emsg = "Not able to get a graph object in SchemaMod.java\n";
- System.out.println( emsg );
- System.exit(1);
- }
-
- // Make sure this property is in the DB.
- graphMgt = graph.openManagement();
- if( graphMgt == null ){
- String emsg = "Not able to get a graph Management object in SchemaMod.java\n";
- System.out.println( emsg );
- System.exit(1);
- }
- PropertyKey origPropKey = graphMgt.getPropertyKey(propName);
- if( origPropKey == null ){
- String emsg = "The propName = [" + propName + "] is not defined in our graph. ";
- System.out.println( emsg );
- System.exit(1);
- }
- origPropKey = graphMgt.getPropertyKey(targetPropName);
- if( origPropKey == null ){
- String emsg = "The targetPropName = [" + targetPropName + "] is not defined in our graph. ";
- System.out.println( emsg );
- System.exit(1);
- }
-
- if ( !targetNodeType.equals("NA")) {
- if ( graphMgt.getVertexLabel(targetNodeType) == null ) {
- String emsg = "The targetNodeType = [" + targetNodeType + "] is not defined in our graph. ";
- System.out.println( emsg );
- System.exit(1);
- }
- }
-
- // For each node that has this property, update the new from the old and then remove the
- // old property from that node
- Iterable<TitanVertex> verts = null;
- int vtxCount = 0;
- String label;
- long longId;
-
- int propertyCount;
-
- Iterator<VertexProperty<Object>> titanProperties = null;
-
- VertexProperty<Object> tmpProperty = null;
- Object origVal;
- Object targetVal;
-
- if ( targetNodeType.equals("NA")) {
- verts= graph.query().has(propName).vertices();
- Iterator<TitanVertex> it = verts.iterator();
-
- while( it.hasNext() ){
-
- TitanVertex tmpVtx = (TitanVertex)it.next();
- String tmpVid = tmpVtx.id().toString();
-
- origVal = tmpVtx.<Object>property(propName).orElse(null);
- targetVal = tmpVtx.<Object>property(targetPropName).orElse(null);
-
- label = tmpVtx.label();
- longId = tmpVtx.longId();
-
- if ( targetVal != null ) {
- System.out.println( "vertex [" + label + "] id " + tmpVid + " has " + targetPropName +
- " with value " + targetVal + ", skip adding with value " + origVal);
- continue;
- }
- vtxCount++;
- titanProperties = tmpVtx.properties(); // current properties
-
- propertyCount = 0;
-
- while( titanProperties.hasNext() ){
-
- tmpProperty = titanProperties.next();
-
- if ( propertyCount == 0 )
- System.out.print( "adding to [" + label + "] vertex id " + tmpVid + " with existing properties " +
- tmpProperty.toString() );
- else
- System.out.print(", " + tmpProperty.toString());
- ++propertyCount;
- }
-
- if ( propertyCount > 0 ) {
- System.out.println("");
-
- tmpVtx.property(targetPropName,origVal);
- System.out.println("INFO -- just did the add using " + longId +
- " with label " + label + "] and updated it with the orig value (" +
- origVal.toString() + ")");
- titanProperties = tmpVtx.properties(); // current properties
- propertyCount = 0;
-
-
- while( titanProperties.hasNext() ){
- tmpProperty = titanProperties.next();
- if ( propertyCount == 0 )
- System.out.print( "new property list for [" + label + "] vertex id " + tmpVid + " with existing properties " +
- tmpProperty.toString() );
- else
- System.out.print(", " + tmpProperty.toString());
- ++propertyCount;
- }
-
- if ( propertyCount > 0 )
- System.out.println("");
- }
- }
- } else {
- // targetNodeType is NA
-
- verts= graph.query().has("aai-node-type", targetNodeType).vertices();
- if( verts != null ){
- // We did find some matching vertices
- Iterator <?> it = verts.iterator();
- Object propVal;
- while( it.hasNext() ){
- TitanVertex v = (TitanVertex)it.next();
- label = v.label();
- longId = v.longId();
- targetVal = v.<Object>property(targetPropName).orElse(null);
- origVal = v.<Object>property(propName).orElse(null);
-
- if ( origVal == null)
- continue;
-
- if ( targetVal != null ) {
- System.out.println( "vertex [" + label + "] id " + longId + " has " + targetPropName +
- " with value " + targetVal + ", skip adding with value " + origVal);
- continue;
- }
- titanProperties = v.properties(); // current properties
- propertyCount = 0;
- if ( v.<Object>property(propName).orElse(null) != null ) {
- propVal = v.<Object>property(propName).orElse(null);
- v.property(targetPropName, propVal);
- ++vtxCount;
- while( titanProperties.hasNext() ){
-
- tmpProperty = titanProperties.next();
- if ( propertyCount == 0 )
- System.out.print( "adding to vertex id " + longId + " with existing properties " +
- tmpProperty.toString() );
- else
- System.out.print(", " + tmpProperty.toString());
- ++propertyCount;
- }
-
- if ( propertyCount > 0 )
- System.out.println("");
- System.out.println("INFO -- just did the add target [" + targetNodeType + "] using " + longId +
- " with label " + label + "] and updated it with the orig value (" +
- propVal.toString() + ")");
- propertyCount = 0;
- while( titanProperties.hasNext() ){
-
- tmpProperty = titanProperties.next();
- if ( propertyCount == 0 )
- System.out.print( "new property list for vertex [" + label + "] id " + longId + " with existing properties " +
- tmpProperty.toString() );
- else
- System.out.print(", " + tmpProperty.toString());
- ++propertyCount;
- }
-
- if ( propertyCount > 0 )
- System.out.println("");
- }
- }
- }
-
- }
-
- System.out.println("added properties data for " + vtxCount + " vertexes. noCommit " + noCommit);
- if ( !noCommit )
- graph.tx().commit();
- }
- catch (Exception ex) {
- System.out.print("Threw a regular Exception:\n");
- System.out.println(ex.getMessage());
- }
- finally {
- if( graphMgt != null && graphMgt.isOpen() ){
- // Any changes that worked correctly should have already done their commits.
- graphMgt.rollback();
- }
- if( graph != null ){
- // Any changes that worked correctly should have already done their commits.
- graph.tx().rollback();
- graph.close();
- }
- }
-
- System.exit(0);
-
- }// End of main()
-
-
-}
-
-
diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java b/aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java
deleted file mode 100644
index dd72530..0000000
--- a/aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.util;
-
-import java.io.FileWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import org.openecomp.aai.audit.ListEndpoints;
-import org.openecomp.aai.introspection.Version;
-
-public class GenerateMethodMapper {
-
- private final static String filePath = "bundleconfig-local/etc/appprops/methodMapper.properties";
-
- /**
- * The main method.
- *
- * @param args the arguments
- * @throws Exception the exception
- */
- public static void main(String[] args) throws Exception {
-
- ListEndpoints le = null;
- JSONObject jo = new JSONObject();
- JSONArray ja = new JSONArray();
-
- for (Version version : Version.values()) {
-
- le = new ListEndpoints(version);
- Map<String, String> ln = le.getLogicalNames();
- List<String> keys = new ArrayList<String>(ln.keySet());
- Collections.sort(keys);
- for (String key : keys) {
- addEndpointToJsonArray(key, ln.get(key), ja, version.toString());
- }
-
- }
-
- addUniqueEndpoints(ja);
-
- jo.put("ActiveAndAvailableInventory-CloudNetwork", ja);
- try (FileWriter file = new FileWriter(filePath)) {
- file.write(jo.toString(4));
- }
-
- System.exit(0);
-
- }
-
- /**
- * Adds the unique endpoints.
- *
- * @param ja the ja
- * @throws JSONException the JSON exception
- */
- private static void addUniqueEndpoints(JSONArray ja) throws JSONException {
- JSONObject joItem = new JSONObject();
- joItem.put("url", "/aai/{version}/service-design-and-creation/models*");
- joItem.put("method", "get");
- joItem.put("logicalName", "GetModel");
- ja.put(joItem);
- joItem = new JSONObject();
- joItem.put("url", "/aai/{version}/service-design-and-creation/models*");
- joItem.put("method", "put");
- joItem.put("logicalName", "PutModel");
- ja.put(joItem);
- joItem = new JSONObject();
- joItem.put("url", "/aai/{version}/service-design-and-creation/models*");
- joItem.put("method", "delete");
- joItem.put("logicalName", "DeleteModel");
- ja.put(joItem);
- joItem = new JSONObject();
- joItem.put("url", "/aai/{version}/service-design-and-creation/named-queries/*");
- joItem.put("method", "get");
- joItem.put("logicalName", "GetNamedQuery");
- ja.put(joItem);
- }
-
- /**
- * Adds the endpoint to json array.
- *
- * @param url the url
- * @param name the name
- * @param ja the ja
- * @param apiVersion the api version
- * @throws JSONException the JSON exception
- */
- private static void addEndpointToJsonArray(String url, String name, JSONArray ja, String apiVersion)
- throws JSONException {
-
- JSONObject joGet = new JSONObject();
- JSONObject joPut = new JSONObject();
- JSONObject joDel = new JSONObject();
-
- if (!url.endsWith("relationship")) {
- joGet.put("url", url);
- joGet.put("method", "get");
- joGet.put("logicalName", apiVersion + "Get" + name);
- ja.put(joGet);
- }
-
- if (url.endsWith("}") || url.endsWith("relationship")) {
- joPut.put("url", url);
- joPut.put("method", "put");
- joPut.put("logicalName", apiVersion + "Put" + name);
- ja.put(joPut);
-
- joDel.put("url", url);
- joDel.put("method", "delete");
- joDel.put("logicalName", apiVersion + "Delete" + name);
- ja.put(joDel);
-
- }
-
- }
-
-}
diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java b/aai-resources/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
deleted file mode 100644
index 000ebd0..0000000
--- a/aai-resources/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.util;
-
-import java.io.FileInputStream;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-
-import org.openecomp.aai.domain.yang.Customers;
-import org.openecomp.aai.exceptions.AAIException;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.client.filter.LoggingFilter;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.client.urlconnection.HTTPSProperties;
-
-import static java.util.Base64.getEncoder;
-
-public class HttpsAuthClient{
-
- /**
- * The main method.
- *
- * @param args the arguments
- */
- public static void main(String[] args) {
- try {
- String url = AAIConfig.get(AAIConstants.AAI_SERVER_URL) + "business/customers";
- System.out.println("Making Jersey https call...");
- Client client = HttpsAuthClient.getTwoWaySSLClient();
-
- ClientResponse res = client.resource(url)
- .accept("application/json")
- .header("X-TransactionId", "PROV001")
- .header("X-FromAppId", "AAI")
- .type("application/json")
- .get(ClientResponse.class);
-
-// System.out.println("Jersey result: ");
-// System.out.println(res.getEntity(String.class).toString());
-
- Customers customers = res.getEntity(Customers.class);
- System.out.println("Jersey result: ");
- System.out.println("Number of customers: " + customers.getCustomer().size());
-
- } catch (KeyManagementException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * Gets the client.
- *
- * @return the client
- * @throws KeyManagementException the key management exception
- */
- public static Client getTwoWaySSLClient() throws KeyManagementException {
-
- ClientConfig config = new DefaultClientConfig();
- config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
- config.getClasses().add(org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider.class);
-
- SSLContext ctx = null;
- try {
- String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
- String truststore_password = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
- String keystore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
- String keystore_password = AAIConfig.get(AAIConstants.AAI_KEYSTORE_PASSWD);
-
- System.setProperty("javax.net.ssl.trustStore", truststore_path);
- System.setProperty("javax.net.ssl.trustStorePassword", truststore_password);
- HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
- public boolean verify(String string,SSLSession ssls) {
- return true;
- }
- });
-
- ctx = SSLContext.getInstance("TLSv1.2");
- KeyManagerFactory kmf = null;
- try {
- kmf = KeyManagerFactory.getInstance("SunX509");
- FileInputStream fin = new FileInputStream(keystore_path);
- KeyStore ks = KeyStore.getInstance("PKCS12");
- char[] pwd = keystore_password.toCharArray();
- ks.load(fin, pwd);
- kmf.init(ks, pwd);
- } catch (Exception e) {
- System.out.println("Error setting up kmf: exiting");
- e.printStackTrace();
- System.exit(1);
- }
-
- ctx.init(kmf.getKeyManagers(), null, null);
- config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new HTTPSProperties( new HostnameVerifier() {
- @Override
- public boolean verify( String s, SSLSession sslSession ) {
- return true;
- }
- }, ctx));
- } catch (Exception e) {
- System.out.println("Error setting up config: exiting");
- e.printStackTrace();
- System.exit(1);
- }
-
- Client client = Client.create(config);
- // uncomment this line to get more logging for the request/response
- // client.addFilter(new LoggingFilter(System.out));
-
- return client;
- }
-
- public static Client getBasicAuthClient() throws AAIException {
-
- String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
- System.setProperty("javax.net.ssl.trustStore", truststore_path);
-
- javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {
- public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
- return true;
- }
- });
-
- String userName = AAIConfig.get("aai.tools.username");
- String password = AAIConfig.get("aai.tools.password");
- // ClientConfig config = new DefaultClientConfig();
- Client client = Client.create();
- //client.addFilter(new HTTPBasicAuthFilter(userName, password));
-
-
-
-
- return client;
- }
-
- public static String getBasicAuthHeaderValue() throws AAIException {
-
-
- String userName = AAIConfig.get("aai.tools.username", "");
- String password = AAIConfig.get("aai.tools.password", "");
- String authString = userName + ":" + password;
- byte[] s = getEncoder().encode(authString.getBytes());
- String basicauthStringEnc = new String(s);
-
- return "Basic " + basicauthStringEnc;
-
- }
-
-
- public static Client getClient() throws KeyManagementException {
-
- ClientConfig config = new DefaultClientConfig();
- config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
- config.getClasses().add(org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider.class);
-
- SSLContext ctx = null;
- try {
- String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
- String truststore_password = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
- String keystore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
- String keystore_password = AAIConfig.get(AAIConstants.AAI_KEYSTORE_PASSWD);
-
- System.setProperty("javax.net.ssl.trustStore", truststore_path);
- System.setProperty("javax.net.ssl.trustStorePassword", truststore_password);
- HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
- public boolean verify(String string,SSLSession ssls) {
- return true;
- }
- });
-
- ctx = SSLContext.getInstance("TLSv1.2");
- KeyManagerFactory kmf = null;
- try {
- kmf = KeyManagerFactory.getInstance("SunX509");
- FileInputStream fin = new FileInputStream(keystore_path);
- KeyStore ks = KeyStore.getInstance("PKCS12");
- char[] pwd = keystore_password.toCharArray();
- ks.load(fin, pwd);
- kmf.init(ks, pwd);
- } catch (Exception e) {
- System.out.println("Error setting up kmf: exiting");
- e.printStackTrace();
- System.exit(1);
- }
-
- ctx.init(kmf.getKeyManagers(), null, null);
- config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new HTTPSProperties( new HostnameVerifier() {
- @Override
- public boolean verify( String s, SSLSession sslSession ) {
- return true;
- }
- }, ctx));
- } catch (Exception e) {
- System.out.println("Error setting up config: exiting");
- e.printStackTrace();
- System.exit(1);
- }
-
- Client client = Client.create(config);
- // uncomment this line to get more logging for the request/response
- // client.addFilter(new LoggingFilter(System.out));
-
- return client;
- }
-
-}