For a Testcase i need to remove a user on which we have allready Tasks in designer. When I remove the User in User Editor he ist still existing in ISecurityContext.getUsers(). Only when i close the designer and reopen it the user is removed. But than also all tasks are away.

Is there a way to remove the User without closing Axon.Ivy Designer?

asked 10.01 at 08:18

Thomas%20Wirz's gravatar image

Thomas Wirz
764512
accept rate: 33%


I think the only one way for now is to implement a helper process and calling ch.ivyteam.ivy.security.ISecurityContext.deleteUser(String)

link

answered 14.01 at 03:37

Alex%20Suter's gravatar image

Alex Suter ♦♦
2.1k81936
accept rate: 84%

For other Visitor thats finally the code I implemented:

public static void deleteUser(String userName) throws EnvironmentNotAvailableException, Exception{
            SecurityManager.getSecurityManager().executeAsSystem(() -> {
                try {
                    IUser user = Ivy.wf().getSecurityContext().findUser(userName);
                    user.getRoles().stream().filter(role -> role.getId() != 1).forEach(role -> user.removeRole(role));
                    Ivy.wf().getSecurityContext().deleteUser(userName);
                }
                catch (Exception ex){
                    Ivy.log().error("error on delete user "+userName,ex);
                }
                return true;
            }); 
    }

public static void addUser(String userName, String displayName,String password, Locale language, String email) throws EnvironmentNotAvailableException, Exception{
    SecurityManager.getSecurityManager().executeAsSystem(() -> {
        try
        {
            IUser user = Ivy.wf().getSecurityContext().createUser(userName, displayName, password, language, email, userName);
            Ivy.wf().getSecurityContext().getActiveRoles().stream().filter(role -> role.getId() != 1).forEach(role -> {
                Ivy.log().fatal(role.getName() +" / " + role.getDisplayName() +" / " +role.getId() +" / ");
                user.addRole(role);
            });
        }catch(Exception ex){
            Ivy.log().error(ex);
        }
        return true;
    });
link

answered 16.01 at 04:40

Thomas%20Wirz's gravatar image

Thomas Wirz
764512
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×71
×26

Asked: 10.01 at 08:18

Seen: 180 times

Last updated: 16.01 at 04:40