JndiPermission perm = new JndiPermission(prefix, JndiPermission.LOOKUP);
sm.checkPermission(perm);
}
// Return this
result = new NamingContext(null, (Name)(prefix.clone()), getRoot());
}
else if (name.size() > 1)
{
// Recurse to find correct context
// System.out.println("lookup#"+name+"#");
Object ctx = getObject(name);
if (ctx instanceof NamingServer)
{
result = ((NamingServer)ctx).lookup(name.getSuffix(1));
}
else if (ctx instanceof Reference)
{
// Federation
if (((Reference)ctx).get("nns") != null)
{
CannotProceedException cpe = new CannotProceedException();
cpe.setResolvedObj(ctx);
cpe.setRemainingName(name.getSuffix(1));
throw cpe;
}
result = new ResolveResult(ctx, name.getSuffix(1));
} else
{
throw new NotContextException();
}
}
else
{
// Get object to return
if (name.get(0).equals(""))
{
SecurityManager sm = getSecurityManager();
if(sm != null)
{
JndiPermission perm = new JndiPermission(prefix, JndiPermission.LOOKUP);
sm.checkPermission(perm);
}
result = new NamingContext(null, (Name)(prefix.clone()), getRoot());
}
else
{
// System.out.println("lookup "+name);
SecurityManager sm = getSecurityManager();
Name fullName = (Name)(prefix.clone());
fullName.addAll(name);
if(sm != null)
{
JndiPermission perm = new JndiPermission(fullName, JndiPermission.LOOKUP);
sm.checkPermission(perm);
}
Object res = getObject(name);
if (res instanceof NamingServer)
{
result = new NamingContext(null, fullName, getRoot());
}
else
result = res;
}
}