当前位置: 首页>>代码示例>>Java>>正文


Java DefaultClientAttribute类代码示例

本文整理汇总了Java中org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute的典型用法代码示例。如果您正苦于以下问题:Java DefaultClientAttribute类的具体用法?Java DefaultClientAttribute怎么用?Java DefaultClientAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultClientAttribute类属于org.apache.directory.shared.ldap.entry.client包,在下文中一共展示了DefaultClientAttribute类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAttribute

import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的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.client.DefaultClientAttribute; //导入依赖的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.client.DefaultClientAttribute; //导入依赖的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.client.DefaultClientAttribute; //导入依赖的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

示例5: replaceMod

import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的package包/类
private static Modification replaceMod(String attrName, String newValue) {
  return new ClientModification(
      REPLACE_ATTRIBUTE, new DefaultClientAttribute(attrName, newValue));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:5,代码来源:LdapSynchronizationFlowTest.java


注:本文中的org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。