Example #1
0
 public void addLocalEntry(String sessionCookie, DataHandler dh)
     throws LocalEntryAdminException, IOException, XMLStreamException {
   AuthenticateStub.authenticateStub(sessionCookie, localEntryAdminServiceStub);
   XMLStreamReader parser =
       XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream());
   // create the builder
   StAXOMBuilder builder = new StAXOMBuilder(parser);
   OMElement localEntryElem = builder.getDocumentElement();
   localEntryAdminServiceStub.addEntry(localEntryElem.toString());
 }
  public void addLocalEntry(
      String userName, String password, String mailUserNAme, String mailPassword)
      throws EmailMonitorServiceException {
    CarbonUtils.setBasicAccessSecurityHeaders(userName, password, stub._getServiceClient());

    boolean isEmailEntryExist = false;
    boolean isPasswordEntryExist = false;
    try {
      String entrySet = stub.getEntryNamesString();
      isEmailEntryExist = entrySet.contains("[Entry]-email");
      isPasswordEntryExist = entrySet.contains("[Entry]-password");
    } catch (RemoteException e) {
      e.printStackTrace();
    } catch (LocalEntryAdminException e) {
      e.printStackTrace();
    }

    CryptographyManager cryptographyManager = new CryptographyManager();

    try {

      if (isEmailEntryExist) {
        stub.deleteEntry("email");
      }
      if (isPasswordEntryExist) {
        stub.deleteEntry("password");
      }
      stub.addEntry(
          "<localEntry key=\"email\"><email>"
              + mailUserNAme
              + "</email><description/></localEntry>");
      stub.addEntry(
          "<localEntry key=\"password\"><password>"
              + cryptographyManager.encryptAndBase64Encode(mailPassword)
              + "</password><description/></localEntry>");

    } catch (RemoteException e) {
      e.printStackTrace();
    } catch (LocalEntryAdminException e) {
      e.printStackTrace();
    }
  }