Examples of FormatableProperties


Examples of org.apache.derby.iapi.services.io.FormatableProperties

    String dbname = InternalDriver.getDatabaseName(url, info);

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = getAttributes(url, info);
    info = null; // ensure we don't use this reference directly again.
    boolean encryptDB = Boolean.valueOf(finfo.getProperty(Attribute.DATA_ENCRYPTION)).booleanValue();   
    String encryptpassword = finfo.getProperty(Attribute.BOOT_PASSWORD);

    if (dbname.length() == 0 || (encryptDB && encryptpassword == null)) {

      // with no database name we can have shutdown or a database name

      // In future, if any new attribute info needs to be included in this
      // method, it just has to be added to either string or boolean or secret array
      // depending on whether it accepts string or boolean or secret(ie passwords) value.

      String[][] connStringAttributes = {
        {Attribute.DBNAME_ATTR, MessageId.CONN_DATABASE_IDENTITY},
        {Attribute.CRYPTO_PROVIDER, MessageId.CONN_CRYPTO_PROVIDER},
        {Attribute.CRYPTO_ALGORITHM, MessageId.CONN_CRYPTO_ALGORITHM},
        {Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
        {Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
        {Attribute.TERRITORY, MessageId.CONN_LOCALE},
        {Attribute.COLLATION, MessageId.CONN_COLLATION},
        {Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
        {Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
        {Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},
        {Attribute.CREATE_FROM, MessageId.CONN_CREATE_FROM},
        {Attribute.RESTORE_FROM, MessageId.CONN_RESTORE_FROM},
      };

      String[][] connBooleanAttributes = {
        {Attribute.SHUTDOWN_ATTR, MessageId.CONN_SHUT_DOWN_CLOUDSCAPE},
                {Attribute.DEREGISTER_ATTR, MessageId.CONN_DEREGISTER_AUTOLOADEDDRIVER},
        {Attribute.CREATE_ATTR, MessageId.CONN_CREATE_DATABASE},
        {Attribute.DATA_ENCRYPTION, MessageId.CONN_DATA_ENCRYPTION},
        {Attribute.UPGRADE_ATTR, MessageId.CONN_UPGRADE_DATABASE},
        };

      String[][] connStringSecretAttributes = {
        {Attribute.BOOT_PASSWORD, MessageId.CONN_BOOT_PASSWORD},
        {Attribute.PASSWORD_ATTR, MessageId.CONN_PASSWORD_ATTR},
        };

     
      DriverPropertyInfo[] optionsNoDB = new   DriverPropertyInfo[connStringAttributes.length+
                                    connBooleanAttributes.length+
                                                                connStringSecretAttributes.length];
     
      int attrIndex = 0;
      for( int i = 0; i < connStringAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringAttributes[i][0],
                    finfo.getProperty(connStringAttributes[i][0]));
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringAttributes[i][1]);
      }

      optionsNoDB[0].choices = Monitor.getMonitor().getServiceList(Property.DATABASE_MODULE);
      // since database name is not stored in FormatableProperties, we
      // assign here explicitly
      optionsNoDB[0].value = dbname;

      for( int i = 0; i < connStringSecretAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringSecretAttributes[i][0],
                    (finfo.getProperty(connStringSecretAttributes[i][0]) == null? "" : "****"));
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringSecretAttributes[i][1]);
      }

      for( int i = 0; i < connBooleanAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connBooleanAttributes[i][0],
                   Boolean.valueOf(finfo == null? "" : finfo.getProperty(connBooleanAttributes[i][0])).toString());
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connBooleanAttributes[i][1]);
        optionsNoDB[attrIndex].choices = BOOLEAN_CHOICES;       
      }

      return optionsNoDB;
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

      return null;
    }

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = getAttributes(url, info);
    info = null; // ensure we don't use this reference directly again.
    try {

      /*
      ** A property "shutdown=true" means shut the system or database down
      */
      boolean shutdown = Boolean.valueOf(finfo.getProperty(Attribute.SHUTDOWN_ATTR)).booleanValue();
     
      if (shutdown) {
       
        // If we are shutting down the system don't attempt to create
        // a connection; but we validate users credentials if we have to.
        // In case of datbase shutdown, we ask the database authentication
        // service to authenticate the user. If it is a system shutdown,
        // then we ask the Driver to do the authentication.
        //
        if (InternalDriver.getDatabaseName(url, finfo).length() == 0) {
          //
          // We need to authenticate the user if authentication is
          // ON. Note that this is a system shutdown.
          // check that we do have a authentication service
          // it is _always_ expected.
          if (this.getAuthenticationService() == null)
            throw Util.generateCsSQLException(
                        SQLState.LOGIN_FAILED,
            MessageService.getTextMessage(MessageId.AUTH_NO_SERVICE_FOR_SYSTEM));
         
           
          if (!this.getAuthenticationService().authenticate((String) null, finfo)) {

            // not a valid user
            throw Util.generateCsSQLException(
                                  SQLState.LOGIN_FAILED, MessageService.getTextMessage(MessageId.AUTH_INVALID));
          }

          Monitor.getMonitor().shutdown();
          throw Util.generateCsSQLException(
                                         SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
        }
      }
     
      EmbedConnection conn = getNewEmbedConnection(url, finfo);

      // if this is not the correct driver a EmbedConnection
      // object is returned in the closed state.
      if (conn.isClosed()) {
        return null;
      }

      return conn;
    }
    finally {
      // break any link with the user's Properties set.
      finfo.clearDefaults();
    }
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

  protected FormatableProperties getAttributes(String url, Properties info)
    throws SQLException {

    // We use FormatableProperties here to take advantage
    // of the clearDefaults, method.
    FormatableProperties finfo = new FormatableProperties(info);
    info = null; // ensure we don't use this reference directly again.


    StringTokenizer st = new StringTokenizer(url, ";");
    st.nextToken(); // skip the first part of the url

    while (st.hasMoreTokens()) {

      String v = st.nextToken();

      int eqPos = v.indexOf('=');
      if (eqPos == -1)
        throw Util.generateCsSQLException(
                                            SQLState.MALFORMED_URL, url);

      //if (eqPos != v.lastIndexOf('='))
      //  throw Util.malformedURL(url);

      finfo.put((v.substring(0, eqPos)).trim(),
           (v.substring(eqPos + 1)).trim()
          );
    }

    // now validate any attributes we can
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

* only eg impl/load/import.java specifies property insertMode=replace/bulkInsert
* in the insert statement. This same property will not be acceptable from an
* insert statement from a user sql.
*/
  final public Properties propertyList(boolean propertiesUseAllowed) throws ParseException, StandardException {
        Properties properties = new FormatableProperties();
        StringTokenizer commaSeparatedProperties;
        StringTokenizer equalOperatorSeparatedProperty;
    jj_consume_token(DERBYDASHPROPERTIES);
                //first use StringTokenizer to get tokens which are delimited by ,s
                commaSeparatedProperties = new StringTokenizer(getToken(1).image,",");
                while (commaSeparatedProperties.hasMoreTokens()) {
                        //Now verify that tokens delimited by ,s follow propertyName=value pattern
                        String currentProperty = commaSeparatedProperties.nextToken();
                        equalOperatorSeparatedProperty = new StringTokenizer(currentProperty,"=", true);
                        if (equalOperatorSeparatedProperty.countTokens() != 3)
                                {if (true) throw StandardException.newException(SQLState.PROPERTY_SYNTAX_INVALID);}
                        else {
                                String key = equalOperatorSeparatedProperty.nextToken().trim();
                                if (!equalOperatorSeparatedProperty.nextToken().equals("="))
                                        {if (true) throw StandardException.newException(SQLState.PROPERTY_SYNTAX_INVALID);}
                                String value = equalOperatorSeparatedProperty.nextToken().trim();
                                verifyImageLength(value);
                                /* Trim off the leading and trailing ', and compress all '' to ' */
                                if (value.startsWith("'") && value.endsWith("'"))
                                        value = StringUtil.compressQuotes(value.substring(1, value.length() - 1), SINGLEQUOTES);
                                /* Trim off the leading and trailing ", and compress all "" to " */
                                else if (value.startsWith("\"") && value.endsWith("\""))
                                        value = StringUtil.compressQuotes(value.substring(1, value.length() - 1), DOUBLEQUOTES);
                                else
                                        value = value.toUpperCase();
                                // Do not allow user to specify multiple values for the same key
                                if (properties.put(key, value) != null)
                                {
                                        {if (true) throw StandardException.newException(SQLState.LANG_DUPLICATE_PROPERTY, key);}
                                }
                }
        }
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

      return null;
    }

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = null;
       
    try {
           
            finfo = getAttributes(url, info);
            info = null; // ensure we don't use this reference directly again.

      /*
      ** A property "shutdown=true" means shut the system or database down
      */
      boolean shutdown = Boolean.valueOf(finfo.getProperty(Attribute.SHUTDOWN_ATTR)).booleanValue();
     
      if (shutdown) {       
        // If we are shutting down the system don't attempt to create
        // a connection; but we validate users credentials if we have to.
        // In case of datbase shutdown, we ask the database authentication
        // service to authenticate the user. If it is a system shutdown,
        // then we ask the Driver to do the authentication.
        //
        if (InternalDriver.getDatabaseName(url, finfo).length() == 0) {
          //
          // We need to authenticate the user if authentication is
          // ON. Note that this is a system shutdown.
          // check that we do have a authentication service
          // it is _always_ expected.
          if (this.getAuthenticationService() == null)
            throw Util.generateCsSQLException(
                        SQLState.LOGIN_FAILED,
            MessageService.getTextMessage(MessageId.AUTH_NO_SERVICE_FOR_SYSTEM));
         
           
          if (!this.getAuthenticationService().authenticate((String) null, finfo)) {

            // not a valid user
            throw Util.generateCsSQLException(
                                    SQLState.NET_CONNECT_AUTH_FAILED,
                                    MessageService.
                                    getTextMessage(MessageId.AUTH_INVALID));
          }

                    // DERBY-2905, allow users to provide deregister attribute to
                    // leave AutoloadedDriver registered in DriverManager, default
                    // value is true
                    if (finfo.getProperty(Attribute.DEREGISTER_ATTR) != null) {
                        boolean deregister = Boolean.valueOf(
                                finfo.getProperty(Attribute.DEREGISTER_ATTR))
                                .booleanValue();
                        InternalDriver.setDeregister(deregister);
                    }

          // check for shutdown privileges
          // DERBY-3495: uncomment to enable system privileges checks
          //final String user = IdUtil.getUserNameFromURLProps(finfo);
          //checkShutdownPrivileges(user);

          Monitor.getMonitor().shutdown();

          throw Util.generateCsSQLException(
                                         SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
        }
      }

            EmbedConnection conn;
     
            if ( loginTimeoutSeconds <= 0 ) { conn = getNewEmbedConnection( url, finfo ); }
            else { conn = timeLogin( url, finfo, loginTimeoutSeconds ); }
           
      // if this is not the correct driver a EmbedConnection
      // object is returned in the closed state.
      if (conn.isClosed()) {
        return null;
      }

      return conn;
    }
    catch (OutOfMemoryError noMemory)
    {
      EmbedConnection.memoryState.setLowMemory();
      throw EmbedConnection.NO_MEM;
    }
    finally {
      // break any link with the user's Properties set.
            if (finfo != null)
          finfo.clearDefaults();
    }
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

  protected FormatableProperties getAttributes(String url, Properties info)
    throws SQLException {

    // We use FormatableProperties here to take advantage
    // of the clearDefaults, method.
    FormatableProperties finfo = new FormatableProperties(info);
    info = null; // ensure we don't use this reference directly again.


    StringTokenizer st = new StringTokenizer(url, ";");
    st.nextToken(); // skip the first part of the url

    while (st.hasMoreTokens()) {

      String v = st.nextToken();

      int eqPos = v.indexOf('=');
      if (eqPos == -1)
        throw Util.generateCsSQLException(
                                            SQLState.MALFORMED_URL, url);

      //if (eqPos != v.lastIndexOf('='))
      //  throw Util.malformedURL(url);

      finfo.put((v.substring(0, eqPos)).trim(),
           (v.substring(eqPos + 1)).trim()
          );
    }

    // now validate any attributes we can
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

        String dbname = InternalDriver.getDatabaseName(url, info);

        // convert the ;name=value attributes in the URL into
        // properties.
        FormatableProperties finfo = getAttributes(url, info);
        info = null; // ensure we don't use this reference directly again.
        boolean encryptDB = Boolean.valueOf(finfo.getProperty(Attribute.DATA_ENCRYPTION)).booleanValue();
        String encryptpassword = finfo.getProperty(Attribute.BOOT_PASSWORD);

        if (dbname.length() == 0 || (encryptDB && encryptpassword == null)) {

            // with no database name we can have shutdown or a database name

            // In future, if any new attribute info needs to be included in this
            // method, it just has to be added to either string or boolean or secret array
            // depending on whether it accepts string or boolean or secret(ie passwords) value.

            String[][] connStringAttributes = {
                {Attribute.DBNAME_ATTR, MessageId.CONN_DATABASE_IDENTITY},
                {Attribute.CRYPTO_PROVIDER, MessageId.CONN_CRYPTO_PROVIDER},
                {Attribute.CRYPTO_ALGORITHM, MessageId.CONN_CRYPTO_ALGORITHM},
                {Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
                {Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
                {Attribute.TERRITORY, MessageId.CONN_LOCALE},
                {Attribute.COLLATION, MessageId.CONN_COLLATION},
                {Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
                {Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
                {Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},
                {Attribute.CREATE_FROM, MessageId.CONN_CREATE_FROM},
                {Attribute.RESTORE_FROM, MessageId.CONN_RESTORE_FROM},
            };

            String[][] connBooleanAttributes = {
                {Attribute.SHUTDOWN_ATTR, MessageId.CONN_SHUT_DOWN_CLOUDSCAPE},
                {Attribute.DEREGISTER_ATTR, MessageId.CONN_DEREGISTER_AUTOLOADEDDRIVER},
                {Attribute.CREATE_ATTR, MessageId.CONN_CREATE_DATABASE},
                {Attribute.DATA_ENCRYPTION, MessageId.CONN_DATA_ENCRYPTION},
                {Attribute.UPGRADE_ATTR, MessageId.CONN_UPGRADE_DATABASE},
                };

            String[][] connStringSecretAttributes = {
                {Attribute.BOOT_PASSWORD, MessageId.CONN_BOOT_PASSWORD},
                {Attribute.PASSWORD_ATTR, MessageId.CONN_PASSWORD_ATTR},
                };


            DriverPropertyInfo[] optionsNoDB = new  DriverPropertyInfo[connStringAttributes.length+
                                                                      connBooleanAttributes.length+
                                                                      connStringSecretAttributes.length];

            int attrIndex = 0;
            for( int i = 0; i < connStringAttributes.length; i++, attrIndex++ )
            {
                optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringAttributes[i][0],
                                      finfo.getProperty(connStringAttributes[i][0]));
                optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringAttributes[i][1]);
            }

            optionsNoDB[0].choices = Monitor.getMonitor().getServiceList(Property.DATABASE_MODULE);
            // since database name is not stored in FormatableProperties, we
            // assign here explicitly
            optionsNoDB[0].value = dbname;

            for( int i = 0; i < connStringSecretAttributes.length; i++, attrIndex++ )
            {
                optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringSecretAttributes[i][0],
                                      (finfo.getProperty(connStringSecretAttributes[i][0]) == null? "" : "****"));
                optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringSecretAttributes[i][1]);
            }

            for( int i = 0; i < connBooleanAttributes.length; i++, attrIndex++ )
            {
                optionsNoDB[attrIndex] = new DriverPropertyInfo(connBooleanAttributes[i][0],
                    Boolean.valueOf(finfo == null? "" : finfo.getProperty(connBooleanAttributes[i][0])).toString());
                optionsNoDB[attrIndex].description = MessageService.getTextMessage(connBooleanAttributes[i][1]);
                optionsNoDB[attrIndex].choices = BOOLEAN_CHOICES;
            }

            return optionsNoDB;
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

    this.rowsInput = rowsInput;
    this.rowsReturned = rowsReturned;
    this.eliminateDuplicates = eliminateDuplicates;
    this.inSortedOrder = inSortedOrder;
    this.childResultSetStatistics = childResultSetStatistics;
    this.sortProperties = new FormatableProperties();
    for (Enumeration e = sortProperties.keys(); e.hasMoreElements(); )
    {
      String key = (String)e.nextElement();
      this.sortProperties.put(key, sortProperties.get(key));
    }
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

           (UUID)stmtID,
           (UUID)timingID);
    }
    public Object getSortPropsDescriptor(Object sortPropsID)
    {
        FormatableProperties props = this.sortProperties;
       
        // create new scan info descriptor with some basic information
        XPLAINSortPropsDescriptor sortRSDescriptor =           
          new XPLAINSortPropsDescriptor(
              (UUID)sortPropsID,      // the sort props UUID
View Full Code Here

Examples of org.apache.derby.iapi.services.io.FormatableProperties

      optimizerEstimatedCost
      );
    this.hashtableSize = hashtableSize;
    this.hashKeyColumns = ArrayUtil.copy( hashKeyColumns );
    this.nextQualifiers = nextQualifiers;
    this.scanProperties = new FormatableProperties();
    if (scanProperties != null)
    {
      for (Enumeration e = scanProperties.keys(); e.hasMoreElements(); )
      {
        String key = (String)e.nextElement();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.