public CouchClient createCouchClient() throws Exception { // Create couch client CouchClient couchClient = null; { Properties couchClientProps = new Properties(); couchClientProps.put("couchdb.server", server); if( null != user && null != password ) { couchClientProps.put("couchdb.user", user); couchClientProps.put("couchdb.password", password); } CouchFactory couchFactory = new CouchFactory(); couchClient = couchFactory.getClient(couchClientProps); // Verify that we can connect to the server try { couchClient.validateContext(); } catch(Exception e) { throw new Exception("Unable to connect to the server. Probably a problem with server URL, user name or password.",e); } } return couchClient; }
private CouchDb getUserCouchDbFromCookies(Cookie[] cookies) throws Exception { CouchContextCookie contextCookie = new CouchContextCookie(); for(Cookie cookie : cookies){ contextCookie.setCookie(cookie.getName(), cookie.getValue()); } CouchFactory factory = new CouchFactory(); return factory.getDb(contextCookie, dd.getDatabase()); }
static public CouchClient createCouchClient( GlobalSettings gs ,AtlasProperties atlasProperties ) throws Exception { // Create couch client CouchClient couchClient = null; { Properties couchClientProps = new Properties(); couchClientProps.put("couchdb.server", atlasProperties.getCouchDbUrl().toExternalForm()); couchClientProps.put("couchdb.user", atlasProperties.getCouchDbAdminUser()); couchClientProps.put("couchdb.password", atlasProperties.getCouchDbAdminPassword()); CouchFactory couchFactory = new CouchFactory(); couchClient = couchFactory.getClient(couchClientProps); // Verify that we can connect to the server try { couchClient.validateContext(); } catch(Exception e) { throw new Exception("Unable to connect to the server. Probably wrong user name or password.",e); } } return couchClient; }
@Override public CouchAuthenticationContext getRolesFromAuthentication(Cookie[] cookies) throws Exception { CouchContextCookie contextCookie = new CouchContextCookie(); for(Cookie cookie : cookies){ contextCookie.setCookie(cookie.getName(), cookie.getValue()); } CouchFactory factory = new CouchFactory(); CouchDb couchDb = factory.getDb(contextCookie, userDb); CouchSession session = couchDb.getClient().getSession(); CouchAuthenticationContext userContext = session.getAuthenticationContext(); return userContext; }
private CouchAuthenticationContext getAuthenticationContextFromCookies(Cookie[] cookies) throws Exception { CouchContextCookie contextCookie = new CouchContextCookie(); if( null != cookies ) { for(Cookie cookie : cookies){ contextCookie.setCookie(cookie.getName(), cookie.getValue()); } } CouchClient client = documentDesign.getDatabase().getClient(); CouchFactory factory = new CouchFactory(); CouchClient userClient = factory.getClient(contextCookie, client); CouchSession session = userClient.getSession(); CouchAuthenticationContext authContext = session.getAuthenticationContext(); return authContext; }
CouchFactory factory = new CouchFactory(); try { couchClient = factory.getClient(props);