Hi
Using SAS 9.4 and JDK1.7.1 for java application.
Got NonTrustedUser Exception when using GetCredentials method of ISecurity_1_1 object.
Connected to metadataServer using makeISecurityConnection method of MdOMRConnection object from Java application.
I tried by adding loginid in "trustUsers.txt" file on the metadata server, but throwing the same exception.
Is it sufficient to make an user into an trusted user ?
Code:
public void isInRole() throws Exception
{
try
{
// Define a two-dimensional string array for options
final String[][] options ={{"",""}};
System.out.println("");
System.out.println("<<<< Begin isInRole() >>>>" );
// Define a holder for the credential handle
StringHolder credHandle = new StringHolder();
System.out.println("After StringHolder");
// Define a holder for the method output
BooleanHolder inRole = new BooleanHolder();
System.out.println("After booleanHolder");
String UGAdminRole = "N_Admin";
// Get a credential handle
iSecurity.GetCredentials("LOGINID:SAS.ADMIN", credHandle); // <----------Throwing exception here.
System.out.println("credHandle = " + credHandle);
// Execute the method
iSecurity.IsInRole(credHandle.value,"ROLE_OBJNAME:" + UGAdminRole,options,inRole);
// Print information about the method call and results
System.out.println();
System.out.println("<<<<<< isInRole() call parameters with results >>>>>>");
System.out.print("credHandle=" + credHandle.value + ", ");
System.out.print("roleSpecification=" + "ROLE_OBJNAME:" + UGAdminRole + ", ");
System.out.print("isInRole=" + inRole.value);
System.out.println();
// Free the credentials
iSecurity.FreeCredentials(credHandle.value);
System.out.println("");
System.out.println("<<<< End isInRole() >>>>" );
}
catch (Exception e)
{
System.out.println("IsInRole: GetInfo: Exceptions");
e.printStackTrace();
throw e;
}
}
// method for establishing connection
public boolean connectToServer()
{
String serverName = "111.219.61.95";
String serverPort = "8561";
String serverUser = "SAS.ADMIN";
String serverPass = "enter";
try
{
MdOMRConnection connection = _factory.getConnection();
// This statement makes the connection to the server.
//connection.makeOMRConnection(serverName, serverPort, serverUser, serverPass);
iSecurity = connection.makeISecurityConnection(serverName, serverPort, serverUser, serverPass);
System.out.println("iSecurity = " + iSecurity);
// The following statements define error handling and error
// reporting messages.
}
catch (MdException e)
{
Throwable t = e.getCause();
if (t != null)
{
String ErrorType = e.getSASMessageSeverity();
String ErrorMsg = e.getSASMessage();
if (ErrorType == null)
{
// If there is no SAS server message, write a Java/CORBA message.
}
else
{
// If there is a message from the server:
System.out.println(ErrorType + ": " + ErrorMsg);
}
if (t instanceof org.omg.CORBA.COMM_FAILURE)
{
// If there is an invalid port number or host name:
System.out.println(e.getLocalizedMessage());
}
else if (t instanceof org.omg.CORBA.NO_PERMISSION)
{
// If there is an invalid user ID or password:
System.out.println(e.getLocalizedMessage());
}
}
else
{
// If we cannot find a nested exception, get message and print.
System.out.println(e.getLocalizedMessage());
}
// If there is an error, print the entire stack trace.
e.printStackTrace();
return false;
}
catch (RemoteException e)
{
// Unknown exception.
e.printStackTrace();
return false;
}
// If no errors occur, then a connection is made.
return true;
}