mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/encryption/EncryptMessageServiceImpl.java
@Activate
    public void activate(final BundleContext context)
            throws IOException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException
    {
        // Bouncy castle provider is added during execution
        Security.addProvider(new BouncyCastleProvider());
        m_Input = Cipher.getInstance(FULL_ENCRYPT_ALGORITHM, BOUNCY_CASTLE_PROVIDER);
        m_Output = Cipher.getInstance(FULL_ENCRYPT_ALGORITHM, BOUNCY_CASTLE_PROVIDER);
        final String dataDir = context.getProperty(SystemConfigurationConstants.DATA_DIR_PROPERTY);
        final String dir = dataDir + File.separator + "encrypt-conf";
        
        //open up the files
        m_PropFileAuthorized = new File(dir, PROP_FILE_NAME_AUTHORIZED);
        m_PropAuthorized = new Properties();
        m_PropFilePublic = new File(dir, PROP_FILE_NAME_PUBLIC);
        m_PropPublic = new Properties();
        m_PropFilePrivate = new File(dir, PROP_FILE_NAME_PRIVATE);
        m_PropPrivate = new Properties();
        
        try (FileInputStream inputStreamAuthorized = new FileInputStream(m_PropFileAuthorized))
        {
            m_PropAuthorized.load(inputStreamAuthorized);
        }
        catch (final FileNotFoundException ex)
        {
            m_Logging.warning("authorized keys file not found");
        }
        
        try (FileInputStream inputStreamPublic = new FileInputStream(m_PropFilePublic))
        {
            m_PropPublic.load(inputStreamPublic);
        }
        catch (final FileNotFoundException ex)
        {
            m_Logging.warning("public key file not found");
        }
        
        try (FileInputStream inputStreamPrivate = new FileInputStream(m_PropFilePrivate))
        {
            m_PropPrivate.load(inputStreamPrivate);
        }
        catch (final FileNotFoundException ex)
        {
            m_Logging.warning("private key file not found");
        }
    }
/**
     * Activate the encryption component.
     * <p>
     * We have three files for each system. one file is for saving all static public key,
     * second file is used for saving all static private key and third file is used for saving
     * all the public remote keys for all systems. 
     * 
     * @param context
     *      this bundle's context
     * @throws IOException 
     *         Component is not activated if there is an IOException
     * @throws NoSuchPaddingException 
     *         Incorrect Padding argument, should be NoPadding.
     * @throws NoSuchProviderException 
     *         Incorrect name of the provider, should be BC.
     * @throws NoSuchAlgorithmException 
     *         Incorrect name of the algorithm, should be AES.
     */
Activate the encryption component.

We have three files for each system. one file is for saving all static public key,
second file is used for saving all static private key and third file is used for saving
all the public remote keys for all systems.

@param context
this bundle's context
@throws IOException
Component is not activated if there is an IOException
@throws NoSuchPaddingException
Incorrect Padding argument, should be NoPadding.
@throws NoSuchProviderException
Incorrect name of the provider, should be BC.
@throws NoSuchAlgorithmException
Incorrect name of the algorithm, should be AES.
Activate the encryption component . We have three files for each system . one file is for saving all static public key second file is used for saving all static private key and third file is used for saving all the public remote keys for all systems . @param context this bundle ' s context @throws IOException Component is not activated if there is an IOException @throws NoSuchPaddingException Incorrect Padding argument should be NoPadding . @throws NoSuchProviderException Incorrect name of the provider should be BC . @throws NoSuchAlgorithmException Incorrect name of the algorithm should be AES .
@Activate
    public void activate(final BundleContext context)
            throws IOException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException
    {
        Security.addProvider(new BouncyCastleProvider());
        m_Input = Cipher.getInstance(FULL_ENCRYPT_ALGORITHM, BOUNCY_CASTLE_PROVIDER);
        m_Output = Cipher.getInstance(FULL_ENCRYPT_ALGORITHM, BOUNCY_CASTLE_PROVIDER);
        final String dataDir = context.getProperty(SystemConfigurationConstants.DATA_DIR_PROPERTY);
        final String dir = dataDir + File.separator + "encrypt-conf";
        m_PropFileAuthorized = new File(dir, PROP_FILE_NAME_AUTHORIZED);
        m_PropAuthorized = new Properties();
        m_PropFilePublic = new File(dir, PROP_FILE_NAME_PUBLIC);
        m_PropPublic = new Properties();
        m_PropFilePrivate = new File(dir, PROP_FILE_NAME_PRIVATE);
        m_PropPrivate = new Properties();
        try (FileInputStream inputStreamAuthorized = new FileInputStream(m_PropFileAuthorized))
        {
            m_PropAuthorized.load(inputStreamAuthorized);
        }
        catch (final FileNotFoundException ex)
        {
            m_Logging.warning("authorized keys file not found");
        }
        try (FileInputStream inputStreamPublic = new FileInputStream(m_PropFilePublic))
        {
            m_PropPublic.load(inputStreamPublic);
        }
        catch (final FileNotFoundException ex)
        {
            m_Logging.warning("public key file not found");
        }
        try (FileInputStream inputStreamPrivate = new FileInputStream(m_PropFilePrivate))
        {
            m_PropPrivate.load(inputStreamPrivate);
        }
        catch (final FileNotFoundException ex)
        {
            m_Logging.warning("private key file not found");
        }
    }
@ Activate public void activate ( final BundleContext context ) throws IOException , NoSuchAlgorithmException , NoSuchProviderException , NoSuchPaddingException { Security . addProvider ( new BouncyCastleProvider ( ) ) ; m_Input = Cipher . getInstance ( FULL_ENCRYPT_ALGORITHM , BOUNCY_CASTLE_PROVIDER ) ; m_Output = Cipher . getInstance ( FULL_ENCRYPT_ALGORITHM , BOUNCY_CASTLE_PROVIDER ) ; final String dataDir = context . getProperty ( SystemConfigurationConstants . DATA_DIR_PROPERTY ) ; final String dir = dataDir + File . separator + "encrypt-conf" ; m_PropFileAuthorized = new File ( dir , PROP_FILE_NAME_AUTHORIZED ) ; m_PropAuthorized = new Properties ( ) ; m_PropFilePublic = new File ( dir , PROP_FILE_NAME_PUBLIC ) ; m_PropPublic = new Properties ( ) ; m_PropFilePrivate = new File ( dir , PROP_FILE_NAME_PRIVATE ) ; m_PropPrivate = new Properties ( ) ; try ( FileInputStream inputStreamAuthorized = new FileInputStream ( m_PropFileAuthorized ) ) { m_PropAuthorized . load ( inputStreamAuthorized ) ; } catch ( final FileNotFoundException ex ) { m_Logging . warning ( "authorized keys file not found" ) ; } try ( FileInputStream inputStreamPublic = new FileInputStream ( m_PropFilePublic ) ) { m_PropPublic . load ( inputStreamPublic ) ; } catch ( final FileNotFoundException ex ) { m_Logging . warning ( "public key file not found" ) ; } try ( FileInputStream inputStreamPrivate = new FileInputStream ( m_PropFilePrivate ) ) { m_PropPrivate . load ( inputStreamPrivate ) ; } catch ( final FileNotFoundException ex ) { m_Logging . warning ( "private key file not found" ) ; } }
Activate the encryption component.
Activate the encryption component .
// Bouncy castle provider is added during execution //open up the files