All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.hyperchain.sdk.service.impl.AuthServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package cn.hyperchain.sdk.service.impl;

import cn.hyperchain.sdk.provider.ProviderManager;
import cn.hyperchain.sdk.request.AuthRequest;
import cn.hyperchain.sdk.request.Request;
import cn.hyperchain.sdk.response.auth.AddressesResponse;
import cn.hyperchain.sdk.response.auth.InspectorRulesResponse;
import cn.hyperchain.sdk.response.auth.Response;
import cn.hyperchain.sdk.response.auth.RolesResponse;
import cn.hyperchain.sdk.service.AuthService;
import cn.hyperchain.sdk.service.params.InspectorRuleParam;

import java.util.List;

public class AuthServiceImpl implements AuthService {
    private ProviderManager providerManager;
    private static final String AUTH_PREFIX = "auth_";

    public AuthServiceImpl() {}

    public AuthServiceImpl(ProviderManager providerManager) {
        this.providerManager = providerManager;
    }

    @Override
    public Request getAllRoles(int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "getAllRoles", providerManager, RolesResponse.class, nodeIds);
        return authRequest;
    }

    @Override
    public Request getRolesByAddress(String address, int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "getRole", providerManager, RolesResponse.class, nodeIds);
        authRequest.addParams(address);
        return authRequest;
    }

    @Override
    public Request getAddressByRole(String role, int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "getAddress", providerManager, AddressesResponse.class, nodeIds);
        authRequest.addParams(role);
        return authRequest;
    }

    @Override
    public Request addRoles(String address, List roles, int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "addRole", providerManager, Response.class, nodeIds);
        authRequest.addParams(address);
        authRequest.addParams(roles);
        return authRequest;
    }

    @Override
    public Request deleteRoles(String address, List roles, int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "deleteRole", providerManager, Response.class, nodeIds);
        authRequest.addParams(address);
        authRequest.addParams(roles);
        return authRequest;
    }

    @Override
    public Request setRules(List rules, int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "setRules", providerManager, Response.class, nodeIds);
        authRequest.addParams(rules);
        return authRequest;
    }

    @Override
    public Request getRules(int... nodeIds) {
        AuthRequest authRequest = new AuthRequest(AUTH_PREFIX + "getRules", providerManager, InspectorRulesResponse.class, nodeIds);
        return authRequest;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy