From: Kavoos Bojnourdi Date: Sun, 9 Aug 2015 14:02:21 +0000 (+0200) Subject: - Fix unit test X-Git-Tag: gde-v0.1~8^2~87 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=13bd4126aadc1ad20789d0ea2ef8f2da58d3a510;p=modules%2Fgde.git - Fix unit test - Fix UserDao --- diff --git a/projects/GDE_App/GDE-ejb/nbproject/project.properties b/projects/GDE_App/GDE-ejb/nbproject/project.properties index 8a9dc37..41ec3c9 100644 --- a/projects/GDE_App/GDE-ejb/nbproject/project.properties +++ b/projects/GDE_App/GDE-ejb/nbproject/project.properties @@ -26,7 +26,7 @@ includes=** j2ee.compile.on.save=true j2ee.deploy.on.save=true j2ee.platform=1.7 -j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/UserEJB.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/UserEJB.java index a72aa84..4cd9a5b 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/UserEJB.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/UserEJB.java @@ -148,6 +148,6 @@ public class UserEJB { */ public boolean deleteGroup(long groupId) { UserDao dao = new UserDao(em); - return deleteGroup(groupId); + return dao.deleteGroup(groupId); } } diff --git a/projects/GDE_App/GDE-war/nbproject/project.properties b/projects/GDE_App/GDE-war/nbproject/project.properties index 71d35c5..3a43454 100644 --- a/projects/GDE_App/GDE-war/nbproject/project.properties +++ b/projects/GDE_App/GDE-war/nbproject/project.properties @@ -34,7 +34,7 @@ j2ee.compile.on.save=true j2ee.copy.static.files.on.save=true j2ee.deploy.on.save=true j2ee.platform=1.7-web -j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java index eb25873..2b83f43 100644 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java +++ b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java @@ -5,9 +5,9 @@ package com.edf.gde.dao; import com.edf.gde.transferables.CommandTO; import com.edf.gde.transferables.responses.CommandResultTO; -import gdetester.restapi.ResponseHandler; -import gdetester.restapi.RestContext; -import gdetester.restapi.SimpleRestApi; +import restapi.ResponseHandler; +import restapi.RestContext; +import restapi.SimpleRestApi; /** * diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java index 10d5d10..fceaf3a 100644 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java +++ b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java @@ -7,7 +7,7 @@ import com.edf.gde.transferables.CommandTO; import com.edf.gde.transferables.GroupTO; import com.edf.gde.transferables.UserTO; import com.edf.gde.transferables.responses.CommandResultTO; -import gdetester.restapi.RestContext; +import restapi.RestContext; import java.io.IOException; /** diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/Base64.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/Base64.java deleted file mode 100644 index 2581d5d..0000000 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/Base64.java +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland -// www.source-code.biz, www.inventec.ch/chdh -// -// This module is multi-licensed and may be used under the terms -// of any of the following licenses: -// -// EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal -// LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html -// GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html -// AGPL, GNU Affero General Public License V3 or later, http://www.gnu.org/licenses/agpl.html -// AL, Apache License, V2.0 or later, http://www.apache.org/licenses -// BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php -// MIT, MIT License, http://www.opensource.org/licenses/MIT -// -// Please contact the author if you need another license. -// This module is provided "as is", without warranties of any kind. -// -// Project home page: www.source-code.biz/base64coder/java - -package gdetester.restapi; - -/** -* A Base64 encoder/decoder. -* -*

-* This class is used to encode and decode data in Base64 format as described in RFC 1521. -* -* @author -* Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland, www.source-code.biz -*/ -public class Base64 { - -// The line separator string of the operating system. -private static final String systemLineSeparator = System.getProperty("line.separator"); - -// Mapping table from 6-bit nibbles to Base64 characters. -private static final char[] map1 = new char[64]; - static { - int i=0; - for (char c='A'; c<='Z'; c++) map1[i++] = c; - for (char c='a'; c<='z'; c++) map1[i++] = c; - for (char c='0'; c<='9'; c++) map1[i++] = c; - map1[i++] = '+'; map1[i++] = '/'; } - -// Mapping table from Base64 characters to 6-bit nibbles. -private static final byte[] map2 = new byte[128]; - static { - for (int i=0; isun.misc.BASE64Encoder.encodeBuffer(byte[]). -* @param in An array containing the data bytes to be encoded. -* @return A String containing the Base64 encoded data, broken into lines. -*/ -public static String encodeLines (byte[] in) { - return encodeLines(in, 0, in.length, 76, systemLineSeparator); } - -/** -* Encodes a byte array into Base 64 format and breaks the output into lines. -* @param in An array containing the data bytes to be encoded. -* @param iOff Offset of the first byte in in to be processed. -* @param iLen Number of bytes to be processed in in, starting at iOff. -* @param lineLen Line length for the output data. Should be a multiple of 4. -* @param lineSeparator The line separator to be used to separate the output lines. -* @return A String containing the Base64 encoded data, broken into lines. -*/ -public static String encodeLines (byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) { - int blockLen = (lineLen*3) / 4; - if (blockLen <= 0) throw new IllegalArgumentException(); - int lines = (iLen+blockLen-1) / blockLen; - int bufLen = ((iLen+2)/3)*4 + lines*lineSeparator.length(); - StringBuilder buf = new StringBuilder(bufLen); - int ip = 0; - while (ip < iLen) { - int l = Math.min(iLen-ip, blockLen); - buf.append(encode(in, iOff+ip, l)); - buf.append(lineSeparator); - ip += l; } - return buf.toString(); } - -/** -* Encodes a byte array into Base64 format. -* No blanks or line breaks are inserted in the output. -* @param in An array containing the data bytes to be encoded. -* @return A character array containing the Base64 encoded data. -*/ -public static char[] encode (byte[] in) { - return encode(in, 0, in.length); } - -/** -* Encodes a byte array into Base64 format. -* No blanks or line breaks are inserted in the output. -* @param in An array containing the data bytes to be encoded. -* @param iLen Number of bytes to process in in. -* @return A character array containing the Base64 encoded data. -*/ -public static char[] encode (byte[] in, int iLen) { - return encode(in, 0, iLen); } - -/** -* Encodes a byte array into Base64 format. -* No blanks or line breaks are inserted in the output. -* @param in An array containing the data bytes to be encoded. -* @param iOff Offset of the first byte in in to be processed. -* @param iLen Number of bytes to process in in, starting at iOff. -* @return A character array containing the Base64 encoded data. -*/ -public static char[] encode (byte[] in, int iOff, int iLen) { - int oDataLen = (iLen*4+2)/3; // output length without padding - int oLen = ((iLen+2)/3)*4; // output length including padding - char[] out = new char[oLen]; - int ip = iOff; - int iEnd = iOff + iLen; - int op = 0; - while (ip < iEnd) { - int i0 = in[ip++] & 0xff; - int i1 = ip < iEnd ? in[ip++] & 0xff : 0; - int i2 = ip < iEnd ? in[ip++] & 0xff : 0; - int o0 = i0 >>> 2; - int o1 = ((i0 & 3) << 4) | (i1 >>> 4); - int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6); - int o3 = i2 & 0x3F; - out[op++] = map1[o0]; - out[op++] = map1[o1]; - out[op] = op < oDataLen ? map1[o2] : '='; op++; - out[op] = op < oDataLen ? map1[o3] : '='; op++; } - return out; } - -/** -* Decodes a string from Base64 format. -* No blanks or line breaks are allowed within the Base64 encoded input data. -* @param s A Base64 String to be decoded. -* @return A String containing the decoded data. -* @throws IllegalArgumentException If the input is not valid Base64 encoded data. -*/ -public static String decodeString (String s) { - return new String(decode(s)); } - -/** -* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks. -* CR, LF, Tab and Space characters are ignored in the input data. -* This method is compatible with sun.misc.BASE64Decoder.decodeBuffer(String). -* @param s A Base64 String to be decoded. -* @return An array containing the decoded data bytes. -* @throws IllegalArgumentException If the input is not valid Base64 encoded data. -*/ -public static byte[] decodeLines (String s) { - char[] buf = new char[s.length()]; - int p = 0; - for (int ip = 0; ip < s.length(); ip++) { - char c = s.charAt(ip); - if (c != ' ' && c != '\r' && c != '\n' && c != '\t') - buf[p++] = c; } - return decode(buf, 0, p); } - -/** -* Decodes a byte array from Base64 format. -* No blanks or line breaks are allowed within the Base64 encoded input data. -* @param s A Base64 String to be decoded. -* @return An array containing the decoded data bytes. -* @throws IllegalArgumentException If the input is not valid Base64 encoded data. -*/ -public static byte[] decode (String s) { - return decode(s.toCharArray()); } - -/** -* Decodes a byte array from Base64 format. -* No blanks or line breaks are allowed within the Base64 encoded input data. -* @param in A character array containing the Base64 encoded data. -* @return An array containing the decoded data bytes. -* @throws IllegalArgumentException If the input is not valid Base64 encoded data. -*/ -public static byte[] decode (char[] in) { - return decode(in, 0, in.length); } - -/** -* Decodes a byte array from Base64 format. -* No blanks or line breaks are allowed within the Base64 encoded input data. -* @param in A character array containing the Base64 encoded data. -* @param iOff Offset of the first character in in to be processed. -* @param iLen Number of characters to process in in, starting at iOff. -* @return An array containing the decoded data bytes. -* @throws IllegalArgumentException If the input is not valid Base64 encoded data. -*/ -public static byte[] decode (char[] in, int iOff, int iLen) { - if (iLen%4 != 0) throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); - while (iLen > 0 && in[iOff+iLen-1] == '=') iLen--; - int oLen = (iLen*3) / 4; - byte[] out = new byte[oLen]; - int ip = iOff; - int iEnd = iOff + iLen; - int op = 0; - while (ip < iEnd) { - int i0 = in[ip++]; - int i1 = in[ip++]; - int i2 = ip < iEnd ? in[ip++] : 'A'; - int i3 = ip < iEnd ? in[ip++] : 'A'; - if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) - throw new IllegalArgumentException("Illegal character in Base64 encoded data."); - int b0 = map2[i0]; - int b1 = map2[i1]; - int b2 = map2[i2]; - int b3 = map2[i3]; - if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) - throw new IllegalArgumentException("Illegal character in Base64 encoded data."); - int o0 = ( b0 <<2) | (b1>>>4); - int o1 = ((b1 & 0xf)<<4) | (b2>>>2); - int o2 = ((b2 & 3)<<6) | b3; - out[op++] = (byte)o0; - if (op parametters; - private CertificateProvider certificateProvider; - - public RestContext() { - parametters = new HashMap(); - } - - public RestContext(String resource) { - this.baseResource = resource; - parametters = new HashMap(); - } - - public RestContext(String resource, String trustStorePath) { - this.baseResource = resource; - parametters = new HashMap(); - } - - public RestContext(String resource, String userName, String password) { - this.baseResource = resource; - this.userName = userName; - this.password = password; - parametters = new HashMap(); - } - - public CertificateProvider getCertificateProvider() { - return certificateProvider; - } - - public void setCertificateProvider(CertificateProvider certificateProvider) { - this.certificateProvider = certificateProvider; - } - - public void clear() { - this.parametters.clear(); - } - - public String getPassword() { - return password; - } - - public void setParametter(String name, String value) { - this.parametters.put(name, value); - } - - public String getResource() { - StringBuilder sb = new StringBuilder(); - sb.append(baseResource); - if (parametters.size() > 0) { - Set keys = parametters.keySet(); - String[] k = keys.toArray(new String[0]); - - sb.append("?"); - try { - sb.append(k[0]).append("=").append(URLEncoder.encode(parametters.get(k[0]), "utf-8")); - } catch (UnsupportedEncodingException ex) { - Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex); - } - for (int i = 1; i < k.length; i++) { - try { - sb.append("&").append(k[i]).append("=").append(URLEncoder.encode(parametters.get(k[i]), "utf-8")); - } catch (UnsupportedEncodingException ex) { - Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex); - } - - } - - } - String ret = sb.toString(); - return ret; - } - - public String getBaseResource() { - return baseResource; - } - - public String getUserName() { - return userName; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setBaseResource(String resource) { - this.baseResource = resource; - } - - public void setUserName(String userName) { - this.userName = userName; - } -} diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/SimpleRestApi.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/SimpleRestApi.java deleted file mode 100644 index 0ee4476..0000000 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/SimpleRestApi.java +++ /dev/null @@ -1,591 +0,0 @@ -package gdetester.restapi; - -import com.google.gson.Gson; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.lang.reflect.Type; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManagerFactory; -import gdetester.restapi.providers.CertificateProvider; - -/** - * - * @author Kavoos Bojnourdi - */ -public class SimpleRestApi { - - /** - * RestContext - */ - protected RestContext restContext; - - private KeyStore keyStore; - private TrustManagerFactory tmf; - private SSLContext context; - private boolean verifyHostName; - private HttpURLConnection connection; - protected Gson gson; - - public SimpleRestApi() { - restContext = new RestContext(); - gson = new Gson(); - } - - public SimpleRestApi(RestContext context) { - this.restContext = context; - gson = new Gson(); - } - - public boolean isVerifyHostName() { - return verifyHostName; - } - - public void setVerifyHostName(boolean verifyHostName) { - this.verifyHostName = verifyHostName; - } - - protected void setContext(RestContext context) { - this.restContext = context; - if (context.getBaseResource() != null) { - initResource(); - } - } - - private void initResource() { - - } - - public RestContext getContext() { - return restContext; - } - - protected void setResource(String resource) { - restContext.setBaseResource(resource); - initResource(); - } - - protected void setResource(String base, String resource) { - restContext.setBaseResource(base + resource); - initResource(); - } - - public void closeConnection() { - if (connection != null) { - connection.disconnect(); - } - } - - public void setCertificateProvider(CertificateProvider certificateProvider) { - restContext.setCertificateProvider(certificateProvider); - } - - /** - * - * @param connection - */ - protected void initAuthentication(HttpURLConnection connection) { - if (restContext.getUserName() == null) { - return; - } - String userCredentials = restContext.getUserName() + ":" + restContext.getPassword(); - String basicAuth = "Basic " + new String(Base64.encode(userCredentials.getBytes())); - connection.setRequestProperty("Authorization", basicAuth); - connection.setRequestProperty("User-Agent", "Deuterium/1.0"); - } - - /** - * - * @param rh - * @return - * @throws IOException - */ - protected boolean remove(ResponseHandler rh) throws IOException { - setUpHttpConnection(); - - try { - connection.setDoInput(true); - connection.setDoOutput(false); - initAuthentication(connection); - - connection.setRequestMethod("DELETE"); - - // Open and do query - int responseCode = connection.getResponseCode(); - String resultString = readStringResponse(connection); - - if (rh == null) { - rh = new DefaultResponseHandler(); - } - return rh.checkResponse(responseCode, resultString); - } finally { - closeConnection(); - } - } - - /** - * - * @param data - * @param rh - * @return - * @throws IOException - */ - protected boolean putAsJSonData(Object data, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("PUT"); - return writeJsonData(data, connection, rh); - } finally { - closeConnection(); - } - } - - /** - * - * @param data - * @return - * @throws IOException - */ - protected boolean putAsJSonData(Object data) throws IOException { - return putAsJSonData(data, null); - } - - /** - * - * @param data - * @param rh - * @return - * @throws IOException - */ - protected boolean postAsJSonData(Object data, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("POST"); - return writeJsonData(data, connection, rh); - } finally { - closeConnection(); - } - } - - /** - * - * @param data - * @return - * @throws IOException - */ - protected boolean postAsJSonData(Object data) throws IOException { - return postAsJSonData(data, null); - } - - /** - * - * @param data - * @param rh - * @return - * @throws IOException - */ - protected boolean postAsBinaryData(byte[] data, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("POST"); - return sendBinaryData(connection, data, rh); - } finally { - closeConnection(); - } - } - - /** - * - * @param data - * @param rh - * @return - * @throws IOException - */ - protected boolean putAsBinaryData(byte[] data, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("PUT"); - return sendBinaryData(connection, data, rh); - } finally { - closeConnection(); - } - } - - /** - * - * @param data - * @return - * @throws IOException - */ - protected boolean putAsBinaryData(byte[] data) throws IOException { - return putAsBinaryData(data, null); - } - - /** - * - * @param in - * @param rh - * @return - * @throws IOException - */ - protected boolean postAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("POST"); - return sendBinaryStream(connection, in, rh); - } finally { - closeConnection(); - } - } - - /** - * - * @param in - * @return - * @throws IOException - */ - protected boolean postAsBinaryStream(InputStream in) throws IOException { - return postAsBinaryStream(in, null); - } - - /** - * - * @param in - * @param rh - * @return - * @throws IOException - */ - protected boolean putAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("PUT"); - return sendBinaryStream(connection, in, rh); - - } finally { - closeConnection(); - } - } - - /** - * - * @param in - * @return - * @throws IOException - */ - protected boolean putAsBinaryStream(InputStream in) throws IOException { - return putAsBinaryStream(in, null); - } - - /** - * - * @param rh - * @return - * @throws IOException - */ - protected byte[] getBinaryData(ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("GET"); - connection.setDoInput(true); - connection.setDoOutput(false); - initAuthentication(connection); - - int responseCode = connection.getResponseCode(); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - copy(connection.getInputStream(), outputStream); - - if (rh == null) { - rh = new DefaultResponseHandler(); - } - rh.checkResponse(responseCode, connection.getResponseMessage()); - - return outputStream.toByteArray(); - } finally { - closeConnection(); - } - } - - /** - * - * @return @throws IOException - */ - protected byte[] getBinaryData() throws IOException { - return getBinaryData(null); - } - - /** - * - * @param rh - * @return - * @throws IOException - */ - protected InputStream getBinaryStream(ResponseHandler rh) throws IOException { - setUpHttpConnection(); - connection.setRequestMethod("GET"); - connection.setDoInput(true); - connection.setDoOutput(false); - initAuthentication(connection); - - int responseCode = connection.getResponseCode(); - if (rh == null) { - rh = new DefaultResponseHandler(); - } - rh.checkResponse(responseCode, connection.getResponseMessage()); - return connection.getInputStream(); - } - - /** - * - * @return @throws IOException - */ - protected InputStream getBinaryStream() throws IOException { - return getBinaryStream(null); - } - - /** - * - * @param - * @param classOfT - * @param rh - * @return - * @throws IOException - */ - protected T getData(Class classOfT, ResponseHandler rh) throws IOException { - setUpHttpConnection(); - try { - connection.setRequestMethod("GET"); - connection.setDoInput(true); - connection.setDoOutput(false); - initAuthentication(connection); - - String data = readStringResponse(connection); - int responseCode = connection.getResponseCode(); - if (rh == null) { - rh = new DefaultResponseHandler(); - } - rh.checkResponse(responseCode, connection.getResponseMessage()); - T o = gson.fromJson(data, classOfT); - return o; - } finally { - closeConnection(); - } - } - - /** - * - * @param - * @param classOfT - * @return - * @throws IOException - */ - protected T getData(Class classOfT) throws IOException { - return getData(classOfT, null); - } - - protected List getDataList(Type typeOfT, ResponseHandler rh) throws IOException { - - setUpHttpConnection(); - try { - - connection.setRequestMethod("GET"); - connection.setDoInput(true); - connection.setDoOutput(false); - initAuthentication(connection); - - int responseCode = connection.getResponseCode(); - if (rh == null) { - rh = new DefaultResponseHandler(); - } - rh.checkResponse(responseCode, connection.getResponseMessage()); - - String data = readStringResponse(connection); - T[] o = gson.fromJson(data, typeOfT); - List ret = new ArrayList(); - ret.addAll(Arrays.asList(o)); - return ret; - } finally { - closeConnection(); - } - } - - /* Private methods */ - /* ********************************************************************** */ - private boolean sendBinaryStream(HttpURLConnection connection, InputStream in, ResponseHandler rh) throws IOException { - initAuthentication(connection); - connection.setDoInput(true); - connection.setDoOutput(true); - connection.setChunkedStreamingMode(4096); - connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - copy(in, connection.getOutputStream()); - int responseCode = connection.getResponseCode(); - String response = readStringResponse(connection); - if (rh == null) { - rh = new DefaultResponseHandler(); - } - - return rh.checkResponse(responseCode, response); - - } - - private void copy(InputStream in, OutputStream out) throws IOException { - ReadableByteChannel source = Channels.newChannel(in); - WritableByteChannel target = Channels.newChannel(out); - - ByteBuffer buffer = ByteBuffer.allocate(16 * 1024); - while (source.read(buffer) != -1) { - buffer.flip(); // Prepare the buffer to be drained - while (buffer.hasRemaining()) { - target.write(buffer); - } - buffer.clear(); // Empty buffer to get ready for filling - } - - source.close(); - target.close(); - - } - - private boolean sendBinaryData(HttpURLConnection connection, byte[] data, ResponseHandler rh) throws IOException { - initAuthentication(connection); - writeData(connection, data); - int responseCode = connection.getResponseCode(); - String response = readStringResponse(connection); - if (rh == null) { - rh = new DefaultResponseHandler(); - } - - return rh.checkResponse(responseCode, response); - } - - private void writeData(HttpURLConnection connection, byte[] data) throws IOException { - connection.setDoInput(true); - connection.setDoOutput(true); - connection.setChunkedStreamingMode(4096); - connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream()); - outputStream.write(data); - outputStream.flush(); - outputStream.close(); - - } - - private boolean writeJsonData(Object data, HttpURLConnection connection, ResponseHandler rh) throws IOException { - - String dataStr = gson.toJson(data); - initAuthentication(connection); - writeData(connection, dataStr.getBytes("UTF-8")); - int responseCode = connection.getResponseCode(); - String response = readStringResponse(connection); - if (rh == null) { - rh = new DefaultResponseHandler(); - } - - return rh.checkResponse(responseCode, response); - } - - private String readStringResponse(HttpURLConnection connection) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String inputLine; - StringBuilder builder = new StringBuilder(); - while ((inputLine = reader.readLine()) != null) { - builder.append(inputLine); - } - String resultString = builder.toString(); - reader.close(); - return resultString; - } - - private void setUpHttpConnection() { - try { - - String urlString = restContext.getResource(); - URL url = new URL(urlString); - if (url.getProtocol().equals("http")) { - connection = (HttpURLConnection) url.openConnection(); - - } - if (url.getProtocol().equals("https")) { - connection = makeHttpsConnection(url); - } - - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - /** - * - * @param url - * @return - * @throws CertificateException - * @throws IOException - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - * @throws KeyStoreException - * @throws FileNotFoundException - */ - private HttpURLConnection makeHttpsConnection(URL url) throws CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException { - if (keyStore == null) { - CertificateProvider certificateProvider = restContext.getCertificateProvider(); - if (certificateProvider == null) { - throw new CertificateException("Need a certification provider"); - } - Certificate ca = certificateProvider.getCertificate(); - - String keyStoreType = KeyStore.getDefaultType(); - keyStore = KeyStore.getInstance(keyStoreType); - keyStore.load(null, null); - keyStore.setCertificateEntry("ca", ca); - - // Create a TrustManager that trusts the CAs in our KeyStore - String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); - tmf = TrustManagerFactory.getInstance(tmfAlgorithm); - tmf.init(keyStore); - - // Create an SSLContext that uses our TrustManager - context = SSLContext.getInstance("TLS"); - context.init(null, tmf.getTrustManagers(), null); - } - - // Tell the URLConnection to use a SocketFactory from our SSLContext - HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); - urlConnection.setSSLSocketFactory(context.getSocketFactory()); - - if (!verifyHostName) { - HostnameVerifier hv = new HostnameVerifier() { - - @Override - public boolean verify(String string, SSLSession ssls) { - return true; - } - }; - urlConnection.setHostnameVerifier(hv); - } - - return urlConnection; - } -} diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/exceptions/RestResponseException.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/exceptions/RestResponseException.java deleted file mode 100644 index 48cdbde..0000000 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/exceptions/RestResponseException.java +++ /dev/null @@ -1,24 +0,0 @@ -package gdetester.restapi.exceptions; - -/** - * - * @author mordicus - */ -public class RestResponseException extends RuntimeException { - - public RestResponseException(Throwable cause) { - super(cause); - } - - public RestResponseException(String message, Throwable cause) { - super(message, cause); - } - - public RestResponseException(String message) { - super(message); - } - - public RestResponseException() { - } - -} diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/providers/CertificateProvider.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/providers/CertificateProvider.java deleted file mode 100644 index 5f98153..0000000 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/providers/CertificateProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package gdetester.restapi.providers; - -import java.io.IOException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; - -public interface CertificateProvider { - - public Certificate getCertificate() throws CertificateException, IOException; - -} diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/providers/FileCertificateProvider.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/providers/FileCertificateProvider.java deleted file mode 100644 index 74e0387..0000000 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/restapi/providers/FileCertificateProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package gdetester.restapi.providers; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; - -public class FileCertificateProvider implements CertificateProvider { - - private final File file; - private Certificate ca; - - public FileCertificateProvider(File file) { - this.file = file; - } - - public FileCertificateProvider(String fileName) { - file = new File(fileName); - } - - @Override - public Certificate getCertificate() throws CertificateException, IOException { - if (ca != null) { - return ca; - } - - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - InputStream caInput = null; - try { - caInput = new BufferedInputStream(new FileInputStream(file)); - ca = cf.generateCertificate(caInput); - return ca; - } catch (FileNotFoundException ex) { - throw new IOException(ex); - } finally { - if (caInput != null) { - caInput.close(); - } - } - } - -} diff --git a/projects/GDE_App/GDE-war/test/restapi/Base64.java b/projects/GDE_App/GDE-war/test/restapi/Base64.java new file mode 100644 index 0000000..7f765b5 --- /dev/null +++ b/projects/GDE_App/GDE-war/test/restapi/Base64.java @@ -0,0 +1,228 @@ +// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland +// www.source-code.biz, www.inventec.ch/chdh +// +// This module is multi-licensed and may be used under the terms +// of any of the following licenses: +// +// EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal +// LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html +// GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html +// AGPL, GNU Affero General Public License V3 or later, http://www.gnu.org/licenses/agpl.html +// AL, Apache License, V2.0 or later, http://www.apache.org/licenses +// BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php +// MIT, MIT License, http://www.opensource.org/licenses/MIT +// +// Please contact the author if you need another license. +// This module is provided "as is", without warranties of any kind. +// +// Project home page: www.source-code.biz/base64coder/java + +package restapi; + +/** +* A Base64 encoder/decoder. +* +*

+* This class is used to encode and decode data in Base64 format as described in RFC 1521. +* +* @author +* Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland, www.source-code.biz +*/ +public class Base64 { + +// The line separator string of the operating system. +private static final String systemLineSeparator = System.getProperty("line.separator"); + +// Mapping table from 6-bit nibbles to Base64 characters. +private static final char[] map1 = new char[64]; + static { + int i=0; + for (char c='A'; c<='Z'; c++) map1[i++] = c; + for (char c='a'; c<='z'; c++) map1[i++] = c; + for (char c='0'; c<='9'; c++) map1[i++] = c; + map1[i++] = '+'; map1[i++] = '/'; } + +// Mapping table from Base64 characters to 6-bit nibbles. +private static final byte[] map2 = new byte[128]; + static { + for (int i=0; isun.misc.BASE64Encoder.encodeBuffer(byte[]). +* @param in An array containing the data bytes to be encoded. +* @return A String containing the Base64 encoded data, broken into lines. +*/ +public static String encodeLines (byte[] in) { + return encodeLines(in, 0, in.length, 76, systemLineSeparator); } + +/** +* Encodes a byte array into Base 64 format and breaks the output into lines. +* @param in An array containing the data bytes to be encoded. +* @param iOff Offset of the first byte in in to be processed. +* @param iLen Number of bytes to be processed in in, starting at iOff. +* @param lineLen Line length for the output data. Should be a multiple of 4. +* @param lineSeparator The line separator to be used to separate the output lines. +* @return A String containing the Base64 encoded data, broken into lines. +*/ +public static String encodeLines (byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) { + int blockLen = (lineLen*3) / 4; + if (blockLen <= 0) throw new IllegalArgumentException(); + int lines = (iLen+blockLen-1) / blockLen; + int bufLen = ((iLen+2)/3)*4 + lines*lineSeparator.length(); + StringBuilder buf = new StringBuilder(bufLen); + int ip = 0; + while (ip < iLen) { + int l = Math.min(iLen-ip, blockLen); + buf.append(encode(in, iOff+ip, l)); + buf.append(lineSeparator); + ip += l; } + return buf.toString(); } + +/** +* Encodes a byte array into Base64 format. +* No blanks or line breaks are inserted in the output. +* @param in An array containing the data bytes to be encoded. +* @return A character array containing the Base64 encoded data. +*/ +public static char[] encode (byte[] in) { + return encode(in, 0, in.length); } + +/** +* Encodes a byte array into Base64 format. +* No blanks or line breaks are inserted in the output. +* @param in An array containing the data bytes to be encoded. +* @param iLen Number of bytes to process in in. +* @return A character array containing the Base64 encoded data. +*/ +public static char[] encode (byte[] in, int iLen) { + return encode(in, 0, iLen); } + +/** +* Encodes a byte array into Base64 format. +* No blanks or line breaks are inserted in the output. +* @param in An array containing the data bytes to be encoded. +* @param iOff Offset of the first byte in in to be processed. +* @param iLen Number of bytes to process in in, starting at iOff. +* @return A character array containing the Base64 encoded data. +*/ +public static char[] encode (byte[] in, int iOff, int iLen) { + int oDataLen = (iLen*4+2)/3; // output length without padding + int oLen = ((iLen+2)/3)*4; // output length including padding + char[] out = new char[oLen]; + int ip = iOff; + int iEnd = iOff + iLen; + int op = 0; + while (ip < iEnd) { + int i0 = in[ip++] & 0xff; + int i1 = ip < iEnd ? in[ip++] & 0xff : 0; + int i2 = ip < iEnd ? in[ip++] & 0xff : 0; + int o0 = i0 >>> 2; + int o1 = ((i0 & 3) << 4) | (i1 >>> 4); + int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6); + int o3 = i2 & 0x3F; + out[op++] = map1[o0]; + out[op++] = map1[o1]; + out[op] = op < oDataLen ? map1[o2] : '='; op++; + out[op] = op < oDataLen ? map1[o3] : '='; op++; } + return out; } + +/** +* Decodes a string from Base64 format. +* No blanks or line breaks are allowed within the Base64 encoded input data. +* @param s A Base64 String to be decoded. +* @return A String containing the decoded data. +* @throws IllegalArgumentException If the input is not valid Base64 encoded data. +*/ +public static String decodeString (String s) { + return new String(decode(s)); } + +/** +* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks. +* CR, LF, Tab and Space characters are ignored in the input data. +* This method is compatible with sun.misc.BASE64Decoder.decodeBuffer(String). +* @param s A Base64 String to be decoded. +* @return An array containing the decoded data bytes. +* @throws IllegalArgumentException If the input is not valid Base64 encoded data. +*/ +public static byte[] decodeLines (String s) { + char[] buf = new char[s.length()]; + int p = 0; + for (int ip = 0; ip < s.length(); ip++) { + char c = s.charAt(ip); + if (c != ' ' && c != '\r' && c != '\n' && c != '\t') + buf[p++] = c; } + return decode(buf, 0, p); } + +/** +* Decodes a byte array from Base64 format. +* No blanks or line breaks are allowed within the Base64 encoded input data. +* @param s A Base64 String to be decoded. +* @return An array containing the decoded data bytes. +* @throws IllegalArgumentException If the input is not valid Base64 encoded data. +*/ +public static byte[] decode (String s) { + return decode(s.toCharArray()); } + +/** +* Decodes a byte array from Base64 format. +* No blanks or line breaks are allowed within the Base64 encoded input data. +* @param in A character array containing the Base64 encoded data. +* @return An array containing the decoded data bytes. +* @throws IllegalArgumentException If the input is not valid Base64 encoded data. +*/ +public static byte[] decode (char[] in) { + return decode(in, 0, in.length); } + +/** +* Decodes a byte array from Base64 format. +* No blanks or line breaks are allowed within the Base64 encoded input data. +* @param in A character array containing the Base64 encoded data. +* @param iOff Offset of the first character in in to be processed. +* @param iLen Number of characters to process in in, starting at iOff. +* @return An array containing the decoded data bytes. +* @throws IllegalArgumentException If the input is not valid Base64 encoded data. +*/ +public static byte[] decode (char[] in, int iOff, int iLen) { + if (iLen%4 != 0) throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); + while (iLen > 0 && in[iOff+iLen-1] == '=') iLen--; + int oLen = (iLen*3) / 4; + byte[] out = new byte[oLen]; + int ip = iOff; + int iEnd = iOff + iLen; + int op = 0; + while (ip < iEnd) { + int i0 = in[ip++]; + int i1 = in[ip++]; + int i2 = ip < iEnd ? in[ip++] : 'A'; + int i3 = ip < iEnd ? in[ip++] : 'A'; + if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) + throw new IllegalArgumentException("Illegal character in Base64 encoded data."); + int b0 = map2[i0]; + int b1 = map2[i1]; + int b2 = map2[i2]; + int b3 = map2[i3]; + if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) + throw new IllegalArgumentException("Illegal character in Base64 encoded data."); + int o0 = ( b0 <<2) | (b1>>>4); + int o1 = ((b1 & 0xf)<<4) | (b2>>>2); + int o2 = ((b2 & 3)<<6) | b3; + out[op++] = (byte)o0; + if (op parametters; + private CertificateProvider certificateProvider; + + public RestContext() { + parametters = new HashMap(); + } + + public RestContext(String resource) { + this.baseResource = resource; + parametters = new HashMap(); + } + + public RestContext(String resource, String trustStorePath) { + this.baseResource = resource; + parametters = new HashMap(); + } + + public RestContext(String resource, String userName, String password) { + this.baseResource = resource; + this.userName = userName; + this.password = password; + parametters = new HashMap(); + } + + public CertificateProvider getCertificateProvider() { + return certificateProvider; + } + + public void setCertificateProvider(CertificateProvider certificateProvider) { + this.certificateProvider = certificateProvider; + } + + public void clear() { + this.parametters.clear(); + } + + public String getPassword() { + return password; + } + + public void setParametter(String name, String value) { + this.parametters.put(name, value); + } + + public String getResource() { + StringBuilder sb = new StringBuilder(); + sb.append(baseResource); + if (parametters.size() > 0) { + Set keys = parametters.keySet(); + String[] k = keys.toArray(new String[0]); + + sb.append("?"); + try { + sb.append(k[0]).append("=").append(URLEncoder.encode(parametters.get(k[0]), "utf-8")); + } catch (UnsupportedEncodingException ex) { + Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex); + } + for (int i = 1; i < k.length; i++) { + try { + sb.append("&").append(k[i]).append("=").append(URLEncoder.encode(parametters.get(k[i]), "utf-8")); + } catch (UnsupportedEncodingException ex) { + Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex); + } + + } + + } + String ret = sb.toString(); + return ret; + } + + public String getBaseResource() { + return baseResource; + } + + public String getUserName() { + return userName; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setBaseResource(String resource) { + this.baseResource = resource; + } + + public void setUserName(String userName) { + this.userName = userName; + } +} diff --git a/projects/GDE_App/GDE-war/test/restapi/SimpleRestApi.java b/projects/GDE_App/GDE-war/test/restapi/SimpleRestApi.java new file mode 100644 index 0000000..53a6859 --- /dev/null +++ b/projects/GDE_App/GDE-war/test/restapi/SimpleRestApi.java @@ -0,0 +1,591 @@ +package restapi; + +import com.google.gson.Gson; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.lang.reflect.Type; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.nio.channels.WritableByteChannel; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManagerFactory; +import restapi.providers.CertificateProvider; + +/** + * + * @author Kavoos Bojnourdi + */ +public class SimpleRestApi { + + /** + * RestContext + */ + protected RestContext restContext; + + private KeyStore keyStore; + private TrustManagerFactory tmf; + private SSLContext context; + private boolean verifyHostName; + private HttpURLConnection connection; + protected Gson gson; + + public SimpleRestApi() { + restContext = new RestContext(); + gson = new Gson(); + } + + public SimpleRestApi(RestContext context) { + this.restContext = context; + gson = new Gson(); + } + + public boolean isVerifyHostName() { + return verifyHostName; + } + + public void setVerifyHostName(boolean verifyHostName) { + this.verifyHostName = verifyHostName; + } + + protected void setContext(RestContext context) { + this.restContext = context; + if (context.getBaseResource() != null) { + initResource(); + } + } + + private void initResource() { + + } + + public RestContext getContext() { + return restContext; + } + + protected void setResource(String resource) { + restContext.setBaseResource(resource); + initResource(); + } + + protected void setResource(String base, String resource) { + restContext.setBaseResource(base + resource); + initResource(); + } + + public void closeConnection() { + if (connection != null) { + connection.disconnect(); + } + } + + public void setCertificateProvider(CertificateProvider certificateProvider) { + restContext.setCertificateProvider(certificateProvider); + } + + /** + * + * @param connection + */ + protected void initAuthentication(HttpURLConnection connection) { + if (restContext.getUserName() == null) { + return; + } + String userCredentials = restContext.getUserName() + ":" + restContext.getPassword(); + String basicAuth = "Basic " + new String(Base64.encode(userCredentials.getBytes())); + connection.setRequestProperty("Authorization", basicAuth); + connection.setRequestProperty("User-Agent", "Deuterium/1.0"); + } + + /** + * + * @param rh + * @return + * @throws IOException + */ + protected boolean remove(ResponseHandler rh) throws IOException { + setUpHttpConnection(); + + try { + connection.setDoInput(true); + connection.setDoOutput(false); + initAuthentication(connection); + + connection.setRequestMethod("DELETE"); + + // Open and do query + int responseCode = connection.getResponseCode(); + String resultString = readStringResponse(connection); + + if (rh == null) { + rh = new DefaultResponseHandler(); + } + return rh.checkResponse(responseCode, resultString); + } finally { + closeConnection(); + } + } + + /** + * + * @param data + * @param rh + * @return + * @throws IOException + */ + protected boolean putAsJSonData(Object data, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("PUT"); + return writeJsonData(data, connection, rh); + } finally { + closeConnection(); + } + } + + /** + * + * @param data + * @return + * @throws IOException + */ + protected boolean putAsJSonData(Object data) throws IOException { + return putAsJSonData(data, null); + } + + /** + * + * @param data + * @param rh + * @return + * @throws IOException + */ + protected boolean postAsJSonData(Object data, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("POST"); + return writeJsonData(data, connection, rh); + } finally { + closeConnection(); + } + } + + /** + * + * @param data + * @return + * @throws IOException + */ + protected boolean postAsJSonData(Object data) throws IOException { + return postAsJSonData(data, null); + } + + /** + * + * @param data + * @param rh + * @return + * @throws IOException + */ + protected boolean postAsBinaryData(byte[] data, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("POST"); + return sendBinaryData(connection, data, rh); + } finally { + closeConnection(); + } + } + + /** + * + * @param data + * @param rh + * @return + * @throws IOException + */ + protected boolean putAsBinaryData(byte[] data, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("PUT"); + return sendBinaryData(connection, data, rh); + } finally { + closeConnection(); + } + } + + /** + * + * @param data + * @return + * @throws IOException + */ + protected boolean putAsBinaryData(byte[] data) throws IOException { + return putAsBinaryData(data, null); + } + + /** + * + * @param in + * @param rh + * @return + * @throws IOException + */ + protected boolean postAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("POST"); + return sendBinaryStream(connection, in, rh); + } finally { + closeConnection(); + } + } + + /** + * + * @param in + * @return + * @throws IOException + */ + protected boolean postAsBinaryStream(InputStream in) throws IOException { + return postAsBinaryStream(in, null); + } + + /** + * + * @param in + * @param rh + * @return + * @throws IOException + */ + protected boolean putAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("PUT"); + return sendBinaryStream(connection, in, rh); + + } finally { + closeConnection(); + } + } + + /** + * + * @param in + * @return + * @throws IOException + */ + protected boolean putAsBinaryStream(InputStream in) throws IOException { + return putAsBinaryStream(in, null); + } + + /** + * + * @param rh + * @return + * @throws IOException + */ + protected byte[] getBinaryData(ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("GET"); + connection.setDoInput(true); + connection.setDoOutput(false); + initAuthentication(connection); + + int responseCode = connection.getResponseCode(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + copy(connection.getInputStream(), outputStream); + + if (rh == null) { + rh = new DefaultResponseHandler(); + } + rh.checkResponse(responseCode, connection.getResponseMessage()); + + return outputStream.toByteArray(); + } finally { + closeConnection(); + } + } + + /** + * + * @return @throws IOException + */ + protected byte[] getBinaryData() throws IOException { + return getBinaryData(null); + } + + /** + * + * @param rh + * @return + * @throws IOException + */ + protected InputStream getBinaryStream(ResponseHandler rh) throws IOException { + setUpHttpConnection(); + connection.setRequestMethod("GET"); + connection.setDoInput(true); + connection.setDoOutput(false); + initAuthentication(connection); + + int responseCode = connection.getResponseCode(); + if (rh == null) { + rh = new DefaultResponseHandler(); + } + rh.checkResponse(responseCode, connection.getResponseMessage()); + return connection.getInputStream(); + } + + /** + * + * @return @throws IOException + */ + protected InputStream getBinaryStream() throws IOException { + return getBinaryStream(null); + } + + /** + * + * @param + * @param classOfT + * @param rh + * @return + * @throws IOException + */ + protected T getData(Class classOfT, ResponseHandler rh) throws IOException { + setUpHttpConnection(); + try { + connection.setRequestMethod("GET"); + connection.setDoInput(true); + connection.setDoOutput(false); + initAuthentication(connection); + + String data = readStringResponse(connection); + int responseCode = connection.getResponseCode(); + if (rh == null) { + rh = new DefaultResponseHandler(); + } + rh.checkResponse(responseCode, connection.getResponseMessage()); + T o = gson.fromJson(data, classOfT); + return o; + } finally { + closeConnection(); + } + } + + /** + * + * @param + * @param classOfT + * @return + * @throws IOException + */ + protected T getData(Class classOfT) throws IOException { + return getData(classOfT, null); + } + + protected List getDataList(Type typeOfT, ResponseHandler rh) throws IOException { + + setUpHttpConnection(); + try { + + connection.setRequestMethod("GET"); + connection.setDoInput(true); + connection.setDoOutput(false); + initAuthentication(connection); + + int responseCode = connection.getResponseCode(); + if (rh == null) { + rh = new DefaultResponseHandler(); + } + rh.checkResponse(responseCode, connection.getResponseMessage()); + + String data = readStringResponse(connection); + T[] o = gson.fromJson(data, typeOfT); + List ret = new ArrayList(); + ret.addAll(Arrays.asList(o)); + return ret; + } finally { + closeConnection(); + } + } + + /* Private methods */ + /* ********************************************************************** */ + private boolean sendBinaryStream(HttpURLConnection connection, InputStream in, ResponseHandler rh) throws IOException { + initAuthentication(connection); + connection.setDoInput(true); + connection.setDoOutput(true); + connection.setChunkedStreamingMode(4096); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + copy(in, connection.getOutputStream()); + int responseCode = connection.getResponseCode(); + String response = readStringResponse(connection); + if (rh == null) { + rh = new DefaultResponseHandler(); + } + + return rh.checkResponse(responseCode, response); + + } + + private void copy(InputStream in, OutputStream out) throws IOException { + ReadableByteChannel source = Channels.newChannel(in); + WritableByteChannel target = Channels.newChannel(out); + + ByteBuffer buffer = ByteBuffer.allocate(16 * 1024); + while (source.read(buffer) != -1) { + buffer.flip(); // Prepare the buffer to be drained + while (buffer.hasRemaining()) { + target.write(buffer); + } + buffer.clear(); // Empty buffer to get ready for filling + } + + source.close(); + target.close(); + + } + + private boolean sendBinaryData(HttpURLConnection connection, byte[] data, ResponseHandler rh) throws IOException { + initAuthentication(connection); + writeData(connection, data); + int responseCode = connection.getResponseCode(); + String response = readStringResponse(connection); + if (rh == null) { + rh = new DefaultResponseHandler(); + } + + return rh.checkResponse(responseCode, response); + } + + private void writeData(HttpURLConnection connection, byte[] data) throws IOException { + connection.setDoInput(true); + connection.setDoOutput(true); + connection.setChunkedStreamingMode(4096); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream()); + outputStream.write(data); + outputStream.flush(); + outputStream.close(); + + } + + private boolean writeJsonData(Object data, HttpURLConnection connection, ResponseHandler rh) throws IOException { + + String dataStr = gson.toJson(data); + initAuthentication(connection); + writeData(connection, dataStr.getBytes("UTF-8")); + int responseCode = connection.getResponseCode(); + String response = readStringResponse(connection); + if (rh == null) { + rh = new DefaultResponseHandler(); + } + + return rh.checkResponse(responseCode, response); + } + + private String readStringResponse(HttpURLConnection connection) throws IOException { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder builder = new StringBuilder(); + while ((inputLine = reader.readLine()) != null) { + builder.append(inputLine); + } + String resultString = builder.toString(); + reader.close(); + return resultString; + } + + private void setUpHttpConnection() { + try { + + String urlString = restContext.getResource(); + URL url = new URL(urlString); + if (url.getProtocol().equals("http")) { + connection = (HttpURLConnection) url.openConnection(); + + } + if (url.getProtocol().equals("https")) { + connection = makeHttpsConnection(url); + } + + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * + * @param url + * @return + * @throws CertificateException + * @throws IOException + * @throws KeyManagementException + * @throws NoSuchAlgorithmException + * @throws KeyStoreException + * @throws FileNotFoundException + */ + private HttpURLConnection makeHttpsConnection(URL url) throws CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException { + if (keyStore == null) { + CertificateProvider certificateProvider = restContext.getCertificateProvider(); + if (certificateProvider == null) { + throw new CertificateException("Need a certification provider"); + } + Certificate ca = certificateProvider.getCertificate(); + + String keyStoreType = KeyStore.getDefaultType(); + keyStore = KeyStore.getInstance(keyStoreType); + keyStore.load(null, null); + keyStore.setCertificateEntry("ca", ca); + + // Create a TrustManager that trusts the CAs in our KeyStore + String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); + tmf = TrustManagerFactory.getInstance(tmfAlgorithm); + tmf.init(keyStore); + + // Create an SSLContext that uses our TrustManager + context = SSLContext.getInstance("TLS"); + context.init(null, tmf.getTrustManagers(), null); + } + + // Tell the URLConnection to use a SocketFactory from our SSLContext + HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); + urlConnection.setSSLSocketFactory(context.getSocketFactory()); + + if (!verifyHostName) { + HostnameVerifier hv = new HostnameVerifier() { + + @Override + public boolean verify(String string, SSLSession ssls) { + return true; + } + }; + urlConnection.setHostnameVerifier(hv); + } + + return urlConnection; + } +} diff --git a/projects/GDE_App/GDE-war/test/restapi/exceptions/RestResponseException.java b/projects/GDE_App/GDE-war/test/restapi/exceptions/RestResponseException.java new file mode 100644 index 0000000..7ae9462 --- /dev/null +++ b/projects/GDE_App/GDE-war/test/restapi/exceptions/RestResponseException.java @@ -0,0 +1,24 @@ +package restapi.exceptions; + +/** + * + * @author mordicus + */ +public class RestResponseException extends RuntimeException { + + public RestResponseException(Throwable cause) { + super(cause); + } + + public RestResponseException(String message, Throwable cause) { + super(message, cause); + } + + public RestResponseException(String message) { + super(message); + } + + public RestResponseException() { + } + +} diff --git a/projects/GDE_App/GDE-war/test/restapi/providers/CertificateProvider.java b/projects/GDE_App/GDE-war/test/restapi/providers/CertificateProvider.java new file mode 100644 index 0000000..f48cd8a --- /dev/null +++ b/projects/GDE_App/GDE-war/test/restapi/providers/CertificateProvider.java @@ -0,0 +1,11 @@ +package restapi.providers; + +import java.io.IOException; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; + +public interface CertificateProvider { + + public Certificate getCertificate() throws CertificateException, IOException; + +} diff --git a/projects/GDE_App/GDE-war/test/restapi/providers/FileCertificateProvider.java b/projects/GDE_App/GDE-war/test/restapi/providers/FileCertificateProvider.java new file mode 100644 index 0000000..4b92289 --- /dev/null +++ b/projects/GDE_App/GDE-war/test/restapi/providers/FileCertificateProvider.java @@ -0,0 +1,47 @@ +package restapi.providers; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; + +public class FileCertificateProvider implements CertificateProvider { + + private final File file; + private Certificate ca; + + public FileCertificateProvider(File file) { + this.file = file; + } + + public FileCertificateProvider(String fileName) { + file = new File(fileName); + } + + @Override + public Certificate getCertificate() throws CertificateException, IOException { + if (ca != null) { + return ca; + } + + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + InputStream caInput = null; + try { + caInput = new BufferedInputStream(new FileInputStream(file)); + ca = cf.generateCertificate(caInput); + return ca; + } catch (FileNotFoundException ex) { + throw new IOException(ex); + } finally { + if (caInput != null) { + caInput.close(); + } + } + } + +} diff --git a/projects/GDE_App/nbproject/project.properties b/projects/GDE_App/nbproject/project.properties index cd4eff4..8118174 100644 --- a/projects/GDE_App/nbproject/project.properties +++ b/projects/GDE_App/nbproject/project.properties @@ -13,7 +13,7 @@ j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args} j2ee.compile.on.save=true j2ee.deploy.on.save=false j2ee.platform=1.7 -j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar diff --git a/projects/GDE_App/src/GDE_DB_Init.sql b/projects/GDE_App/src/GDE_DB_Init.sql index 19c986d..72a1a3c 100644 --- a/projects/GDE_App/src/GDE_DB_Init.sql +++ b/projects/GDE_App/src/GDE_DB_Init.sql @@ -1,7 +1,7 @@ /* Unique Ids sequence generator */ drop sequence SEQ_GEN_SEQUENCE; -create sequence SEQ_GEN_SEQUENCE START WITH 50 INCREMENT BY 50; +create sequence SEQ_GEN_SEQUENCE START WITH 100 INCREMENT BY 50; DROP TABLE IF EXISTS GROUP_ CASCADE; @@ -109,3 +109,4 @@ CREATE TABLE profile_attribute ( mandatory boolean, profile_id bigint REFERENCES profile (id) ); +