import com.novell.java.security.Authenticator;
import com.novell.java.security.Identity;
import com.novell.java.security.IdentityScope;
import com.novell.java.security.KeyManagementException;
import com.novell.service.security.NdsIdentity;
import com.novell.service.security.NdsPasswordIdentity;
import com.novell.service.security.NdsIdentityScope;
import com.novell.service.security.BinderyIdentity;
import com.novell.service.security.BinderyPasswordIdentity;
import com.novell.service.security.BinderyIdentityScope;
import com.novell.service.security.Password;
public class VerifyTokensPI
{
static public void main(String args[])
{
if(args.length < 4)
{
System.out.println("Usage: VerifyTokensPI [NDS]-or-[BINDERY] domain name");
System.out.println("E.g.: VerifyTokensPI [NDS] MyTree MyOrgContext MyGroupContext Me MYPASSWORD");
System.out.println("E.g.: VerifyTokensPI [BINDERY] MyServer Me MYPASSWORD");
System.exit(-1);
}
try
{
Identity identity = null;
if(args[0].equalsIgnoreCase(NdsIdentityScope.ADMINISTRATIVE_DOMAIN_NAME))
identity = buildNdsIdentity(null,0,args);
else if(args[0].equalsIgnoreCase(BinderyIdentityScope.ADMINISTRATIVE_DOMAIN_NAME))
identity = buildBinderyIdentity(null,0,args);
else
{
System.out.println("You must specify either [NDS] or [BINDERY] as the first scope.");
System.exit(-1);
}
Authenticator.verifyTokens(identity);
}
catch(java.lang.Throwable e)
{
if (e instanceof java.lang.ExceptionInInitializerError)
((java.lang.ExceptionInInitializerError)e).getException().printStackTrace();
e.printStackTrace();
}
finally
{
System.exit(0);
}
}
static Identity buildNdsIdentity(IdentityScope scope, int offset, String args[])
throws KeyManagementException
{
if( args.length == 0)
return new NdsIdentity("");
if(!(offset < args.length-2))
{
Identity pi = new NdsPasswordIdentity(args[offset],scope);
((NdsPasswordIdentity)pi).setPassword(new Password(args[offset+1]));
return pi;
}
return buildNdsIdentity(new NdsIdentityScope(args[offset],scope), ++offset, args);
}
static Identity buildBinderyIdentity(IdentityScope scope, int offset, String args[])
throws KeyManagementException
{
if( args.length == 0)
return new BinderyIdentity("");
if(!(offset < args.length-2))
{
Identity pi = new BinderyPasswordIdentity(args[offset],scope);
((BinderyPasswordIdentity)pi).setPassword(new Password(args[offset+1]));
return pi;
}
return buildBinderyIdentity(new BinderyIdentityScope(args[offset],scope), ++offset, args);
}
}