private static Locale getSymbolLocale() { return PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.enDateNames", false)?Locale.ENGLISH:Locale.getDefault(); //$NON-NLS-1$ }
public static SSLSocketFactory getSSLSocketFactory(Properties props) throws IOException, GeneralSecurityException{ String keystore = props.getProperty(KEYSTORE_FILENAME); String keystorePassword = props.getProperty(KEYSTORE_PASSWORD); String keystoreType = props.getProperty(KEYSTORE_TYPE, DEFAULT_KEYSTORE_TYPE); String keystoreProtocol = props.getProperty(PROTOCOL, DEFAULT_PROTOCOL); String keystoreAlgorithm = props.getProperty(KEYSTORE_ALGORITHM); String truststore = props.getProperty(TRUSTSTORE_FILENAME, keystore); String truststorePassword = props.getProperty(TRUSTSTORE_PASSWORD, keystorePassword); String keyAlias = props.getProperty(KEYSTORE_ALIAS); String keyPassword = props.getProperty(KEY_PASSWORD); boolean anon = PropertiesUtils.getBooleanProperty(props, ALLOW_ANON, true); boolean trustAll = PropertiesUtils.getBooleanProperty(props, TRUST_ALL, false); boolean checkExpired = PropertiesUtils.getBooleanProperty(props, CHECK_EXPIRED, false); SSLContext result = null; // 1) keystore != null = 2 way SSL (can define a separate truststore too) // 2) truststore != null = 1 way SSL (here we can define custom properties for truststore; useful when // client like a appserver have to define multiple certs without importing // all the certificates into one single certificate // 3) else = javax properties; this is default way to define the SSL anywhere. if (keystore != null || truststore != null || trustAll || checkExpired) { result = getSSLContext(keystore, keystorePassword, truststore, truststorePassword, keystoreAlgorithm, keystoreType, keystoreProtocol, keyAlias, keyPassword, trustAll, checkExpired); } else { result = SSLContext.getDefault(); } //TODO: could allow a custom SSLSocketFactory to be plugged in like the pg jdbc driver return new SSLSocketFactory(result, anon); }
public static SSLSocketFactory getSSLSocketFactory(Properties props) throws IOException, GeneralSecurityException{ String keystore = props.getProperty(KEYSTORE_FILENAME); String keystorePassword = props.getProperty(KEYSTORE_PASSWORD); String keystoreType = props.getProperty(KEYSTORE_TYPE, DEFAULT_KEYSTORE_TYPE); String keystoreProtocol = props.getProperty(PROTOCOL, DEFAULT_PROTOCOL); String keystoreAlgorithm = props.getProperty(KEYSTORE_ALGORITHM); String truststore = props.getProperty(TRUSTSTORE_FILENAME, keystore); String truststorePassword = props.getProperty(TRUSTSTORE_PASSWORD, keystorePassword); String keyAlias = props.getProperty(KEYSTORE_ALIAS); String keyPassword = props.getProperty(KEY_PASSWORD); boolean anon = PropertiesUtils.getBooleanProperty(props, ALLOW_ANON, true); boolean trustAll = PropertiesUtils.getBooleanProperty(props, TRUST_ALL, false); boolean checkExpired = PropertiesUtils.getBooleanProperty(props, CHECK_EXPIRED, false); SSLContext result = null; // 1) keystore != null = 2 way SSL (can define a separate truststore too) // 2) truststore != null = 1 way SSL (here we can define custom properties for truststore; useful when // client like a appserver have to define multiple certs without importing // all the certificates into one single certificate // 3) else = javax properties; this is default way to define the SSL anywhere. if (keystore != null || truststore != null || trustAll || checkExpired) { result = getSSLContext(keystore, keystorePassword, truststore, truststorePassword, keystoreAlgorithm, keystoreType, keystoreProtocol, keyAlias, keyPassword, trustAll, checkExpired); } else { result = SSLContext.getDefault(); } //TODO: could allow a custom SSLSocketFactory to be plugged in like the pg jdbc driver return new SSLSocketFactory(result, anon); }
public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException {
public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException {
/** * <p>Constructor which initializes with the connection object on which metadata * is sought * @param driver's connection object. * @throws SQLException if the connection is already closed. */ DatabaseMetaDataImpl(ConnectionImpl connection) { this.driverConnection = connection; if (PropertiesUtils.getBooleanProperty(connection.getConnectionProps(), REPORT_AS_VIEWS, true)) { TABLE_TYPE = "CASE WHEN IsSystem = 'true' and UCASE(Type) = 'TABLE' THEN 'SYSTEM TABLE' WHEN IsPhysical <> 'true' AND UCASE(Type) = 'TABLE' THEN 'VIEW' ELSE UCASE(Type) END"; //$NON-NLS-1$ } else { TABLE_TYPE = "CASE WHEN IsSystem = 'true' and UCASE(Type) = 'TABLE' THEN 'SYSTEM TABLE' ELSE UCASE(Type) END"; //$NON-NLS-1$ } String nullSortProp = connection.getConnectionProps().getProperty(NULL_SORT); if (nullSortProp != null) { nullSort = StringUtil.caseInsensitiveValueOf(NullSort.class, nullSortProp); } QUERY_TABLES = new StringBuffer("SELECT VDBName AS TABLE_CAT, SchemaName AS TABLE_SCHEM, Name AS TABLE_NAME") //$NON-NLS-1$ .append(", ").append(TABLE_TYPE).append(" AS TABLE_TYPE, Description AS REMARKS, NULL AS TYPE_CAT, NULL AS TYPE_SCHEM") //$NON-NLS-1$ //$NON-NLS-2$ .append(", NULL AS TYPE_NAME, NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION, IsPhysical AS ISPHYSICAL") //$NON-NLS-1$ .append(" FROM ").append(RUNTIME_MODEL.VIRTUAL_MODEL_NAME).append(".Tables g ") //$NON-NLS-1$ //$NON-NLS-2$ .append(" WHERE UCASE(VDBName)").append(LIKE_ESCAPE)//$NON-NLS-1$ .append(" AND UCASE(SchemaName)").append(LIKE_ESCAPE)//$NON-NLS-1$ .append(" AND UCASE(Name)") .append(LIKE_ESCAPE).toString(); //$NON-NLS-1$ }
/** * <p>Constructor which initializes with the connection object on which metadata * is sought * @param driver's connection object. * @throws SQLException if the connection is already closed. */ DatabaseMetaDataImpl(ConnectionImpl connection) { this.driverConnection = connection; if (PropertiesUtils.getBooleanProperty(connection.getConnectionProps(), REPORT_AS_VIEWS, true)) { TABLE_TYPE = "CASE WHEN IsSystem = 'true' and UCASE(Type) = 'TABLE' THEN 'SYSTEM TABLE' WHEN IsPhysical <> 'true' AND UCASE(Type) = 'TABLE' THEN 'VIEW' ELSE UCASE(Type) END"; //$NON-NLS-1$ } else { TABLE_TYPE = "CASE WHEN IsSystem = 'true' and UCASE(Type) = 'TABLE' THEN 'SYSTEM TABLE' ELSE UCASE(Type) END"; //$NON-NLS-1$ } String nullSortProp = connection.getConnectionProps().getProperty(NULL_SORT); if (nullSortProp != null) { nullSort = StringUtil.caseInsensitiveValueOf(NullSort.class, nullSortProp); } QUERY_TABLES = new StringBuffer("SELECT VDBName AS TABLE_CAT, SchemaName AS TABLE_SCHEM, Name AS TABLE_NAME") //$NON-NLS-1$ .append(", ").append(TABLE_TYPE).append(" AS TABLE_TYPE, Description AS REMARKS, NULL AS TYPE_CAT, NULL AS TYPE_SCHEM") //$NON-NLS-1$ //$NON-NLS-2$ .append(", NULL AS TYPE_NAME, NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION, IsPhysical AS ISPHYSICAL") //$NON-NLS-1$ .append(" FROM ").append(RUNTIME_MODEL.VIRTUAL_MODEL_NAME).append(".Tables g ") //$NON-NLS-1$ //$NON-NLS-2$ .append(" WHERE UCASE(VDBName)").append(LIKE_ESCAPE)//$NON-NLS-1$ .append(" AND UCASE(SchemaName)").append(LIKE_ESCAPE)//$NON-NLS-1$ .append(" AND UCASE(Name)") .append(LIKE_ESCAPE).toString(); //$NON-NLS-1$ }
@Override public ServerConnection createServerConnection(Properties info) throws TeiidException { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { ModuleLoader callerModuleLoader = Module.getCallerModuleLoader(); if (callerModuleLoader == null) { logger.fine(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20033)); return (ServerConnection)ReflectionHelper.create("org.teiid.transport.LocalServerConnection", Arrays.asList(info, PropertiesUtils.getBooleanProperty(info, LocalProfile.USE_CALLING_THREAD, true)), Thread.currentThread().getContextClassLoader()); //$NON-NLS-1$ } final Module module = callerModuleLoader.loadModule("org.jboss.teiid"); //$NON-NLS-1$ Thread.currentThread().setContextClassLoader(module.getClassLoader()); return (ServerConnection)ReflectionHelper.create("org.teiid.transport.LocalServerConnection", Arrays.asList(info, PropertiesUtils.getBooleanProperty(info, LocalProfile.USE_CALLING_THREAD, true)), Thread.currentThread().getContextClassLoader()); //$NON-NLS-1$ } catch (ModuleLoadException e) { throw new ConnectionException(JDBCPlugin.Event.TEIID20008, e, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20008)); } finally { Thread.currentThread().setContextClassLoader(tccl); } }
private static final class UpperLowerReader extends FilterReader { int c1 = -1; private boolean upper; private UpperLowerReader(Reader in, boolean upper) { super(in); this.upper = upper; } @Override public int read(char[] cbuf, int off, int len) throws IOException { if (len <= 0) { if (len < 0) { throw new IndexOutOfBoundsException(); } else if ((off < 0) || (off > cbuf.length)) { throw new IndexOutOfBoundsException(); } return 0; } int chars = 0; while (chars <= len) { int c = read(); if (c == -1) { if (chars == 0) { return -1; } break; } cbuf[off++] = (char)c; chars++;
public void setFetchSize(int rows) throws SQLException { checkClosed(); if ( rows < 0 ) { throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Invalid_fetch_size")); //$NON-NLS-1$ } // sets the fetch size on this statement if (rows == 0) { this.fetchSize = BaseDataSource.DEFAULT_FETCH_SIZE; } else { if (disableFetchSize == null) { this.disableFetchSize = PropertiesUtils.getBooleanProperty(statement.getConnection().getConnectionProps(), DISABLE_FETCH_SIZE, DISABLE_FETCH_SIZE_DEFAULT); } if (disableFetchSize == null || !disableFetchSize) { this.fetchSize = rows; } } }
public void setFetchSize(int rows) throws SQLException { checkClosed(); if ( rows < 0 ) { throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Invalid_fetch_size")); //$NON-NLS-1$ } // sets the fetch size on this statement if (rows == 0) { this.fetchSize = BaseDataSource.DEFAULT_FETCH_SIZE; } else { if (disableFetchSize == null) { this.disableFetchSize = PropertiesUtils.getBooleanProperty(statement.getConnection().getConnectionProps(), DISABLE_FETCH_SIZE, DISABLE_FETCH_SIZE_DEFAULT); } if (disableFetchSize == null || !disableFetchSize) { this.fetchSize = rows; } } }
if (PropertiesUtils.getBooleanProperty(factory.getModelProperties(), IMPORT_PUSHDOWN_FUNCTIONS, false)) { //$NON-NLS-1$ List<FunctionMethod> functions = executionFactory.getPushDownFunctions();