use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class AbstractConnectionPool method getSchema.
/**
* Retrieves the directory server schema definitions that govern the specified
* entry using a connection from this connection pool. The subschemaSubentry
* attribute will be retrieved from the target entry, and then the appropriate
* schema definitions will be loaded from the entry referenced by that
* attribute. This may be necessary to ensure correct behavior in servers
* that support multiple schemas.
*
* @param entryDN The DN of the entry for which to retrieve the associated
* schema definitions. It may be {@code null} or an empty
* string if the subschemaSubentry attribute should be
* retrieved from the server's root DSE.
*
* @return The directory server schema definitions, or {@code null} if the
* schema information could not be retrieved (e.g, the client does
* not have permission to read the server schema).
*
* @throws LDAPException If a problem occurs while attempting to retrieve
* the server schema.
*/
@Override()
@Nullable()
public final Schema getSchema(@Nullable final String entryDN) throws LDAPException {
final LDAPConnection conn = getConnection();
try {
final Schema schema = conn.getSchema(entryDN);
releaseConnection(conn);
return schema;
} catch (final Throwable t) {
throwLDAPExceptionIfShouldNotRetry(t, OperationType.SEARCH, conn);
// If we have gotten here, then we should retry the operation with a
// newly-created connection.
final LDAPConnection newConn = replaceDefunctConnection(t, conn);
try {
final Schema schema = newConn.getSchema(entryDN);
releaseConnection(newConn);
return schema;
} catch (final Throwable t2) {
throwLDAPException(t2, newConn);
}
// This return statement should never be reached.
return null;
}
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class InterceptedOperation method getConnectedAddress.
/**
* {@inheritDoc}
*/
@Override()
@Nullable()
public String getConnectedAddress() {
if (clientConnection == null) {
return null;
}
final Socket s = clientConnection.getSocket();
if (s == null) {
return null;
}
final InetAddress localAddress = s.getLocalAddress();
if (localAddress == null) {
return null;
}
return localAddress.getHostAddress();
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class JNDIConverter method convertControl.
/**
* Converts the provided JNDI control to an LDAP SDK control.
*
* @param c The control to be converted.
*
* @return The LDAP SDK control that corresponds to the provided JNDI
* control.
*
* @throws NamingException If a problem is encountered during the conversion
* process.
*/
@Nullable
public static Control convertControl(@Nullable final javax.naming.ldap.Control c) throws NamingException {
if (c == null) {
return null;
}
final ASN1OctetString value;
final byte[] valueBytes = c.getEncodedValue();
if ((valueBytes == null) || (valueBytes.length == 0)) {
value = null;
} else {
try {
value = ASN1OctetString.decodeAsOctetString(valueBytes);
} catch (final ASN1Exception ae) {
throw new NamingException(StaticUtils.getExceptionMessage(ae));
}
}
return new Control(c.getID(), c.isCritical(), value);
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class JNDIConverter method convertSearchEntry.
/**
* Converts the provided LDAP SDK entry to a JNDI search result.
*
* @param e The entry to be converted to a JNDI search result.
* @param contextBaseDN The base DN for the JNDI context over which the
* search result was retrieved. If it is
* non-{@code null} and non-empty, then it will be
* removed from the end of the entry's DN in order to
* obtain the name for the {@code SearchResult} that is
* returned.
*
* @return The JNDI search result that corresponds to the provided LDAP SDK
* entry.
*/
@Nullable()
public static SearchResult convertSearchEntry(@Nullable final Entry e, @Nullable final String contextBaseDN) {
if (e == null) {
return null;
}
String name = e.getDN();
if ((contextBaseDN != null) && (!contextBaseDN.isEmpty())) {
try {
final DN parsedEntryDN = e.getParsedDN();
final DN parsedBaseDN = new DN(contextBaseDN);
if (parsedEntryDN.equals(parsedBaseDN)) {
name = "";
} else if (parsedEntryDN.isDescendantOf(parsedBaseDN, false)) {
final RDN[] entryRDNs = parsedEntryDN.getRDNs();
final RDN[] baseRDNs = parsedBaseDN.getRDNs();
final RDN[] remainingRDNs = new RDN[entryRDNs.length - baseRDNs.length];
System.arraycopy(entryRDNs, 0, remainingRDNs, 0, remainingRDNs.length);
name = new DN(remainingRDNs).toString();
}
} catch (final Exception ex) {
Debug.debugException(ex);
}
}
final Collection<Attribute> attrs = e.getAttributes();
final Attribute[] attributes = new Attribute[attrs.size()];
attrs.toArray(attributes);
return new SearchResult(name, null, convertAttributes(attributes));
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class JNDIExtendedRequest method toSDKExtendedRequest.
/**
* Retrieves an LDAP SDK extended request that is the equivalent of the
* provided JNDI extended request.
*
* @param r The JNDI extended request to convert to an LDAP SDK extended
* request.
*
* @return The LDAP SDK extended request converted from the provided JNDI
* extended request.
*
* @throws NamingException If a problem occurs while decoding the provided
* JNDI extended request as an SDK extended request.
*/
@Nullable()
public static ExtendedRequest toSDKExtendedRequest(@Nullable final javax.naming.ldap.ExtendedRequest r) throws NamingException {
if (r == null) {
return null;
}
final ASN1OctetString value;
final byte[] valueBytes = r.getEncodedValue();
if (valueBytes == null) {
value = null;
} else {
try {
value = ASN1OctetString.decodeAsOctetString(valueBytes);
} catch (final ASN1Exception ae) {
throw new NamingException(StaticUtils.getExceptionMessage(ae));
}
}
return new ExtendedRequest(r.getID(), value);
}
Aggregations