Ejemplo n.º 1
0
  private void upgradeZimbraGalLdapAttrMap() throws ServiceException {
    final String attrName = Provisioning.A_zimbraGalLdapAttrMap;

    final String valueToRemove =
        "binary zimbraPrefMailSMIMECertificate,userCertificate,userSMIMECertificate=SMIMECertificate";

    final String[] valuesToAdd =
        new String[] {
          "(certificate) userCertificate=userCertificate",
          "(binary) userSMIMECertificate=userSMIMECertificate"
        };

    Config config = prov.getConfig();

    Map<String, Object> attrs = new HashMap<String, Object>();

    Set<String> curValues = config.getMultiAttrSet(attrName);
    if (curValues.contains(valueToRemove)) {
      StringUtil.addToMultiMap(attrs, "-" + attrName, valueToRemove);
    }

    for (String valueToAdd : valuesToAdd) {
      if (!curValues.contains(valueToAdd)) {
        StringUtil.addToMultiMap(attrs, "+" + attrName, valueToAdd);
      }
    }

    modifyAttrs(config, attrs);
  }
Ejemplo n.º 2
0
 private AuthToken getAuthTokenForApp(
     HttpServletRequest req, HttpServletResponse resp, boolean doNotSendHttpError)
     throws IOException, ServiceException {
   Config config = Provisioning.getInstance().getConfig();
   int adminPort = config.getIntAttr(Provisioning.A_zimbraAdminPort, 0);
   if (adminPort == req.getLocalPort()) {
     return getAdminAuthTokenFromCookie(req, resp, doNotSendHttpError);
   }
   return getAuthTokenFromCookie(req, resp, doNotSendHttpError);
 }
Ejemplo n.º 3
0
 protected SoapCLI() throws ServiceException {
   // get admin username from local config
   mUser = LC.zimbra_ldap_user.value();
   // get password from localconfig
   mPassword = LC.zimbra_ldap_password.value();
   // host can be specified
   mHost = "localhost";
   // get admin port number from provisioning
   com.zimbra.cs.account.Config conf = null;
   try {
     conf = Provisioning.getInstance().getConfig();
   } catch (ServiceException e) {
     throw ServiceException.FAILURE("Unable to connect to LDAP directory", e);
   }
   mPort = conf.getIntAttr(Provisioning.A_zimbraAdminPort, 0);
   if (mPort == 0)
     throw ServiceException.FAILURE("Unable to get admin port number from provisioning", null);
   mOptions = new Options();
   mHiddenOptions = new Options();
 }
Ejemplo n.º 4
0
 /**
  * If the configured Message-ID cache size has changed, create a new cache and copy values from
  * the old one.
  */
 private void checkDedupeCacheSize() {
   try {
     Config config = Provisioning.getInstance().getConfig();
     int cacheSize = config.getMessageIdDedupeCacheSize();
     long entryTimeout = config.getMessageIdDedupeCacheTimeout();
     synchronized (ZimbraLmtpBackend.class) {
       Map<String, Set<Integer>> newMap = null;
       if (receivedMessageIDs == null) {
         // if non-zero entry timeout is specified then use a timeout map, else use an lru map
         receivedMessageIDs =
             entryTimeout == 0
                 ? new LruMap<String, Set<Integer>>(cacheSize)
                 : new TimeoutMap<String, Set<Integer>>(entryTimeout);
       } else if (receivedMessageIDs instanceof LruMap) {
         if (entryTimeout != 0) {
           // change to a timeout map
           newMap = MapUtil.newTimeoutMap(entryTimeout);
         } else if (((LruMap) receivedMessageIDs).getMaxSize() != cacheSize) {
           // adjust lru map size
           newMap = MapUtil.newLruMap(cacheSize);
         }
       } else if (receivedMessageIDs instanceof TimeoutMap) {
         if (entryTimeout == 0) {
           // change to a lru map
           newMap = MapUtil.newLruMap(cacheSize);
         } else {
           ((TimeoutMap) receivedMessageIDs).setTimeout(entryTimeout);
         }
       }
       if (newMap != null) {
         // Copy entries from the old map to the new one.  The old map
         // is iterated in order from least-recently accessed to last accessed.
         // If the new map size is smaller, we'll get the latest entries.
         newMap.putAll(receivedMessageIDs);
         receivedMessageIDs = newMap;
       }
     }
   } catch (ServiceException e) {
     ZimbraLog.lmtp.warn("Unable to update dedupe cache size.", e);
   }
 }
Ejemplo n.º 5
0
  @Override
  void doUpgrade() throws ServiceException {
    Config config = prov.getConfig();

    String oldValue = "displayName,cn=fullName";
    String newValue =
        "displayName,cn=fullName,fullName2,fullName3,fullName4,fullName5,fullName6,fullName7,fullName8,fullName9,fullName10";

    String[] curValues = config.getMultiAttr(Provisioning.A_zimbraGalLdapAttrMap);

    for (String value : curValues) {
      if (value.equalsIgnoreCase(oldValue)) {
        Map<String, Object> attr = new HashMap<String, Object>();
        attr.put("-" + Provisioning.A_zimbraGalLdapAttrMap, oldValue);
        attr.put("+" + Provisioning.A_zimbraGalLdapAttrMap, newValue);

        printer.println("Modifying " + Provisioning.A_zimbraGalLdapAttrMap + " on global config:");
        printer.println("    removing value: " + oldValue);
        printer.println("    adding value: " + newValue);
        prov.modifyAttrs(config, attr);
      }
    }
  }
Ejemplo n.º 6
0
 public static String getDomain() throws ServiceException {
   Config config = Provisioning.getInstance().getConfig(Provisioning.A_zimbraDefaultDomainName);
   String domain = config.getAttr(Provisioning.A_zimbraDefaultDomainName, null);
   assert (domain != null && domain.length() > 0);
   return domain;
 }