0 Replies Latest reply on Jun 2, 2009 8:58 AM by Vanitha Palanichamy

    Email Gateway Password

    Vanitha Palanichamy Newbie

      Hi,

      I have the inbound email gateway password in the encrypted form
      and I have to decrypt the password and use it to connect to the email server.


      I have the end point class EmailGateway created and has a constructor
      accepting ConfigTree
      public class EmailGateway
      implements InflowGateway, MailListener
      {
      private ServiceInvoker invoker;
      private ConfigTree _config;

      public EmailGateway(ConfigTree config) throws ConfigurationException
      {}
      }

      I get the encrypted password from Config Tree decrypt and set it back on ConfigTree.

      For some reason it is not using the decrypted password.

      The code to set it back on Config Tree

      ConfigTree spec = config.getFirstChild(JcaConstants.ELEMENT_ACTIVATION_CONFIG);
      String emailGatewayEncryptedPassword = null;
      String emailGatewayDecryptedPassword = null;
      HashMap<String, String> activationSpec = new HashMap<String, String>();
      if (spec != null)
      {
      for (ConfigTree configProperty : spec.getChildren(JcaConstants.ELEMENT_PROPERTY))
      {
      String name = configProperty.getAttribute(JcaConstants.ATTRIBUTE_NAME);
      String value = configProperty.getAttribute(JcaConstants.ATTRIBUTE_VALUE);

      if (name.equals("password"))
      {
      emailGatewayEncryptedPassword = value;
      log.info("emailGatewayEncryptedPassword='" + emailGatewayEncryptedPassword + "'");

      try
      {
      emailGatewayDecryptedPassword = (StringEncrypterUtil
      .chars2String(StringEncrypterUtil
      .decryptPassPhrase(emailGatewayEncryptedPassword.toCharArray())));

      }
      catch (GeneralSecurityException e)
      {
      log.error("Failed to decrypt ftp gateway password.", e);
      throw new IllegalArgumentException(e);
      }
      log.info("emailGatewayDecryptedPassword='" + emailGatewayDecryptedPassword + "'");
      configProperty.setAttribute(JcaConstants.ATTRIBUTE_VALUE,
      emailGatewayDecryptedPassword);
      break;
      }

      log.info("name='" + name + "'" + "-" + " value='" + value + "'");
      activationSpec.put(name, value);
      }
      }
      this._config = config;



      Here is what I have in jboss-esb.properties file




      <jca-gateway name="Mail-JCA-Gateway"
      adapter="mail-ra.rar"
      endpointClass="org.nhheaf.esb.nchelp.listeners.gateway.EmailGateway"
      is-gateway="true" transacted="false">
      <activation-config>






      </activation-config>
      </jca-gateway>
      <jms-listener name="JMS-ESBListener"
      busidref="nchelpMailInboundEsbChannel"
      maxThreads="1"
      />






      Am I doing something wrong.


      Any help will be appreciated.

      Thanks
      Vanitha