com.evernote.edam.userstore.BootstrapProfile Java Examples

The following examples show how to use com.evernote.edam.userstore.BootstrapProfile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BootstrapManager.java    From EverMemo with MIT License 5 votes vote down vote up
/**
 * Log the {@link BootstrapProfile} list
 * @param bsInfo
 */
void printBootstrapInfo(BootstrapInfo bsInfo) {
  if (bsInfo == null) return;

  Log.d(LOGTAG, "printBootstrapInfo");
  List<BootstrapProfile> profiles = bsInfo.getProfiles();
  if (profiles != null) {
    for (BootstrapProfile profile : profiles) {
      Log.d(LOGTAG, profile.toString());
    }
  } else {
    Log.d(LOGTAG, "Profiles are null");
  }
}
 
Example #2
Source File: EvernoteOAuthActivity.java    From EverMemo with MIT License 5 votes vote down vote up
@Override
protected String doInBackground(Void... params) {
	String url = null;
	try {

		EvernoteSession session = EvernoteSession.getOpenSession();
		if (session != null) {
			// Network request
			BootstrapManager.BootstrapInfoWrapper infoWrapper = session
					.getBootstrapSession().getBootstrapInfo();

			if (infoWrapper != null) {
				BootstrapInfo info = infoWrapper.getBootstrapInfo();
				if (info != null) {
					mBootstrapProfiles = (ArrayList<BootstrapProfile>) info
							.getProfiles();
					if (mBootstrapProfiles != null
							&& mBootstrapProfiles.size() > 0
							&& mSelectedBootstrapProfilePos < mBootstrapProfiles
									.size()) {

						mSelectedBootstrapProfile = mBootstrapProfiles
								.get(mSelectedBootstrapProfilePos);
					}
				}
			}
		}

		if (mSelectedBootstrapProfile == null
				|| TextUtils.isEmpty(mSelectedBootstrapProfile
						.getSettings().getServiceHost())) {
			Log.d(LOGTAG, "Bootstrap did not return a valid host");
			return null;
		}

		OAuthService service = createService();

		Log.i(LOGTAG, "Retrieving OAuth request token...");
		Token reqToken = service.getRequestToken();
		mRequestToken = reqToken.getToken();
		mRequestTokenSecret = reqToken.getSecret();

		Log.i(LOGTAG, "Redirecting user for authorization...");
		url = service.getAuthorizationUrl(reqToken);
	} catch (BootstrapManager.ClientUnsupportedException cue) {

		return null;
	} catch (Exception ex) {
		Log.e(LOGTAG, "Failed to obtain OAuth request token", ex);
	}
	return url;
}
 
Example #3
Source File: BootstrapManager.java    From EverMemo-EverNote with MIT License 5 votes vote down vote up
/**
 * Log the {@link BootstrapProfile} list
 * @param bsInfo
 */
void printBootstrapInfo(BootstrapInfo bsInfo) {
  if (bsInfo == null) return;

  Log.d(LOGTAG, "printBootstrapInfo");
  List<BootstrapProfile> profiles = bsInfo.getProfiles();
  if (profiles != null) {
    for (BootstrapProfile profile : profiles) {
      Log.d(LOGTAG, profile.toString());
    }
  } else {
    Log.d(LOGTAG, "Profiles are null");
  }
}
 
Example #4
Source File: EvernoteOAuthActivity.java    From EverMemo-EverNote with MIT License 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  //Show web loading progress
  getWindow().requestFeature(Window.FEATURE_PROGRESS);

  setContentView(R.layout.esdk__webview);
  mActivity = this;

  mWebView = (WebView) findViewById(R.id.esdk__webview);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.setWebChromeClient(mWebChromeClient);
  mWebView.getSettings().setJavaScriptEnabled(true);

  if (savedInstanceState != null) {
    mEvernoteService = savedInstanceState.getParcelable(EXTRA_EVERNOTE_SERVICE);
    mConsumerKey = savedInstanceState.getString(EXTRA_CONSUMER_KEY);
    mConsumerSecret = savedInstanceState.getString(EXTRA_CONSUMER_SECRET);
    mRequestToken = savedInstanceState.getString(EXTRA_REQUEST_TOKEN);
    mRequestTokenSecret = savedInstanceState.getString(EXTRA_REQUEST_TOKEN_SECRET);
    mSelectedBootstrapProfile = (BootstrapProfile) savedInstanceState.getSerializable(EXTRA_BOOTSTRAP_SELECTED_PROFILE);
    mSelectedBootstrapProfilePos = savedInstanceState.getInt(EXTRA_BOOTSTRAP_SELECTED_PROFILE_POS);
    mBootstrapProfiles = (ArrayList<BootstrapProfile>) savedInstanceState.getSerializable(EXTRA_BOOTSTRAP_SELECTED_PROFILES);
    mWebView.restoreState(savedInstanceState);

  } else {
    Intent intent = getIntent();
    mEvernoteService = intent.getParcelableExtra(EXTRA_EVERNOTE_SERVICE);
    mConsumerKey = intent.getStringExtra(EXTRA_CONSUMER_KEY);
    mConsumerSecret = intent.getStringExtra(EXTRA_CONSUMER_SECRET);
  }
}
 
Example #5
Source File: EvernoteOAuthActivity.java    From EverMemo-EverNote with MIT License 5 votes vote down vote up
@Override
protected String doInBackground(Void... params) {
  String url = null;
  try {

    EvernoteSession session = EvernoteSession.getOpenSession();
    if (session != null) {
      //Network request
      BootstrapManager.BootstrapInfoWrapper infoWrapper = session.getBootstrapSession().getBootstrapInfo();

      if (infoWrapper != null){
        BootstrapInfo info = infoWrapper.getBootstrapInfo();
        if(info != null) {
          mBootstrapProfiles = (ArrayList<BootstrapProfile>) info.getProfiles();
          if (mBootstrapProfiles != null &&
              mBootstrapProfiles.size() > 0 &&
              mSelectedBootstrapProfilePos < mBootstrapProfiles.size()){

            mSelectedBootstrapProfile = mBootstrapProfiles.get(mSelectedBootstrapProfilePos);
          }
        }
      }
    }

    if(mSelectedBootstrapProfile == null || TextUtils.isEmpty(mSelectedBootstrapProfile.getSettings().getServiceHost())) {
      Log.d(LOGTAG, "Bootstrap did not return a valid host");
      return null;
    }

    OAuthService service = createService();

    Log.i(LOGTAG, "Retrieving OAuth request token...");
    Token reqToken = service.getRequestToken();
    mRequestToken = reqToken.getToken();
    mRequestTokenSecret = reqToken.getSecret();

    Log.i(LOGTAG, "Redirecting user for authorization...");
    url = service.getAuthorizationUrl(reqToken);
  } catch(BootstrapManager.ClientUnsupportedException cue) {

    return null;
  } catch (Exception ex) {
    Log.e(LOGTAG, "Failed to obtain OAuth request token", ex);
  }
  return url;
}
 
Example #6
Source File: StoreOperationControllerUserStoreIntegrationTest.java    From evernote-rest-webapp with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetBootstrapInfo() throws Exception {
	BootstrapSettings settings = new BootstrapSettings();
	settings.setServiceHost("SERVICE_HOST");
	settings.setMarketingUrl("MARKETING_URL");
	settings.setSupportUrl("SUPPORT_URL");
	settings.setAccountEmailDomain("ACCOUNT_EMAIL_DOMAIN");
	settings.setEnableFacebookSharing(true);
	settings.setEnableGiftSubscriptions(true);
	settings.setEnableSupportTickets(true);
	settings.setEnableSharedNotebooks(true);
	settings.setEnableSingleNoteSharing(true);
	settings.setEnableSponsoredAccounts(true);
	settings.setEnableTwitterSharing(true);
	settings.setEnableLinkedInSharing(true);
	settings.setEnablePublicNotebooks(true);

	BootstrapProfile profile = new BootstrapProfile();
	profile.setName("PROFILE_NAME");
	profile.setSettings(settings);

	List<BootstrapProfile> profiles = new ArrayList<BootstrapProfile>();
	profiles.add(profile);

	BootstrapInfo bootstrapInfo = new BootstrapInfo();
	bootstrapInfo.setProfiles(profiles);
	when(userStoreOperations.getBootstrapInfo("foo")).thenReturn(bootstrapInfo);

	performRequest("/userStore/getBootstrapInfo", "{\"locale\": \"foo\"}")
			.andExpect(jsonPath("$.profiles[0].name").value("PROFILE_NAME"))
			.andExpect(jsonPath("$.profiles[0].settings.serviceHost").value("SERVICE_HOST"))
			.andExpect(jsonPath("$.profiles[0].settings.marketingUrl").value("MARKETING_URL"))
			.andExpect(jsonPath("$.profiles[0].settings.supportUrl").value("SUPPORT_URL"))
			.andExpect(jsonPath("$.profiles[0].settings.accountEmailDomain").value("ACCOUNT_EMAIL_DOMAIN"))
			.andExpect(jsonPath("$.profiles[0].settings.enableFacebookSharing").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableGiftSubscriptions").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableSupportTickets").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableSharedNotebooks").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableSingleNoteSharing").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableSponsoredAccounts").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableTwitterSharing").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enableLinkedInSharing").value(true))
			.andExpect(jsonPath("$.profiles[0].settings.enablePublicNotebooks").value(true))
	;
	verify(userStoreOperations).getBootstrapInfo("foo");
}
 
Example #7
Source File: EvernoteOAuthActivity.java    From EverMemo with MIT License 4 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Show web loading progress
	getWindow().requestFeature(Window.FEATURE_PROGRESS);

	setContentView(R.layout.esdk__webview);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	getSupportActionBar().setDisplayUseLogoEnabled(false);
	getSupportActionBar().setDisplayShowTitleEnabled(true);
	mActivity = this;

	mWebView = (WebView) findViewById(R.id.esdk__webview);
	mWebView.setWebViewClient(mWebViewClient);
	mWebView.setWebChromeClient(mWebChromeClient);
	mWebView.getSettings().setJavaScriptEnabled(true);

	if (savedInstanceState != null) {
		mEvernoteService = savedInstanceState
				.getParcelable(EXTRA_EVERNOTE_SERVICE);
		mConsumerKey = savedInstanceState.getString(EXTRA_CONSUMER_KEY);
		mConsumerSecret = savedInstanceState
				.getString(EXTRA_CONSUMER_SECRET);
		mRequestToken = savedInstanceState.getString(EXTRA_REQUEST_TOKEN);
		mRequestTokenSecret = savedInstanceState
				.getString(EXTRA_REQUEST_TOKEN_SECRET);
		mSelectedBootstrapProfile = (BootstrapProfile) savedInstanceState
				.getSerializable(EXTRA_BOOTSTRAP_SELECTED_PROFILE);
		mSelectedBootstrapProfilePos = savedInstanceState
				.getInt(EXTRA_BOOTSTRAP_SELECTED_PROFILE_POS);
		mBootstrapProfiles = (ArrayList<BootstrapProfile>) savedInstanceState
				.getSerializable(EXTRA_BOOTSTRAP_SELECTED_PROFILES);
		mWebView.restoreState(savedInstanceState);

	} else {
		Intent intent = getIntent();
		mEvernoteService = intent
				.getParcelableExtra(EXTRA_EVERNOTE_SERVICE);
		mConsumerKey = intent.getStringExtra(EXTRA_CONSUMER_KEY);
		mConsumerSecret = intent.getStringExtra(EXTRA_CONSUMER_SECRET);
	}
}