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

org.kie.config.cli.CliIdentity Maven / Gradle / Ivy

There is a newer version: 7.0.0.Beta1
Show newest version
package org.kie.config.cli;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Alternative;

import org.jboss.errai.security.shared.api.Group;
import org.jboss.errai.security.shared.api.Role;
import org.jboss.errai.security.shared.api.identity.User;

/**
 * An alternative Identity used from the CLI to ensure the user has ADMIN permissions
 */
@Alternative
@ApplicationScoped
public class CliIdentity implements User {

    private static final long serialVersionUID = -9178650167557721039L;

    private Set roles = new HashSet();

    @PostConstruct
    public void setup() {
        roles.add( EnvironmentProvider.ADMIN_ROLE );
    }

    @Override
    public String getIdentifier() {
        return System.getProperty( "user.name" );
    }

    @Override
    public Set getRoles() {
        return roles;
    }

    @Override
    public Set getGroups() {
        return Collections.emptySet();
    }

    @Override
    public Map getProperties() {
        return Collections.emptyMap();
    }

    @Override
    public void setProperty( String s,
                             String s2 ) {

    }

    @Override
    public void removeProperty( String name ) {
    }

    @Override
    public String getProperty( String s ) {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy