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


Java LdapAttribute.getBinaryValue方法代码示例

本文整理汇总了Java中org.ldaptive.LdapAttribute.getBinaryValue方法的典型用法代码示例。如果您正苦于以下问题:Java LdapAttribute.getBinaryValue方法的具体用法?Java LdapAttribute.getBinaryValue怎么用?Java LdapAttribute.getBinaryValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ldaptive.LdapAttribute的用法示例。


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

示例1: getString

import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
 * Reads a String value from the LdapEntry.
 *
 * @param entry     the ldap entry
 * @param attribute the attribute name
 * @param nullValue the value which should be returning in case of a null value
 * @return the string
 */
public static String getString(final LdapEntry entry, final String attribute, final String nullValue) {
    final LdapAttribute attr = entry.getAttribute(attribute);
    if (attr == null) {
        return nullValue;
    }

    final String v;
    if (attr.isBinary()) {
        final byte[] b = attr.getBinaryValue();
        v = new String(b, Charset.forName("UTF-8"));
    } else {
        v = attr.getStringValue();
    }

    if (StringUtils.isNotBlank(v)) {
        return v;
    }
    return nullValue;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:LdapUtils.java

示例2: fetchX509CRLFromAttribute

import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
 * Gets x509 cRL from attribute. Retrieves the binary attribute value,
 * decodes it to base64, and fetches it as a byte-array resource.
 *
 * @param aval the attribute, which may be null if it's not found
 * @return the x 509 cRL from attribute
 * @throws Exception if attribute not found or could could not be decoded.
 */
protected X509CRL fetchX509CRLFromAttribute(final LdapAttribute aval) throws Exception {
    if (aval != null) {
        final byte[] val = aval.getBinaryValue();
        if (val == null || val.length == 0) {
            throw new CertificateException("Empty attribute. Can not download CRL from ldap");
        }
        final byte[] decoded64 = CompressionUtils.decodeBase64ToByteArray(val);
        if (decoded64 == null) {
            throw new CertificateException("Could not decode the attribute value to base64");
        }
        logger.debug("Retrieved CRL from ldap as byte array decoded in base64. Fetching...");
        return super.fetch(new ByteArrayResource(decoded64));
    }
    throw new CertificateException("Attribute not found. Can not retrieve CRL");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:LdaptiveResourceCRLFetcher.java

示例3: getString

import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
 * Reads a String value from the LdapEntry.
 *
 * @param entry       the ldap entry
 * @param attribute the attribute name
 * @param nullValue the value which should be returning in case of a null value
 * @return the string
 */
public static String getString(final LdapEntry entry, final String attribute, final String nullValue) {
    final LdapAttribute attr = entry.getAttribute(attribute);
    if (attr == null) {
        return nullValue;
    }

    String v = null;
    if (attr.isBinary()) {
        final byte[] b = attr.getBinaryValue();
        v = new String(b, Charset.forName("UTF-8"));
    } else {
        v = attr.getStringValue();
    }

    if (StringUtils.isNotBlank(v)) {
        return v;
    }
    return nullValue;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:LdapUtils.java

示例4: getString

import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
 * Reads a String value from the LdapEntry.
 *
 * @param entry     the ldap entry
 * @param attribute the attribute name
 * @param nullValue the value which should be returning in case of a null value
 * @return the string
 */
public static String getString(final LdapEntry entry, final String attribute, final String nullValue) {
    final LdapAttribute attr = entry.getAttribute(attribute);
    if (attr == null) {
        return nullValue;
    }

    final String v;
    if (attr.isBinary()) {
        final byte[] b = attr.getBinaryValue();
        v = new String(b, StandardCharsets.UTF_8);
    } else {
        v = attr.getStringValue();
    }

    if (StringUtils.isNotBlank(v)) {
        return v;
    }
    return nullValue;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:28,代码来源:LdapUtils.java

示例5: fetchX509CRLFromAttribute

import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
 * Gets x509 cRL from attribute. Retrieves the binary attribute value,
 * decodes it to base64, and fetches it as a byte-array resource.
 *
 * @param aval the attribute, which may be null if it's not found
 * @return the x 509 cRL from attribute
 * @throws IOException          the exception thrown if resources cant be fetched
 * @throws CRLException         the exception thrown if resources cant be fetched
 * @throws CertificateException if connection to ldap fails, or attribute to get the revocation list is unavailable
 */
protected X509CRL fetchX509CRLFromAttribute(final LdapAttribute aval) throws CertificateException, IOException, CRLException {
    if (aval != null && aval.isBinary()) {
        final byte[] val = aval.getBinaryValue();
        if (val == null || val.length == 0) {
            throw new CertificateException("Empty attribute. Can not download CRL from ldap");
        }
        final byte[] decoded64 = EncodingUtils.decodeBase64(val);
        if (decoded64 == null) {
            throw new CertificateException("Could not decode the attribute value to base64");
        }
        LOGGER.debug("Retrieved CRL from ldap as byte array decoded in base64. Fetching...");
        return super.fetch(new ByteArrayResource(decoded64));
    }
    throw new CertificateException("Attribute not found. Can not retrieve CRL");
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:LdaptiveResourceCRLFetcher.java

示例6: getString

import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
private String getString(final LdapEntry entry, final String attribute, final String nullValue) {
    final LdapAttribute attr = entry.getAttribute(attribute);
    if (attr == null) {
        return nullValue;
    }

    String v;
    if (attr.isBinary()) {
        final byte[] b = attr.getBinaryValue();
        v = new String(b, Charset.forName("UTF-8"));
    } else {
        v = attr.getStringValue();
    }

    if (StringUtils.isNotBlank(v)) {
        return v;
    }
    return nullValue;
}
 
开发者ID:bremersee,项目名称:fac,代码行数:20,代码来源:FailedAccessDefaultLdapMapper.java


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