try { Collection root = DatabaseManager.getCollection(new AnyURIValue(uri).toXmldbURI().toString(), userName, password);
XmldbURI targetColl; if (!uri.startsWith(XmldbURI.XMLDB_SCHEME + ':')) targetColl = XmldbURI.EMBEDDED_SERVER_URI.resolveCollectionPath(XmldbURI.create(uri)); else targetColl = XmldbURI.create(uri); try { Collection root = DatabaseManager.getCollection(targetColl.toString(), userName, password);
	public Sequence eval(Sequence[] args, Sequence contextSequence)		throws XPathException {		if(args[1].isEmpty())			return BooleanValue.FALSE;		String uri = args[0].getStringValue();		String userName = args[1].getStringValue();		String password = args[2].getStringValue();				try {			Collection root = DatabaseManager.getCollection(new AnyURIValue(uri).toXmldbURI().toString(), userName, password);            if (isCalledAs("login")) {                UserManagementService ums = (UserManagementService) root.getService("UserManagementService", "1.0");                User user = ums.getUser(userName);                context.getBroker().setUser(user);                                /** if there is a http session cache the user in the http session */                cacheUserInHttpSession(user);            }			return BooleanValue.TRUE;		} catch (XMLDBException e) {            if (LOG.isDebugEnabled())                LOG.debug("Failed to authenticate user '" + userName + "' on " + uri, e);			return BooleanValue.FALSE;		}	}