/** * Shows the page that signals that a robot was successfully registered a * robot. It will show the robot's token and token secret to use for the * Active API. * * @param robotAccount the newly registered robot account. */ private void onRegisterSuccess(HttpServletRequest req, HttpServletResponse resp, RobotAccountData robotAccount) throws IOException { RobotRegistrationSuccessPage.write(resp.getWriter(), new GxpContext(req.getLocale()), robotAccount.getId().getAddress(), robotAccount.getConsumerSecret(), analyticsAccount); resp.setContentType("text/html"); resp.setStatus(HttpServletResponse.SC_OK); } }
private DBObject robotToObject(RobotAccountData account) { return new BasicDBObject() .append(ROBOT_URL_FIELD, account.getUrl()) .append(ROBOT_SECRET_FIELD, account.getConsumerSecret()) .append(ROBOT_CAPABILITIES_FIELD, capabilitiesToObject(account.getCapabilities())) .append(ROBOT_VERIFIED_FIELD, account.isVerified()); }
public void testRegisterNewSucceeds() throws PersistenceException, RobotRegistrationException { RobotAccountData resultAccountData = registrar.registerNew(ROBOT_ID, LOCATION); verify(accountStore, atLeastOnce()).getAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); verify(tokenGenerator).generateToken(anyInt()); assertTrue(resultAccountData.isRobot()); RobotAccountData robotAccountData = resultAccountData.asRobot(); // Remove the last '/'. assertEquals(LOCATION.substring(0, LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
public void testRegisterNewSucceeds() throws PersistenceException, RobotRegistrationException { RobotAccountData resultAccountData = registrar.registerNew(ROBOT_ID, LOCATION); verify(accountStore, atLeastOnce()).getAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); verify(tokenGenerator).generateToken(anyInt()); assertTrue(resultAccountData.isRobot()); RobotAccountData robotAccountData = resultAccountData.asRobot(); // Remove the last '/'. assertEquals(LOCATION.substring(0, LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
private static ProtoRobotAccountData serialize(RobotAccountData account) { Preconditions.checkNotNull(account, "account is null"); ProtoRobotAccountData.Builder builder = ProtoRobotAccountData.newBuilder(); builder.setUrl(account.getUrl()); builder.setConsumerSecret(account.getConsumerSecret()); builder.setIsVerified(account.isVerified()); if (account.getCapabilities() != null) { builder.setRobotCapabilities(serialize(account.getCapabilities())); } return builder.build(); }
public void testReRegisterSucceedsOnExistingRobotAccount() throws PersistenceException, RobotRegistrationException { when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData); AccountData unregisteredAccountData = registrar.registerOrUpdate(ROBOT_ID, OTHER_LOCATION); verify(accountStore).removeAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); assertTrue(unregisteredAccountData.isRobot()); RobotAccountData robotAccountData = unregisteredAccountData.asRobot(); // Remove the last '/'. assertEquals(OTHER_LOCATION.substring(0, OTHER_LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
new OAuthConsumer(null, participant.getAddress(), account.asRobot().getConsumerSecret(), oauthServiceProvider); OAuthAccessor accessor = new OAuthAccessor(consumer);
public void testReRegisterSucceedsOnExistingRobotAccount() throws PersistenceException, RobotRegistrationException { when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData); AccountData unregisteredAccountData = registrar.registerOrUpdate(ROBOT_ID, OTHER_LOCATION); verify(accountStore).removeAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); assertTrue(unregisteredAccountData.isRobot()); RobotAccountData robotAccountData = unregisteredAccountData.asRobot(); // Remove the last '/'. assertEquals(OTHER_LOCATION.substring(0, OTHER_LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
/** * Returns a new {@link RobotAccountData} updated with the new capabilities * using the given {@link RobotAccountData}. * * @param account The {@link RobotAccountData} to update the capabilities for. * @param activeApiUrl the url of the Active Robot API. * @throws CapabilityFetchException if the capabilities couldn't be retrieved * or parsed. */ public RobotAccountData fetchCapabilities(RobotAccountData account, String activeApiUrl) throws CapabilityFetchException { RobotCapabilitiesParser parser = new RobotCapabilitiesParser( account.getUrl() + Robot.CAPABILITIES_URL, connection, activeApiUrl); RobotCapabilities capabilities = new RobotCapabilities( parser.getCapabilities(), parser.getCapabilitiesHash(), parser.getProtocolVersion()); return new RobotAccountDataImpl(account.getId(), account.getUrl(), account.getConsumerSecret(), capabilities, account.isVerified()); } }
setupOAuth(account.getId().getAddress(), account.getConsumerSecret(), rpcUrl); Wavelet newWelcomeWavelet = newWave(getWaveDomain(), Sets.newHashSet(id.getAddress())); if (welcomeWaveId != null) {