Examples of CredentialsAgentResponse


Examples of org.openstreetmap.josm.io.auth.CredentialsAgentResponse

                        String username = Main.pref.get("osm-server.username", null);
                        String password = Main.pref.get("osm-server.password", null);
                        return username != null && !username.isEmpty() && password != null && !password.isEmpty();
                    }
                } else {
                    CredentialsAgentResponse credentials = credManager.getCredentials(
                            RequestorType.SERVER, OsmApi.getOsmApi().getHost(), false);
                    if (credentials != null) {
                        String username = credentials.getUsername();
                        char[] password = credentials.getPassword();
                        return username != null && !username.isEmpty() && password != null && password.length > 0;
                    }
                }
            } catch (CredentialsAgentException e) {
                Main.warn("Unable to get credentials: "+e.getMessage());
View Full Code Here

Examples of org.openstreetmap.josm.io.auth.CredentialsAgentResponse

     * @param con the connection
     * @throws OsmTransferException thrown if something went wrong. Check for nested exceptions
     */
    protected void addBasicAuthorizationHeader(HttpURLConnection con) throws OsmTransferException {
        CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
        CredentialsAgentResponse response;
        String token;
        try {
            synchronized (CredentialsManager.getInstance()) {
                response = CredentialsManager.getInstance().getCredentials(RequestorType.SERVER,
                con.getURL().getHost(), false /* don't know yet whether the credentials will succeed */);
            }
        } catch (CredentialsAgentException e) {
            throw new OsmTransferException(e);
        }
        if (response == null) {
            token = ":";
        } else if (response.isCanceled()) {
            cancel = true;
            return;
        } else {
            String username= response.getUsername() == null ? "" : response.getUsername();
            String password = response.getPassword() == null ? "" : String.valueOf(response.getPassword());
            token = username + ":" + password;
            try {
                ByteBuffer bytes = encoder.encode(CharBuffer.wrap(token));
                con.addRequestProperty("Authorization", "Basic "+Base64.encode(bytes));
            } catch(CharacterCodingException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.