Package net.handle.hdllib
Class HandleResolver
java.lang.Object
net.handle.hdllib.HandleResolver
- All Implemented Interfaces:
RequestProcessor
Responsible for locating and retrieving the value of handles using
a caching server, or on the internet.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear any caches being used by this resolverSiteInfo[]
Get the site information for the service that is responsible for this handle while at the same time populating the namespaceSiteInfo[]
findLocalSitesForNA
(byte[] naHandle) Get the resolution configurationint
Return the maximum size of the data part of a message before it is split into multiple messages when using UDP.byte[]
getNAHandle
(byte[] handle) Deprecated.Legacy of slash-based delegation; use Util.getZeroNAHandlebyte[]
getNAHandle
(ResolutionRequest resReq) Deprecated.getNamespaceInfo
(ResolutionRequest resReq) Returns the current default session tracker.int
Get how long to wait for responses to TCP requests.int[]
Get the array that specifies how long to wait for responses to each UDP request.boolean
void
listHandlesUnderPrefix
(String prefixHandle, AuthenticationInfo authInfo, ScanCallback callback) void
listHandlesUnderPrefixAtSite
(String prefixHandle, SiteInfo site, AuthenticationInfo authInfo, ScanCallback callback) Shortcut to processRequest(req, null);processRequest
(AbstractRequest req, InetAddress caller) void
processRequest
(AbstractRequest req, InetAddress caller, ResponseMessageCallback callback) processRequest
(AbstractRequest req, ResponseMessageCallback callback) This method processes the given request using the currently configured method (global resolution, resolution against a caching server, etc), and returns the response.Shortcut to processRequestGlobally(req, null);int[]
Return a copy of preferredProtocols[], wherein protocols are listed in order of preference.resolveHandle
(byte[] handle) resolveHandle
(byte[] handle, byte[][] types, int[] indexes) resolveHandle
(String sHandle) resolveHandle
(String sHandle, String[] sTypes, int[] indexes) Locate and return the values of the given handle that have the specified types or indexes.resolveValueReference
(ValueReference valueReference) byte[]
retrieveHandleIndexData
(byte[] handle, int index) this method will retrieve the handle values by the given handle/index pair Now only used to retrieve public key data in veryfying the session setup data.sendHdlTcpRequest
(AbstractRequest req, InetAddress addr, int port) Shortcut to sendHdlTcpRequest(req, addr, port, null);sendHdlTcpRequest
(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) sendHdlUdpRequest
(AbstractRequest req, InetAddress addr, int port) Shortcut to sendHdlUdpRequest(req, addr, port, null);sendHdlUdpRequest
(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) sendHttpRequest
(AbstractRequest req, InetAddress addr, int port) Shortcut to sendHttpRequest(req, addr, port, null);sendHttpRequest
(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) sendHttpsRequest
(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) sendRequestToInterface
(AbstractRequest req, ServerInfo server, Interface interfce) Shortcut to sendRequestToInterface(AbstractRequest, ServerInfo, Interface, null);sendRequestToInterface
(AbstractRequest req, ServerInfo server, Interface interfce, ResponseMessageCallback callback) sendRequestToServer
(AbstractRequest req, ServerInfo server) Shortcut to sendRequestToServer(AbstractRequest, ServerInfo, null);sendRequestToServer
(AbstractRequest req, ServerInfo server, ResponseMessageCallback callback) Wrapper around sendRequestToServerByProtocol(), which used to have this name and signature.sendRequestToServer
(AbstractRequest req, SiteInfo site, ServerInfo server) sendRequestToServer
(AbstractRequest req, SiteInfo site, ServerInfo server, ResponseMessageCallback callback) sendRequestToServerInSiteByProtocol
(AbstractRequest req, SiteInfo site, ServerInfo server, int protocol, ResponseMessageCallback callback) sendRequestToService
(AbstractRequest req, SiteInfo[] sites) Shortcut to sendRequestToService(AbstractRequest, SiteInfo[], null);final AbstractResponse
sendRequestToService
(AbstractRequest req, SiteInfo[] sites, ResponseMessageCallback callback) sendRequestToSite
(AbstractRequest req, SiteInfo site) Sends the given request to the appropriate server in the given site and returns the response.sendRequestToSite
(AbstractRequest req, SiteInfo site, int protocol) Shortcut to sendRequestToSite(AbstractRequest, site, protocol, null);sendRequestToSite
(AbstractRequest req, SiteInfo site, int protocol, ResponseMessageCallback callback) sendRequestToSite
(AbstractRequest req, SiteInfo site, ResponseMessageCallback callback) Sends the given request to the appropriate server in the given site and returns the response.void
Gives the resolver a Cache object to use when resolving.void
setCertifiedCache
(Cache cache) Gives the resolver a Cache object to use for certified resolutions.void
setCheckSignatures
(boolean checkSigs) Set whether or not this object should check the signatures of server responses to certified requests.void
setConfiguration
(Configuration config) Set the configuration used for resolution.void
setExecutorService
(ExecutorService execServ) void
setMaxUDPDataSize
(int newMaxUDPDataSize) Set the maximum size of the data part of a message before it is split into multiple messages when using UDP.void
setPreferredProtocols
(int[] prefProtocols) Set the protocols and the order of preference used for resolution For every server that this resolver talks to, it attempts to communicate via the given protocols either until it succeeds or all attempts to communicate fail.void
setSessionTracker
(ClientSessionTracker sessionTracker) Gives the resolver a session tracker object to use when resolving.void
setSiteFilter
(SiteFilter siteFilter) void
setTcpTimeout
(int newTcpTimeout) Set how long to wait for responses to TCP and HTTP requests.void
setUdpRetryScheme
(int[] newudpRetryScheme) Set the array that specifies how long to wait for responses to each UDP request.setupSessionWithServer
(AbstractRequest req, SessionSetupInfo sessionOptions, ServerInfo server) Create a new session to handle the given request.void
setUseIPv6FastFallback
(boolean useIPv6FastFallback)
-
Field Details
-
traceMessages
public boolean traceMessages
-
-
Constructor Details
-
HandleResolver
public HandleResolver()
-
-
Method Details
-
getExecutorService
-
setExecutorService
-
protocolsByPreference
public int[] protocolsByPreference()Return a copy of preferredProtocols[], wherein protocols are listed in order of preference. For use by methods which do not have access to the private int-array. -
retrieveHandleIndexData
this method will retrieve the handle values by the given handle/index pair Now only used to retrieve public key data in veryfying the session setup data.- Throws:
Exception
-
setCache
Gives the resolver a Cache object to use when resolving. When sending requests, the cache will be checked for the handle instead of always using the network. Setting the cache object to null will cause the resolver to not use any cache. -
setCertifiedCache
Gives the resolver a Cache object to use for certified resolutions. When sening certified resolution requests, this cache will be checked for the handle instead of always using the network. Setting the cache object to null will cause the resolver to not use any cache for certified resolutions. Note: It is important to never use the same cache (or backing storage) for the certified and regular cache. Doing so could poison the certified cache with uncertified values. -
clearCaches
Clear any caches being used by this resolver- Throws:
Exception
-
setSessionTracker
Gives the resolver a session tracker object to use when resolving. When sending administrative requests and the resolver's session tracker is non-null, it is used to establish (or continue) a session with whatever server is being communicated with. Note: If there is a sessionInfo or session tracker already associated with a request, then the resolver's session tracker is ignored. Warning: If this resolver is going to be used in several administrative contexts (ie with several different admin IDs) because authenticated sessions could possibly be used by a different administrator than was intended. -
getSessionTracker
Returns the current default session tracker. -
setConfiguration
Set the configuration used for resolution. This configuration indicates whether requests are processed using a network cache (ala DNS) or if we determine the appropriate server via global. -
setPreferredProtocols
public void setPreferredProtocols(int[] prefProtocols) Set the protocols and the order of preference used for resolution For every server that this resolver talks to, it attempts to communicate via the given protocols either until it succeeds or all attempts to communicate fail. If a client is behind a firewall and not using a caching server then it would be best to set the preferred protocols to Interface.SP_HDL_TCP and Interface.SP_HDL_HTTP since the Interface.SP_HDL_UDP will probably just get blocked by firewalls and be a big waste of time. -
setMaxUDPDataSize
public void setMaxUDPDataSize(int newMaxUDPDataSize) Set the maximum size of the data part of a message before it is split into multiple messages when using UDP. -
getMaxUDPDataSize
public int getMaxUDPDataSize()Return the maximum size of the data part of a message before it is split into multiple messages when using UDP. -
getConfiguration
Get the resolution configuration -
setTcpTimeout
public void setTcpTimeout(int newTcpTimeout) Set how long to wait for responses to TCP and HTTP requests. -
getTcpTimeout
public int getTcpTimeout()Get how long to wait for responses to TCP requests. -
isUseIPv6FastFallback
public boolean isUseIPv6FastFallback() -
setUseIPv6FastFallback
public void setUseIPv6FastFallback(boolean useIPv6FastFallback) -
getSiteFilter
-
setSiteFilter
-
getUdpRetryScheme
public int[] getUdpRetryScheme()Get the array that specifies how long to wait for responses to each UDP request. The length of this array will indicate how many UDP requests to send before giving up. The default scheme is something like {1000, 2000, 3000} which is 1 second, 2 seconds, 3 seconds. -
setUdpRetryScheme
public void setUdpRetryScheme(int[] newudpRetryScheme) Set the array that specifies how long to wait for responses to each UDP request. The length of this array will indicate how many UDP requests to send before giving up. The default scheme is something like {1000, 2000, 3000} which is 1 second, 2 seconds, 3 seconds. -
setCheckSignatures
public void setCheckSignatures(boolean checkSigs) Set whether or not this object should check the signatures of server responses to certified requests. The default is to check signatures and throw an exception if a signature to any certified message is missing or invalid. -
resolveHandle
public HandleValue[] resolveHandle(String sHandle, String[] sTypes, int[] indexes) throws HandleException Locate and return the values of the given handle that have the specified types or indexes. This method simply creates a ResolutionRequest object from the given parameters and calls processRequest with that request object. The requested handle values are then extracted from the response and returned (or an exception is thrown if there was an error). Creating your own ResolutionRequest objects and calling processRequest directly allows more flexibility since you can set the certified, authoritative, and recursive flags of the request. When specifying both a set of types or indexes, a server will return all handle values that have the requested types as well as all handle values that have the requested indexes. Essentially, the union of the set of handles with the requested types and the set of handles with the requested indexes is returned. An empty index or type list indicates that any index or type is acceptable. The following examples describe how the type and index lists are used in resolutions:Type-List Index List Returns [ URL ] [ 0, 12 ] Any URL values, as well as values with indexes 0 and 12 if they exist. [ ] [ 1 ] The value with index one only [ EMAIL ] [ ] Any values with type EMAIL [ ] [ ] All of the values associated with the given handle
- Throws:
HandleException
-
resolveHandle
public HandleValue[] resolveHandle(byte[] handle, byte[][] types, int[] indexes) throws HandleException - Throws:
HandleException
-
resolveHandle
- Throws:
HandleException
-
resolveHandle
- Throws:
HandleException
-
resolveValueReference
- Throws:
HandleException
-
listHandlesUnderPrefix
public void listHandlesUnderPrefix(String prefixHandle, AuthenticationInfo authInfo, ScanCallback callback) throws HandleException - Throws:
HandleException
-
listHandlesUnderPrefixAtSite
public void listHandlesUnderPrefixAtSite(String prefixHandle, SiteInfo site, AuthenticationInfo authInfo, ScanCallback callback) throws HandleException - Throws:
HandleException
-
processRequest
public AbstractResponse processRequest(AbstractRequest req, ResponseMessageCallback callback) throws HandleException This method processes the given request using the currently configured method (global resolution, resolution against a caching server, etc), and returns the response. If a Cache object is available it will be used if the request is a ResolutionRequest and the authoritative flag of the request is not set. The AbstractResponse object that is returned can be either an ErrorResponse or a ResolutionResponse object. Check the responseCode of the AbstractResponse (or use the instanceof keyword) to determine if the response can safely be casted to a ResolutionResponse or not. If you determine that the response is a ResolutionResponse then you can cast the response and call getHandleValues() on it. The following is an example that requests all of the URL values associated with the handle 123/abc, and prints them to System.out.HandleResolver resolver = new HandleResolver(); AbstractResponse aResponse = resolver.resolveHandle("123/abc", new String[]{"URL"}, null); if(aResponse.responseCode==AbstractMessage.RC_SUCCESS) { ResolutionResponse response = (ResolutionResponse)aResponse; HandleValue values[] = response.getHandleValues(); System.out.println("Received values: "); for(int i=0; i<values.length; i++) { System.out.println(String.valueOf(values[i])); } }
- Throws:
HandleException
-
processRequest
Shortcut to processRequest(req, null);- Throws:
HandleException
-
processRequest
public AbstractResponse processRequest(AbstractRequest req, InetAddress caller) throws HandleException - Specified by:
processRequest
in interfaceRequestProcessor
- Throws:
HandleException
-
processRequest
public void processRequest(AbstractRequest req, InetAddress caller, ResponseMessageCallback callback) throws HandleException - Specified by:
processRequest
in interfaceRequestProcessor
- Throws:
HandleException
-
processRequestGlobally
Shortcut to processRequestGlobally(req, null);- Throws:
HandleException
-
findLocalSitesForNA
- Throws:
HandleException
-
findLocalSites
Get the site information for the service that is responsible for this handle while at the same time populating the namespace- Throws:
HandleException
-
getNAHandle
Deprecated.Legacy of slash-based delegation; use Util.getZeroNAHandleFind the prefix handle for a handle -
getNAHandle
Deprecated. -
getNamespaceInfo
- Throws:
HandleException
-
sendRequestToService
public final AbstractResponse sendRequestToService(AbstractRequest req, SiteInfo[] sites, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendRequestToService
public AbstractResponse sendRequestToService(AbstractRequest req, SiteInfo[] sites) throws HandleException Shortcut to sendRequestToService(AbstractRequest, SiteInfo[], null);- Throws:
HandleException
-
sendRequestToSite
public AbstractResponse sendRequestToSite(AbstractRequest req, SiteInfo site, int protocol) throws HandleException Shortcut to sendRequestToSite(AbstractRequest, site, protocol, null);- Throws:
HandleException
-
sendRequestToSite
public AbstractResponse sendRequestToSite(AbstractRequest req, SiteInfo site, int protocol, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendRequestToServerInSiteByProtocol
public AbstractResponse sendRequestToServerInSiteByProtocol(AbstractRequest req, SiteInfo site, ServerInfo server, int protocol, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendRequestToServer
public AbstractResponse sendRequestToServer(AbstractRequest req, ServerInfo server) throws HandleException Shortcut to sendRequestToServer(AbstractRequest, ServerInfo, null);- Throws:
HandleException
-
sendRequestToServer
public AbstractResponse sendRequestToServer(AbstractRequest req, SiteInfo site, ServerInfo server) throws HandleException - Throws:
HandleException
-
sendRequestToServer
public AbstractResponse sendRequestToServer(AbstractRequest req, ServerInfo server, ResponseMessageCallback callback) throws HandleException Wrapper around sendRequestToServerByProtocol(), which used to have this name and signature. This is invoked by the code which formerly invoked the older method.- Throws:
HandleException
-
sendRequestToServer
public AbstractResponse sendRequestToServer(AbstractRequest req, SiteInfo site, ServerInfo server, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendRequestToSite
public AbstractResponse sendRequestToSite(AbstractRequest req, SiteInfo site) throws HandleException Sends the given request to the appropriate server in the given site and returns the response. This will try to contact the appropriate server by trying each of the preferred protocols, in order.- Throws:
HandleException
-
sendRequestToSite
public AbstractResponse sendRequestToSite(AbstractRequest req, SiteInfo site, ResponseMessageCallback callback) throws HandleException Sends the given request to the appropriate server in the given site and returns the response. This will try to contact the appropriate server by trying each of the preferred protocols, in order.- Throws:
HandleException
-
setupSessionWithServer
public ClientSideSessionInfo setupSessionWithServer(AbstractRequest req, SessionSetupInfo sessionOptions, ServerInfo server) throws Exception Create a new session to handle the given request.- Throws:
Exception
-
sendRequestToInterface
public AbstractResponse sendRequestToInterface(AbstractRequest req, ServerInfo server, Interface interfce) throws HandleException Shortcut to sendRequestToInterface(AbstractRequest, ServerInfo, Interface, null);- Throws:
HandleException
-
sendRequestToInterface
public AbstractResponse sendRequestToInterface(AbstractRequest req, ServerInfo server, Interface interfce, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendHdlUdpRequest
public AbstractResponse sendHdlUdpRequest(AbstractRequest req, InetAddress addr, int port) throws HandleException Shortcut to sendHdlUdpRequest(req, addr, port, null);- Throws:
HandleException
-
sendHdlUdpRequest
public AbstractResponse sendHdlUdpRequest(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendHdlTcpRequest
public AbstractResponse sendHdlTcpRequest(AbstractRequest req, InetAddress addr, int port) throws HandleException Shortcut to sendHdlTcpRequest(req, addr, port, null);- Throws:
HandleException
-
sendHdlTcpRequest
public AbstractResponse sendHdlTcpRequest(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendHttpRequest
public AbstractResponse sendHttpRequest(AbstractRequest req, InetAddress addr, int port) throws HandleException Shortcut to sendHttpRequest(req, addr, port, null);- Throws:
HandleException
-
sendHttpRequest
public AbstractResponse sendHttpRequest(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-
sendHttpsRequest
public AbstractResponse sendHttpsRequest(AbstractRequest req, InetAddress addr, int port, ResponseMessageCallback callback) throws HandleException - Throws:
HandleException
-