コード例 #1
0
ファイル: BUG_58514.java プロジェクト: TaNhoSy/zimbra-mirror
  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);
  }
コード例 #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);
 }
コード例 #3
0
ファイル: SoapCLI.java プロジェクト: koem/Zimbra
 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();
 }
コード例 #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);
   }
 }
コード例 #5
0
ファイル: BUG_46961.java プロジェクト: huu0510/z-pec
  @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);
      }
    }
  }
コード例 #6
0
ファイル: AccountTestUtil.java プロジェクト: huu0510/z-pec
 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;
 }