Home : AuthInfo.setThreadDefault(...) and Single-Instance COM Objects
Q95460 - INFO: AuthInfo.setThreadDefault(...) and Single-Instance COM Objects

AuthInfo.setThreadDefault(...) and Single-Instance COM Objects


This article applies to Java applications accessing COM components.

As discussed in our documentation page on Security and Authentication, you can use setThreadDefault(...) if you want authentication to be done on a per-thread basis. This mechanism works only if the COM component you are accessing is multi-instance. A COM application is multi-instance if a user can instantiate more than one instance of the application at a given time in a given desktop. Examples of multi-instance COM applications are Microsoft Word and Excel.

AuthInfo.setThreadDefault(...) will have a different behavior if the COM component it is authenticating to is single-instance. A single-instance COM application is one where a user can invoke only one instance of it. If the user attempts to invoke another instance, the same existing instance is returned to the user. If you have several threads running in a single Java process and you want to use setThreadDefault(...) to authenticate to a single-instance COM component, only the first thread needs to call setThreadDefault(...). All the remaining threads will re-use the authentication of the first one. If you try calling setThreadDefault(...) on the second thread, passing it the wrong authentication credentials (like a wrong username or password), the second thread will still be allowed access to the COM component. This is because the entire Java process has already been authenticated to that single instance of the COM component. Further calls to setThreadDefault(...) have no effect.

Note: If your COM component is a dll and you use setdllhost to surrogate that dll, the COM component effectively becomes a single-instance COM object.

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?


Tell us why you rated the content this way. (optional)
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/11/2006.
Last Modified by No Author Name Available!.
Article has been viewed 9778 times.
Rated 5 out of 10 based on 359 votes.
Print Article
Email Article