當前位置: 首頁>>代碼示例>>Java>>正文


Java ModificationOperation類代碼示例

本文整理匯總了Java中org.apache.directory.shared.ldap.entry.ModificationOperation的典型用法代碼示例。如果您正苦於以下問題:Java ModificationOperation類的具體用法?Java ModificationOperation怎麽用?Java ModificationOperation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModificationOperation類屬於org.apache.directory.shared.ldap.entry包,在下文中一共展示了ModificationOperation類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAttribute

import org.apache.directory.shared.ldap.entry.ModificationOperation; //導入依賴的package包/類
public void addAttribute(String dn, String attrName, String attrValue)
    throws Exception {
  EntryAttribute attr = new DefaultClientAttribute(attrName, attrValue);
  Modification addValue = new ClientModification(
      ModificationOperation.ADD_ATTRIBUTE, attr);
  service.getAdminSession().modify(new DN(dn),
      Collections.singletonList(addValue));
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:9,代碼來源:LdapTestServer.java

示例2: removeAttribute

import org.apache.directory.shared.ldap.entry.ModificationOperation; //導入依賴的package包/類
public void removeAttribute(String dn, String attrName, String attrValue)
    throws Exception {
  EntryAttribute attr = new DefaultClientAttribute(attrName, attrValue);
  Modification removeValue = new ClientModification(
      ModificationOperation.REMOVE_ATTRIBUTE, attr);
  service.getAdminSession().modify(new DN(dn),
      Collections.singletonList(removeValue));
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:9,代碼來源:LdapTestServer.java

示例3: doPost

import org.apache.directory.shared.ldap.entry.ModificationOperation; //導入依賴的package包/類
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    Locale locale = req.getLocale();
    HttpSession session = req.getSession();
    if (session == null) {
        res.sendRedirect("/");
        return;
    }
    String userid = (String) session.getAttribute("userid");
    String password = StringUtils.trim(req.getParameter("password"));
    if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(password) && password.length() >= 8) {
        try {
            DefaultClientAttribute entryAttribute = new DefaultClientAttribute("userPassword", encodeForLDAP(password.trim()));
            ClientModification clientModification = new ClientModification();
            clientModification.setAttribute(entryAttribute);
            clientModification.setOperation(ModificationOperation.REPLACE_ATTRIBUTE);
            ModifyRequestImpl modifyRequest = new ModifyRequestImpl(1);
            modifyRequest.setName(new LdapDN("uid=" + encodeForLDAP(userid.trim()) + ",ou=people,dc=t246osslab,dc=org"));
            modifyRequest.addModification(clientModification);
            EmbeddedADS.getAdminSession().modify(modifyRequest);

            StringBuilder bodyHtml = new StringBuilder();
            bodyHtml.append("<form>");
            bodyHtml.append(getMsg("msg.passwd.changed", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append("<a href=\"/admins/main\">" + getMsg("label.goto.admin.page", locale) + "</a>");
            bodyHtml.append("</form>");
            responseToClient(req, res, getMsg("title.csrf.page", locale), bodyHtml.toString());
        } catch (Exception e) {
            log.error("Exception occurs: ", e);
            req.setAttribute("errorMessage", getErrMsg("msg.passwd.change.failed", locale));
            doGet(req, res);
        }
    } else {
        if (StringUtils.isBlank(password) || password.length() < 8) {
            req.setAttribute("errorMessage", getErrMsg("msg.passwd.is.too.short", locale));
        } else {
            req.setAttribute("errorMessage", getErrMsg("msg.unknown.exception.occur",
                    new String[] { "userid: " + userid }, locale));
        }
        doGet(req, res);
    }
}
 
開發者ID:k-tamura,項目名稱:easybuggy,代碼行數:44,代碼來源:CSRFServlet.java

示例4: doPost

import org.apache.directory.shared.ldap.entry.ModificationOperation; //導入依賴的package包/類
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    Locale locale = req.getLocale();
    HttpSession session = req.getSession();
    if (session == null) {
        res.sendRedirect("/");
        return;
    }
    String userid = (String) session.getAttribute("userid");
    if (userid == null) {
        res.sendRedirect("/");
        return;
    }
    String mail = StringUtils.trim(req.getParameter("mail"));
    if (!StringUtils.isBlank(mail) && EmailUtils.isValidEmailAddress(mail)) {
        try {
            DefaultClientAttribute entryAttribute = new DefaultClientAttribute("mail", encodeForLDAP(mail.trim()));
            ClientModification clientModification = new ClientModification();
            clientModification.setAttribute(entryAttribute);
            clientModification.setOperation(ModificationOperation.REPLACE_ATTRIBUTE);
            ModifyRequestImpl modifyRequest = new ModifyRequestImpl(1);
            modifyRequest.setName(new LdapDN("uid=" + encodeForLDAP(userid.trim()) + ",ou=people,dc=t246osslab,dc=org"));
            modifyRequest.addModification(clientModification);
            EmbeddedADS.getAdminSession().modify(modifyRequest);

            StringBuilder bodyHtml = new StringBuilder();
            bodyHtml.append("<form>");
            bodyHtml.append(getMsg("msg.mail.changed", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append("<a href=\"/admins/main\">" + getMsg("label.goto.admin.page", locale) + "</a>");
            bodyHtml.append("</form>");
            responseToClient(req, res, getMsg("title.clickjacking.page", locale), bodyHtml.toString());
        } catch (Exception e) {
            log.error("Exception occurs: ", e);
            req.setAttribute("errorMessage", getErrMsg("msg.mail.change.failed", locale));
            doGet(req, res);
        }
    } else {
        req.setAttribute("errorMessage", getErrMsg("msg.mail.format.is.invalid", locale));
        doGet(req, res);
    }
}
 
開發者ID:k-tamura,項目名稱:easybuggy,代碼行數:43,代碼來源:ClickJackingServlet.java


注:本文中的org.apache.directory.shared.ldap.entry.ModificationOperation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。