<commit_before>/**
 * $Revision$
 * $Date$
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
 */
package org.jivesoftware.openfire.clearspace;

import org.jivesoftware.openfire.auth.AuthProvider;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.user.UserNotFoundException;

/**
 * @author <NAME>
 */
public class ClearspaceAuthProvider implements AuthProvider {
    public boolean isPlainSupported() {
        return true;
    }

    public boolean isDigestSupported() {
        return true;
    }

    public void authenticate(String username, String password) throws UnauthorizedException {
        // Nothing
    }

    public void authenticate(String username, String token, String digest) throws UnauthorizedException {
        // Nothing
    }

    public String getPassword(String username) throws UserNotFoundException, UnsupportedOperationException {
        return (username.equals("admin") ? "test" : "<PASSWORD>");
    }

    public void setPassword(String username, String password) throws UserNotFoundException, UnsupportedOperationException {
        // Nothing
    }

    public boolean supportsPasswordRetrieval() {
        return false;
    }
}<commit_msg>Create CSAuthProvider to integrate with Clearspace. JM-1224<commit_after>/**
 * $Revision$
 * $Date$
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
 */
package org.jivesoftware.openfire.clearspace;

import org.jivesoftware.openfire.auth.AuthProvider;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET;
import org.jivesoftware.openfire.user.UserNotFoundException;

/**
 * @author <NAME>
 */
public class ClearspaceAuthProvider implements AuthProvider {
    protected static final String URL_PREFIX = "permissionService/";

    private ClearspaceManager manager;

    public ClearspaceAuthProvider() {
        // gets the manager
        manager = ClearspaceManager.getInstance();
    }

    public boolean isPlainSupported() {
        return true;
    }

    public boolean isDigestSupported() {
        return false;
    }

    public void authenticate(String username, String password) throws UnauthorizedException {
        try {
            String path = URL_PREFIX + "authenticate/" + username + "/" + password;
            manager.executeRequest(GET, path);
        } catch (UnauthorizedException ue) {
            throw ue;
        } catch (Exception e) {
            // It is not supported exception, wrap it into an UnsupportedOperationException
            throw new UnsupportedOperationException("Unexpected error", e);
        }
    }

    public void authenticate(String username, String token, String digest) throws UnauthorizedException {
        throw new UnsupportedOperationException("Digest not supported");
    }

    public String getPassword(String username) throws UserNotFoundException, UnsupportedOperationException {
        throw new UnsupportedOperationException("Password retrieval not supported");
    }

    public void setPassword(String username, String password) throws UserNotFoundException, UnsupportedOperationException {
        throw new UnsupportedOperationException("Change Password not supported");
    }

    public boolean supportsPasswordRetrieval() {
        return false;
    }
}
{'fraction_non_alphanumeric': 0.07929515418502203, 'fraction_numerical': 0.003303964757709251, 'mean_word_length': 3.5526315789473686, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5630722', 'n_tokens_mistral': 921, 'n_tokens_neox': 895, 'n_words': 275}