Package org.openstreetmap.josm.data.oauth

Examples of org.openstreetmap.josm.data.oauth.OAuthToken


        public void build() {
            if (! valAccessTokenKey.isValid() || !valAccessTokenSecret.isValid()) {
                setAccessToken(null);
            } else {
                setAccessToken(new OAuthToken(tfAccessTokenKey.getText().trim(), tfAccessTokenSecret.getText().trim()));
            }
        }
View Full Code Here


            try {
                getProgressMonitor().setTicksCount(3);
                authClient = new OsmOAuthAuthorizationClient(
                        getAdvancedPropertiesPanel().getAdvancedParameters()
                );
                OAuthToken requestToken = authClient.getRequestToken(
                        getProgressMonitor().createSubTaskMonitor(1, false)
                );
                getProgressMonitor().worked(1);
                if (canceled)return;
                authClient.authorise(
                        requestToken,
                        getOsmUserName(),
                        getOsmPassword(),
                        pnlOsmPrivileges.getPrivileges(),
                        getProgressMonitor().createSubTaskMonitor(1, false)
                );
                getProgressMonitor().worked(1);
                if (canceled)return;
                final OAuthToken accessToken = authClient.getAccessToken(
                        getProgressMonitor().createSubTaskMonitor(1,false)
                );
                getProgressMonitor().worked(1);
                if (canceled)return;
                GuiHelper.runInEDT(new Runnable() {
View Full Code Here

     * if the access token has changed
     *
     * @param accessToken the new access token. null, to clear the current access token
     */
    protected void setAccessToken(OAuthToken accessToken) {
        OAuthToken oldValue = this.accessToken;
        this.accessToken = accessToken;
        if (oldValue == null ^ this.accessToken == null) {
            fireAccessTokenChanged(oldValue, this.accessToken);
        } else if (oldValue == null && this.accessToken == null) {
            // no change - don't fire an event
        } else if (! oldValue.equals(this.accessToken)) {
            fireAccessTokenChanged(oldValue, this.accessToken);
        }
    }
View Full Code Here

        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            OAuthToken token = OAuthAccessTokenHolder.getInstance().getAccessToken();
            OAuthParameters parameters = OAuthParameters.createFromPreferences(Main.pref);
            TestAccessTokenTask task = new TestAccessTokenTask(
                    OAuthAuthenticationPreferencesPanel.this,
                    apiUrl,
                    parameters,
View Full Code Here

     * @return the access token, can be {@code null}
     */
    public OAuthToken getAccessToken() {
        if (!containsAccessToken())
            return null;
        return new OAuthToken(accessTokenKey, accessTokenSecret);
    }
View Full Code Here

     * @throws IllegalArgumentException thrown if cm is null
     */
    public void init(Preferences pref, CredentialsAgent cm) throws IllegalArgumentException {
        CheckParameterUtil.ensureParameterNotNull(pref, "pref");
        CheckParameterUtil.ensureParameterNotNull(cm, "cm");
        OAuthToken token = null;
        try {
            token = cm.lookupOAuthAccessToken();
        } catch(CredentialsAgentException e) {
            Main.error(e);
            Main.warn(tr("Failed to retrieve OAuth Access Token from credential manager"));
            Main.warn(tr("Current credential manager is of type ''{0}''", cm.getClass().getName()));
        }
        saveToPreferences = pref.getBoolean("oauth.access-token.save-to-preferences", true);
        if (token != null) {
            accessTokenKey = token.getKey();
            accessTokenSecret = token.getSecret();
        }
    }
View Full Code Here

        preferences.put("oauth.access-token.save-to-preferences", saveToPreferences);
        try {
            if (!saveToPreferences) {
                cm.storeOAuthAccessToken(null);
            } else {
                cm.storeOAuthAccessToken(new OAuthToken(accessTokenKey, accessTokenSecret));
            }
        } catch(CredentialsAgentException e){
            Main.error(e);
            Main.warn(tr("Failed to store OAuth Access Token to credentials manager"));
            Main.warn(tr("Current credential manager is of type ''{0}''", cm.getClass().getName()));
View Full Code Here

    public OAuthToken lookupOAuthAccessToken() throws CredentialsAgentException {
        String accessTokenKey = Main.pref.get("oauth.access-token.key", null);
        String accessTokenSecret = Main.pref.get("oauth.access-token.secret", null);
        if (accessTokenKey == null && accessTokenSecret == null)
            return null;
        return new OAuthToken(accessTokenKey, accessTokenSecret);
    }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.oauth.OAuthToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.