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


Java NoSuchAttributeException类代码示例

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


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

示例1: validateEnvironment

import javax.naming.directory.NoSuchAttributeException; //导入依赖的package包/类
private void validateEnvironment(String certificatePrincipal) throws NamingException {

        String ou = getLDAPAttribute(certificatePrincipal, OU);
        LOGGER.debug("OU from certificate: ", ou);
        String location = getLDAPAttribute(certificatePrincipal, LOCATION);
        LOGGER.debug("Location from certificate: ", location);

        if(StringUtils.isBlank(ou)) {
            throw new NoSuchAttributeException("No ou in dn, you may need to update your certificate: " + certificatePrincipal);
        } else {
            if(allAccessOu.equalsIgnoreCase(StringUtils.replace(ou, " ", ""))){
                LOGGER.debug("Skipping environment validation, user ou matches {} ", allAccessOu);
            } else {
                //if dn not from allAccessOu, verify the location (l) field
                //in the cert matches the configured environment
                if(StringUtils.isBlank(location)) {
                    throw new NoSuchAttributeException("No location in dn, you may need to update your certificate: " + certificatePrincipal);
                } else if(!locationMatchesEnvironment(location)){
                    throw new NoSuchAttributeException("Invalid location from dn, expected " + environment + " but found l=" + location);
                }
            }
        }
    }
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:24,代码来源:CertLdapLoginModule.java

示例2: getLastValue

import javax.naming.directory.NoSuchAttributeException; //导入依赖的package包/类
/**
 * Returns the last recorded value taken from the given field along with the
 * time stamp identifying the time this value was recored.
 * <p>
 * 
 * @param fieldname
 *          the field whose value was recorded.
 * 
 * @return the last recorded value taken from the given field along with the
 *         time stamp identifying the time this value was recored.
 * 
 * @throws NoSuchAttributeException
 *           if no such field exists on the Object to inspect.
 * 
 */
public TimeStampedValue getLastValue(final String fieldname) throws NoSuchAttributeException {
  // search for the field
  int attribindex = -1;
  for (int i = this.m_fields.length - 1; i >= 0; i--) {
    if (this.m_fields[i].getName().equals(fieldname)) {
      attribindex = i;
      break;
    }
  }
  if (attribindex == -1) {
    throw new NoSuchAttributeException("The Attribute with the name: " + fieldname
        + " does not exist in " + this.m_toinspect.getClass().getName());
  }
  final ObjectInspection tmp = this.m_buffer.getYoungest();
  return new TimeStampedValue(tmp.getTime(), tmp.get(attribindex));
}
 
开发者ID:lcm-proj,项目名称:lcm,代码行数:32,代码来源:ObjectRecorder.java

示例3: removeUser

import javax.naming.directory.NoSuchAttributeException; //导入依赖的package包/类
public void removeUser(String username, String groupName) throws NamingException {

        try {
            ModificationItem[] mods = new ModificationItem[1];
            Attribute mod = new BasicAttribute("member", getUserDN(username));
            mods[0] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, mod);
            context.modifyAttributes(getGroupDN(groupName), mods);
        } catch (NoSuchAttributeException e) {
            // If user is not assigned, ignore the error
        }
    }
 
开发者ID:wso2,项目名称:msf4j,代码行数:12,代码来源:LDAPUserStoreManager.java

示例4: RemoveAttribute

import javax.naming.directory.NoSuchAttributeException; //导入依赖的package包/类
/**
 * Removes a Attribute from a Directory Entry.
 *
 * @param ctxSource current established Source JNDI Directory Context
 * @param SourceDN     current DN of Entry which is to be removed.
 * @param AttributeName     current Attribute Name to be removed.
 * @param _IgnoreNoSuchAttribute    indicates whether or not to ignore a NoSuchAttribute Exception.
 * @throws idxIRRException if any non-recoverable errors encountered.
 */
public void RemoveAttribute(DirContext ctxSource,
                            String SourceDN,
                            String AttributeName,
                            boolean _IgnoreNoSuchAttribute)
        throws idxIRRException {

    ;
    try {

        ModificationItem[] irrmods = new ModificationItem[1];
        irrmods[0] = new ModificationItem(
                DirContext.REMOVE_ATTRIBUTE,
                new BasicAttribute(AttributeName));

        ctxSource.modifyAttributes(SourceDN, irrmods);

    } catch (NoSuchAttributeException nsae) {
        if (_IgnoreNoSuchAttribute) {
            return;
        }
        throw new idxIRRException("Exception Performing IRR Removal of Attribute[" +
                AttributeName + "], from Entry[" +
                SourceDN + "],\n" + nsae);

    } catch (Exception e) {
        throw new idxIRRException("Exception Performing IRR Removal of Attribute[" +
                AttributeName + "], from Entry[" +
                SourceDN + "],\n" + e);
    } // End of Exception.
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:40,代码来源:idxIRRutil.java


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