Search in sources :

Example 1 with Member

use of cz.metacentrum.perun.openapi.model.Member in project perun by CESNET.

the class GetExpirationByExtLogin method executeCommand.

@Override
public void executeCommand(PerunCLI.CommandContext ctx) {
    String extSourceName = ctx.getCommandLine().getOptionValue("E");
    Integer voId = getVoId(ctx, true);
    String filename = ctx.getCommandLine().getOptionValue("f");
    try {
        PerunRPC perunRPC = ctx.getPerunRPC();
        for (String login : Files.readAllLines(Paths.get(filename))) {
            Member member = perunRPC.getMembersManager().getMemberByExtSourceNameAndExtLogin(voId, login, extSourceName);
            Attribute attr = perunRPC.getAttributesManager().getMemberAttributeByName(member.getId(), "urn:perun:member:attribute-def:def:membershipExpiration");
            String expiration = (String) attr.getValue();
            System.out.println(login + ";" + expiration);
        }
    } catch (IOException e) {
        System.err.println("file " + filename + " cannot be read");
        System.exit(1);
    }
}
Also used : PerunRPC(cz.metacentrum.perun.openapi.PerunRPC) Attribute(cz.metacentrum.perun.openapi.model.Attribute) IOException(java.io.IOException) Member(cz.metacentrum.perun.openapi.model.Member)

Example 2 with Member

use of cz.metacentrum.perun.openapi.model.Member in project perun by CESNET.

the class ListOfVoMembersWithCertificate method executeCommand.

@Override
public void executeCommand(PerunCLI.CommandContext ctx) {
    Integer voId = this.getVoId(ctx, true);
    AttributesManagerApi attributesManager = ctx.getPerunRPC().getAttributesManager();
    int prefDNid = attributesManager.getAttributeDefinitionByName("urn:perun:user:attribute-def:def:userPreferredCertDN").getId();
    for (Member member : ctx.getPerunRPC().getMembersManager().getMembers(voId, null)) {
        String pdn = (String) attributesManager.getUserAttributeById(member.getUserId(), prefDNid).getValue();
        if (pdn != null) {
            User user = ctx.getPerunRPC().getUsersManager().getUserById(member.getUserId());
            System.out.println(user.getFirstName() + " " + user.getLastName() + " (" + member.getStatus() + ") " + pdn);
        }
    }
}
Also used : AttributesManagerApi(cz.metacentrum.perun.openapi.AttributesManagerApi) User(cz.metacentrum.perun.openapi.model.User) Member(cz.metacentrum.perun.openapi.model.Member)

Aggregations

Member (cz.metacentrum.perun.openapi.model.Member)2 AttributesManagerApi (cz.metacentrum.perun.openapi.AttributesManagerApi)1 PerunRPC (cz.metacentrum.perun.openapi.PerunRPC)1 Attribute (cz.metacentrum.perun.openapi.model.Attribute)1 User (cz.metacentrum.perun.openapi.model.User)1 IOException (java.io.IOException)1