Package org.jasypt.encryption.pbe.config

Examples of org.jasypt.encryption.pbe.config.SimpleStringPBEConfig


    }
   
    //Initialize encryptor for migration during secret key change
    public static void initEncryptorForMigration(String secretKey){
        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
        stringConfig.setPassword(secretKey);
        s_encryptor.setConfig(stringConfig);
        s_useEncryption = true;
    }
View Full Code Here


    return true;
  }

  private void initEncryptor(StandardPBEStringEncryptor encryptor, String secretKey){
    encryptor.setAlgorithm("PBEWithMD5AndDES");
    SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
    stringConfig.setPassword(secretKey);
    encryptor.setConfig(stringConfig);
  }
View Full Code Here

            }

            s_encryptor.setAlgorithm("PBEWithMD5AndDES");
            String secretKey = null;

            SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();

            if(encryptionType.equals("file")){
                File keyFile = new File(s_keyFile);
                if (!keyFile.exists()) {
                    keyFile = new File(s_altKeyFile);
                }
                try {
                    BufferedReader in = new BufferedReader(new FileReader(keyFile));
                    secretKey = in.readLine();
                    //Check for null or empty secret key
                } catch (FileNotFoundException e) {
                    throw new CloudRuntimeException("File containing secret key not found: "+s_keyFile, e);
                } catch (IOException e) {
                    throw new CloudRuntimeException("Error while reading secret key from: "+s_keyFile, e);
                }

                if(secretKey == null || secretKey.isEmpty()){
                    throw new CloudRuntimeException("Secret key is null or empty in file "+s_keyFile);
                }

            } else if(encryptionType.equals("env")){
                secretKey = System.getenv(s_envKey);
                if(secretKey == null || secretKey.isEmpty()){
                    throw new CloudRuntimeException("Environment variable "+s_envKey+" is not set or empty");
                }
            } else if(encryptionType.equals("web")){
                ServerSocket serverSocket = null;
                int port = 8097;
                try {
                    serverSocket = new ServerSocket(port);
                } catch (IOException ioex) {
                    throw new CloudRuntimeException("Error initializing secret key reciever", ioex);
                }
                s_logger.info("Waiting for admin to send secret key on port "+port);
                Socket clientSocket = null;
                try {
                    clientSocket = serverSocket.accept();
                } catch (IOException e) {
                    throw new CloudRuntimeException("Accept failed on "+port);
                }
                PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
                BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                String inputLine;
                if ((inputLine = in.readLine()) != null) {
                    secretKey = inputLine;
                }
                out.close();
                in.close();
                clientSocket.close();
                serverSocket.close();
            } else {
                throw new CloudRuntimeException("Invalid encryption type: "+encryptionType);
            }

            stringConfig.setPassword(secretKey);
            s_encryptor.setConfig(stringConfig);
            s_useEncryption = true;
        } catch (FileNotFoundException e) {
            throw new CloudRuntimeException("File db.properties not found", e);
        } catch (IOException e) {
View Full Code Here

    }

    //Initialize encryptor for migration during secret key change
    public static void initEncryptorForMigration(String secretKey){
        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
        stringConfig.setPassword(secretKey);
        s_encryptor.setConfig(stringConfig);
        s_useEncryption = true;
    }
View Full Code Here

        }

        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        String secretKey = null;

        SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();

        if (encryptionType.equals("file")) {
            File keyFile = new File(s_keyFile);
            if (!keyFile.exists()) {
                keyFile = new File(s_altKeyFile);
            }
            BufferedReader in = null;
            try {
                in = new BufferedReader(new FileReader(keyFile));
                secretKey = in.readLine();
                //Check for null or empty secret key
            } catch (FileNotFoundException e) {
                throw new CloudRuntimeException("File containing secret key not found: " + s_keyFile, e);
            } catch (IOException e) {
                throw new CloudRuntimeException("Error while reading secret key from: " + s_keyFile, e);
            } finally {
                IOUtils.closeQuietly(in);
            }

            if (secretKey == null || secretKey.isEmpty()) {
                throw new CloudRuntimeException("Secret key is null or empty in file " + s_keyFile);
            }

        } else if (encryptionType.equals("env")) {
            secretKey = System.getenv(s_envKey);
            if (secretKey == null || secretKey.isEmpty()) {
                throw new CloudRuntimeException("Environment variable " + s_envKey + " is not set or empty");
            }
        } else if (encryptionType.equals("web")) {
            ServerSocket serverSocket = null;
            int port = 8097;
            try {
                serverSocket = new ServerSocket(port);
            } catch (IOException ioex) {
                throw new CloudRuntimeException("Error initializing secret key reciever", ioex);
            }
            s_logger.info("Waiting for admin to send secret key on port " + port);
            Socket clientSocket = null;
            try {
                clientSocket = serverSocket.accept();
            } catch (IOException e) {
                throw new CloudRuntimeException("Accept failed on " + port);
            }
            PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            String inputLine;
            if ((inputLine = in.readLine()) != null) {
                secretKey = inputLine;
            }
            out.close();
            in.close();
            clientSocket.close();
            serverSocket.close();
        } else {
            throw new CloudRuntimeException("Invalid encryption type: " + encryptionType);
        }

        stringConfig.setPassword(secretKey);
        s_encryptor.setConfig(stringConfig);
        s_useEncryption = true;
    }
View Full Code Here

    }

    //Initialize encryptor for migration during secret key change
    public static void initEncryptorForMigration(String secretKey) {
        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
        stringConfig.setPassword(secretKey);
        s_encryptor.setConfig(stringConfig);
        s_useEncryption = true;
    }
View Full Code Here

          }
         
          s_encryptor.setAlgorithm("PBEWithMD5AndDES");
          String secretKey = null;
         
          SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
         
          if(encryptionType.equals("file")){
            try {
              BufferedReader in = new BufferedReader(new FileReader(s_keyFile));
              secretKey = in.readLine();
              //Check for null or empty secret key
            } catch (FileNotFoundException e) {
              throw new CloudRuntimeException("File containing secret key not found: "+s_keyFile, e);
            } catch (IOException e) {
              throw new CloudRuntimeException("Error while reading secret key from: "+s_keyFile, e);
            }
           
            if(secretKey == null || secretKey.isEmpty()){
              throw new CloudRuntimeException("Secret key is null or empty in file "+s_keyFile);
            }
           
          } else if(encryptionType.equals("env")){
            secretKey = System.getenv(s_envKey);
            if(secretKey == null || secretKey.isEmpty()){
              throw new CloudRuntimeException("Environment variable "+s_envKey+" is not set or empty");
            }
          } else if(encryptionType.equals("web")){
            ServerSocket serverSocket = null;
            int port = 8097;
            try {
                    serverSocket = new ServerSocket(port);
                } catch (IOException ioex) {
                  throw new CloudRuntimeException("Error initializing secret key reciever", ioex);
                }
            s_logger.info("Waiting for admin to send secret key on port "+port);
            Socket clientSocket = null;
            try {
                clientSocket = serverSocket.accept();
            } catch (IOException e) {
              throw new CloudRuntimeException("Accept failed on "+port);
            }
            PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            String inputLine, outputLine;
            if ((inputLine = in.readLine()) != null) {
              secretKey = inputLine;
            }
            out.close();
            in.close();
            clientSocket.close();
            serverSocket.close();
          } else {
            throw new CloudRuntimeException("Invalid encryption type: "+encryptionType);
          }

          stringConfig.setPassword(secretKey);
      s_encryptor.setConfig(stringConfig);
      s_useEncryption = true;
        } catch (FileNotFoundException e) {
          throw new CloudRuntimeException("File db.properties not found", e);
        } catch (IOException e) {
View Full Code Here

    }
   
    //Initialize encryptor for migration during secret key change
    public static void initEncryptorForMigration(String secretKey){
      s_encryptor.setAlgorithm("PBEWithMD5AndDES");
      SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
      stringConfig.setPassword(secretKey);
    s_encryptor.setConfig(stringConfig);
    s_useEncryption = true;
    }
View Full Code Here

    return true;
  }

  private void initEncryptor(StandardPBEStringEncryptor encryptor, String secretKey){
    encryptor.setAlgorithm("PBEWithMD5AndDES");
    SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
    stringConfig.setPassword(secretKey);
    encryptor.setConfig(stringConfig);
  }
View Full Code Here

        return true;
    }

    private void initEncryptor(StandardPBEStringEncryptor encryptor, String secretKey) {
        encryptor.setAlgorithm("PBEWithMD5AndDES");
        SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig();
        stringConfig.setPassword(secretKey);
        encryptor.setConfig(stringConfig);
    }
View Full Code Here

TOP

Related Classes of org.jasypt.encryption.pbe.config.SimpleStringPBEConfig

Copyright © 2018 www.massapicom. 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.