Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * =============================================================================
   * 
   *   Copyright (c) 2007, The JASYPT team (http://www.jasypt.org)
   * 
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   * 
  *       http://www.apache.org/licenses/LICENSE-2.0
  * 
  *   Unless required by applicable law or agreed to in writing, software
  *   distributed under the License is distributed on an "AS IS" BASIS,
  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  * 
  * =============================================================================
  */
 package org.jasypt.encryption.pbe.config;
 

Implementation for PBEConfig which can retrieve configuration values from environment variables or system properties.

The name of the environment variable or system property (JVM property) to query for each parameter can be set with its corresponding setXEnvName or setXSysProperty method.

As this class extends SimplePBEConfig, parameter values can be also set with the usual setX methods.

For any of the configuration parameters, if its value is not configured in any way, a null value will be returned by the corresponding getX method.

Author(s):
Daniel Fernández Garrido
Since:
1.1
 
 public class EnvironmentPBEConfig extends SimplePBEConfig {
     
     private static final long serialVersionUID = -3471444970805905683L;
     
     private String algorithmEnvName = null;
     private String keyObtentionIterationsEnvName = null;
     private String passwordEnvName = null;
 
     private String algorithmSysPropertyName = null;
     private String keyObtentionIterationsSysPropertyName = null;
     private String passwordSysPropertyName = null;
    

    

Creates a new EnvironmentPBEConfig instance.

 
     public EnvironmentPBEConfig() {
         super();
     }



    
Retrieve the name of the environment variable which value has been loaded as the algorithm.

Returns:
the name of the variable
 
     public String getAlgorithmEnvName() {
         return ;
     }


    
Set the config object to use the specified environment variable to load the value for the algorithm.

Parameters:
algorithmEnvName the name of the environment variable
 
     public void setAlgorithmEnvName(String algorithmEnvName) {
         this. = algorithmEnvName;
         if (algorithmEnvName == null) {
             super.setAlgorithm(null);
         } else {
             this. = null;
             super.setAlgorithm(System.getenv(algorithmEnvName));
         }
     }


    
Retrieve the name of the JVM system property which value has been loaded as the algorithm.

Returns:
the name of the property
        return ;
    }


    
Set the config object to use the specified JVM system property to load the value for the algorithm.

Parameters:
algorithmSysPropertyName the name of the property
    public void setAlgorithmSysPropertyName(String algorithmSysPropertyName) {
        this. = algorithmSysPropertyName;
        if (algorithmSysPropertyName == null) {
            super.setAlgorithm(null);
        } else {
            this. = null;
            super.setAlgorithm(System.getProperty(algorithmSysPropertyName));
        }
    }


    
Retrieve the name of the environment variable which value has been loaded as the key obtention iteration count.

Returns:
the name of the variable
        return ;
    }


    
Set the config object to use the specified environment variable to load the value for the key obtention iteration count.

Parameters:
keyObtentionIterationsEnvName the name of the environment variable
    public void setKeyObtentionIterationsEnvName(String keyObtentionIterationsEnvName) {
        this. = keyObtentionIterationsEnvName;
        if (keyObtentionIterationsEnvName == null) {
            super.setKeyObtentionIterations(null);
        } else {
            this. = null;
            String iterationsStr = System.getenv(keyObtentionIterationsEnvName);
            if (iterationsStr != null) {
                try {
                    super.setKeyObtentionIterations(new Integer(iterationsStr));
                } catch (NumberFormatException e) {
                    throw new EncryptionInitializationException(e);
                }
            }
        }
    }


    
Retrieve the name of the JVM system property which value has been loaded as the key obtention iteration count.

Returns:
the name of the property
    }


    
Set the config object to use the specified JVM system property to load the value for the key obtention iteration count.

Parameters:
keyObtentionIterationsSysPropertyName the name of the property
    public void setKeyObtentionIterationsSysPropertyName(String keyObtentionIterationsSysPropertyName) {
        this. = keyObtentionIterationsSysPropertyName;
        if (keyObtentionIterationsSysPropertyName == null) {
            super.setKeyObtentionIterations(null);
        } else {
            this. = null;
            String iterationsStr = System.getProperty(keyObtentionIterationsSysPropertyName);
            if (iterationsStr != null) {
                try {
                    super.setKeyObtentionIterations(new Integer(iterationsStr));
                } catch (NumberFormatException e) {
                    throw new EncryptionInitializationException(e);
                }
            }
        }
    }


    
Retrieve the name of the environment variable which value has been loaded as the password.

Returns:
the name of the variable
    public String getPasswordEnvName() {
        return ;
    }


    
Set the config object to use the specified environment variable to load the value for the password.

Parameters:
passwordEnvName the name of the environment variable
    public void setPasswordEnvName(String passwordEnvName) {
        this. = passwordEnvName;
        if (passwordEnvName == null) {
            super.setPassword(null);
        } else {
            this. = null;
            super.setPassword(System.getenv(passwordEnvName));
        }
    }


    
Retrieve the name of the JVM system property which value has been loaded as the password.

Returns:
the name of the property
        return ;
    }


    
Set the config object to use the specified JVM system property to load the value for the password.

Parameters:
passwordSysPropertyName the name of the property
    public void setPasswordSysPropertyName(String passwordSysPropertyName) {
        this. = passwordSysPropertyName;
        if (passwordSysPropertyName == null) {
            super.setPassword(null);
        } else {
            this. = null;
            super.setPassword(System.getProperty(passwordSysPropertyName));
        }
    }
    
    
    
    public void setAlgorithm(String algorithm) {
        this. = null;
        this. = null;
        super.setAlgorithm(algorithm);
    }
    public void setKeyObtentionIterations(Integer keyObtentionIterations) {
        this. = null;
        this. = null;
        super.setKeyObtentionIterations(keyObtentionIterations);
    }
    public void setPassword(String password) {
        this. = null;
        this. = null;
        super.setPassword(password);
    }
    
New to GrepCode? Check out our FAQ X