本文整理汇总了Java中org.ldaptive.LdapAttribute.isBinary方法的典型用法代码示例。如果您正苦于以下问题:Java LdapAttribute.isBinary方法的具体用法?Java LdapAttribute.isBinary怎么用?Java LdapAttribute.isBinary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ldaptive.LdapAttribute
的用法示例。
在下文中一共展示了LdapAttribute.isBinary方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例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;
}
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;
}
示例4: getGraphics
import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
@Override
public ByteSource getGraphics(final String username) {
try {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final Response<SearchResult> response = searchForId(username);
if (LdapUtils.containsResultEntry(response)) {
final LdapEntry entry = response.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute(gua.getLdap().getImageAttribute());
if (attribute != null && attribute.isBinary()) {
return ByteSource.wrap(attribute.getBinaryValue());
}
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ByteSource.empty();
}
示例5: fetchCRLFromLdap
import org.ldaptive.LdapAttribute; //导入方法依赖的package包/类
/**
* Downloads a CRL from given LDAP url.
*
* @param r the resource that is the ldap url.
* @return the x 509 cRL
* @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 fetchCRLFromLdap(final Object r) throws CertificateException, IOException, CRLException {
try {
final String ldapURL = r.toString();
LOGGER.debug("Fetching CRL from ldap [{}]", ldapURL);
final Response<SearchResult> result = performLdapSearch(ldapURL);
if (result.getResultCode() == ResultCode.SUCCESS) {
final LdapEntry entry = result.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute(this.certificateAttribute);
if (attribute.isBinary()) {
LOGGER.debug("Located entry [{}]. Retrieving first attribute [{}]", entry, attribute);
return fetchX509CRLFromAttribute(attribute);
}
LOGGER.warn("Found certificate attribute [{}] but it is not marked as a binary attribute", this.certificateAttribute);
}
LOGGER.debug("Failed to execute the search [{}]", result);
throw new CertificateException("Failed to establish a connection ldap and search.");
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
throw new CertificateException(e.getMessage());
}
}
示例6: 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");
}
示例7: 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;
}