Home
TeamSite
Help wtih IWAccessService accessService
imran_patel
(1)
command line paramaters
-Dinterwoven.api.locator="<IWRMINamingServiceLocator/" -DUSERNAME ="Publisher" -DPASSWORD="Publisher" -DGROUPNAME="interwov" -DNTDOMAINNAME ="" IWFileSys2 rmi://bge004/IWAccessService
(2) line of failure
IWAccessService accessService =
(IWAccessService) IWService.locate( accessServiceLocation);
(3) problem:
when i run the following example to connect to Teamsite i get the following error:
Caught exception java.rmi.ConnectException: Connection refused to host: 10.188.20.199; nested exception is:
java.net.ConnectException: Connection refused: connect.
java.rmi.ConnectException: Connection refused to host: 10.179.20.193; nested exception is:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:345)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:157)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:144)
at java.net.Socket.<init>(Socket.java:294)
at java.net.Socket.<init>(Socket.java:121)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:38)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:133)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:521)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:217)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:201)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:331)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:93)
at com.interwoven.api.service.IWRMINamingServiceLocator.locateRemote(IWRMINamingServiceLocator.java:188)
at com.interwoven.api.service.IWServiceLocator.locate(IWServiceLocator.java:128)
at com.interwoven.api.service.IWService.locate(IWService.java:400)
at createCountryBusinessUnitView.IWAccessTest0.main(IWAccessTest0.java:95)
(4)
Example
import com.interwoven.api.access.*;
import java.rmi.RemoteException;
import java.util.*;
import com.interwoven.api.access.IWAccessor.AuthenticateException;
import com.interwoven.api.service.IWService;
public class IWAccessTest0{
private static int validity = 60 * 1000;
/**
* Test the Trustee information. Domain Information is only
* returned on NT.
*/
protected static
void
testTrustee(IWAccessService accessService, IWTrustee trustee)
throws RemoteException
{
System.out.println("Testing IWTrustee.getAllDomainCollection");
Collection domainCollection =
((Collection)(IWTrustee.getAllDomainCollection(accessService)));
int domainCount = domainCollection.size();
if (domainCount > 0)
{
System.out.println("Domain Size is " + domainCount);
Iterator domainIterator = domainCollection.iterator();
System.out.println("The Domain names are : ");
while (domainIterator.hasNext())
{
String domain = ((String) (domainIterator.next()));
System.out.println(domain);
}
}
}
/**
* Verify the user name and role
* Note that verifying which group the user belongs to
* has not been implemented yet.
*/
protected static
void
testUser(IWAccessService accessService,
IWUser user,
String userName,
String roleName,
String password)
throws RemoteException, AuthenticateException
{
System.out.println("Lookup the role and access information");
IWRole role = IWRole.lookupByName(accessService, roleName);
IWUser userNew = IWUser.lookupByName(accessService, userName);
if(user.equals(userNew))
{
System.out.println("User name and IWUser.lookupByName return the same value");
}
else
{
System.out.println("User name and IWUser.lookupByName return different values");
}
try {
/*
* We already verified
* IWAccessorAuthentication.authenticateUserByPassword() works.
* Now use the IWUser object to verify authentication.
*/
IWAccessorAuthentication accessorAuthentication =
user.authenticateByPassword(accessService, role, password, validity);
} catch (AuthenticateException ae) {
System.out.println("Exception in accessorAuthentication");
throw ae;
}
}
public static
void
main(String[] commandLineArgVector)
{
try {
String accessServiceLocation = commandLineArgVector[0];
System.out.println("Locating service \"" + accessServiceLocation + "\".");
/*
* Find the access service. Get the service handle.
*/
IWAccessService accessService =
(IWAccessService) IWService.locate( accessServiceLocation);
System.out.println("Got accessService.");
/*
* Taken from the run.sh/run.bat files
*/
String userName = "ipatel";//System.getProperty("USERNAME");
String password = "passw0rd";//System.getProperty("PASSWORD");
String groupName = "";//System.getProperty("GROUPNAME");
String domainname = "MAST_GLEN";//System.getProperty("NTDOMAINNAME");
/*
* For Windows, the domain name is used along with the user
* and group names
*/
if (IWTrustee.nsWindows ==
IWTrustee.getRecommendedTrusteeNameSpace(accessService)) {
userName = domainname +"\\" + userName;
groupName = domainname + "\\" + groupName;
} else {
userName = userName;
groupName = groupName;
}
String roleName = "master";
/*
* Authenticate a user.
*
* Make sure that the TeamSite server machine has a valid
* user id - "openapitest" and password - "openapitest"
* Make sure as well that the file <iw-home>/conf/roles/master.uid
* contains "openapitest" entry.
*/
IWAccessorAuthentication authenticatedUser =
IWAccessorAuthentication.authenticateUserByPassword(accessService,
userName,
roleName,
password,
validity);
System.out.println("Done authenticating user.");
/*
* Get the Accessor information
*/
IWAccessor accessor = authenticatedUser.getAccessor();
testUser(accessService,(IWUser)accessor, userName, roleName, password);
testTrustee(accessService,(IWTrustee)accessor);
} catch (Exception exception) {
System.err.println("Caught exception " + exception + ".");
exception.printStackTrace();
}
}
}
Find more posts tagged with
Comments
Migrateduser
Are you sure OpenAPI is up and running on the port you are specifying when you attempt to access it?
imran_patel
only thing i did is that i included openapi_client.jar to run the example program.
do you have any document/steps to setup open api client and server.
thank you
Imran
Migrateduser
I have had success calling OpenAPI from clients but I don't remember what I did to config - I would have to go back to the IW docs. It wasn't very complicated. I would check the logs in IWHOME/local/logs/iwui and see if there are any messages, sometimes OpenAPI doesn't start right.
Migrateduser
Imran could u get it started? John do u recollect from the settings. We have a Solaris, 5.5.2 & getting the same error as that of Imran.
Caught exception java.rmi.ConnectException: Connection refused to host: 209.232.65.47; nested exception is:
java.net.ConnectException: Operation timed out: connect.
java.rmi.ConnectException: Connection refused to host: