Example usage for org.apache.shiro.realm.text IniRealm USERS_SECTION_NAME

List of usage examples for org.apache.shiro.realm.text IniRealm USERS_SECTION_NAME

Introduction

In this page you can find the example usage for org.apache.shiro.realm.text IniRealm USERS_SECTION_NAME.

Prototype

String USERS_SECTION_NAME

To view the source code for org.apache.shiro.realm.text IniRealm USERS_SECTION_NAME.

Click Source Link

Usage

From source file:ApacheShiro.ShiroMVC.java

public void CrearIni() {
    defaultSecurityManager = new DefaultSecurityManager();
    ini = new Ini();
    usuarios = ini.addSection(IniRealm.USERS_SECTION_NAME);
    roles = ini.addSection(IniRealm.ROLES_SECTION_NAME);

    //        defaultSecurityManager.setRealm(new IniRealm(ini));
    //        SecurityUtils.setSecurityManager(defaultSecurityManager);
}

From source file:org.apache.aurora.scheduler.http.api.security.ApiSecurityIT.java

License:Apache License

@Before
public void setUp() {
    ini = new Ini();

    Ini.Section users = ini.addSection(IniRealm.USERS_SECTION_NAME);
    users.put(ROOT.getUserName(), COMMA_JOINER.join(ROOT.getPassword(), ADMIN_ROLE));
    users.put(WFARNER.getUserName(), COMMA_JOINER.join(WFARNER.getPassword(), ENG_ROLE));
    users.put(UNPRIVILEGED.getUserName(), UNPRIVILEGED.getPassword());
    users.put(BACKUP_SERVICE.getUserName(), COMMA_JOINER.join(BACKUP_SERVICE.getPassword(), BACKUP_ROLE));
    users.put(DEPLOY_SERVICE.getUserName(), COMMA_JOINER.join(DEPLOY_SERVICE.getPassword(), DEPLOY_ROLE));

    Ini.Section roles = ini.addSection(IniRealm.ROLES_SECTION_NAME);
    roles.put(ADMIN_ROLE, "*");
    roles.put(ENG_ROLE, "thrift.AuroraSchedulerManager:*");
    roles.put(BACKUP_ROLE, "thrift.AuroraAdmin:listBackups");
    roles.put(DEPLOY_ROLE, "thrift.AuroraSchedulerManager:killTasks:" + ADS_STAGING_JOB.getRole() + ":"
            + ADS_STAGING_JOB.getEnvironment() + ":" + ADS_STAGING_JOB.getName());

    auroraAdmin = createMock(AnnotatedAuroraAdmin.class);
    statsProvider = createMock(StatsProvider.class);
    expect(statsProvider.makeCounter(anyString())).andStubReturn(new AtomicLong());
}

From source file:org.apache.aurora.scheduler.http.api.security.HttpSecurityIT.java

License:Apache License

@Before
public void setUp() {
    ini = new Ini();

    Ini.Section users = ini.addSection(IniRealm.USERS_SECTION_NAME);
    users.put(ROOT.getUserName(), COMMA_JOINER.join(ROOT.getPassword(), ADMIN_ROLE));
    users.put(WFARNER.getUserName(), COMMA_JOINER.join(WFARNER.getPassword(), ENG_ROLE));
    users.put(UNPRIVILEGED.getUserName(), UNPRIVILEGED.getPassword());
    users.put(BACKUP_SERVICE.getUserName(), COMMA_JOINER.join(BACKUP_SERVICE.getPassword(), BACKUP_ROLE));
    users.put(DEPLOY_SERVICE.getUserName(), COMMA_JOINER.join(DEPLOY_SERVICE.getPassword(), DEPLOY_ROLE));
    users.put(H2_USER.getUserName(), COMMA_JOINER.join(H2_USER.getPassword(), H2_ROLE));

    Ini.Section roles = ini.addSection(IniRealm.ROLES_SECTION_NAME);
    roles.put(ADMIN_ROLE, "*");
    roles.put(ENG_ROLE, "thrift.AuroraSchedulerManager:*");
    roles.put(BACKUP_ROLE, "thrift.AuroraAdmin:listBackups");
    roles.put(DEPLOY_ROLE, "thrift.AuroraSchedulerManager:killTasks:" + ADS_STAGING_JOB.getRole() + ":"
            + ADS_STAGING_JOB.getEnvironment() + ":" + ADS_STAGING_JOB.getName());
    roles.put(H2_ROLE, H2_PERM);//w  w  w. j  ava 2 s.  c om

    auroraAdmin = createMock(AnnotatedAuroraAdmin.class);
    shiroAfterAuthFilter = createMock(Filter.class);
}

From source file:org.obiba.opal.core.upgrade.security.HashShiroIniPasswordUpgradeStepTest.java

License:Open Source License

@Test
public void testExecute() throws Exception {

    String iniFileMd5 = new Md5Hash(iniFile).toHex();

    upgradeStep.execute(null);/*from w  w w  .  jav  a 2 s.co  m*/

    assertThat(iniBackup.exists()).isTrue();
    assertThat(new Md5Hash(iniBackup).toHex()).isEqualTo(iniFileMd5);
    assertThat(destIniFile.exists()).isTrue();
    assertThat(new Md5Hash(destIniFile).toHex()).isNotEqualTo(iniFileMd5);

    Ini ini = new Ini();
    ini.loadFromPath(destIniFile.getAbsolutePath());
    Ini.Section section = ini.getSection(IniRealm.USERS_SECTION_NAME);
    assertThat(section).isNotNull();
    assertThat(section).hasSize(3);
    for (String username : usernamePassword.keySet()) {
        assertThat(section.containsKey(username)).isTrue();
        String[] passwordAndRolesArray = StringUtils.split(section.get(username));
        String encrypted = passwordAndRolesArray[0];
        assertThat(passwordService.passwordsMatch(usernamePassword.get(username), encrypted)).isTrue();
    }

}

From source file:org.obiba.opal.core.upgrade.v2_0_x.HashShiroIniPasswordUpgradeStep.java

License:Open Source License

private Map<String, String> getUsernamePasswords() {
    Ini ini = new Ini();
    ini.loadFromPath(srcIniFile.getAbsolutePath());
    Ini.Section section = ini.getSection(IniRealm.USERS_SECTION_NAME);
    if (section == null || section.isEmpty()) {
        return Collections.emptyMap();
    }/*from  w ww .j  a  v  a2s .c  o m*/

    Map<String, String> map = new LinkedHashMap<>();
    for (Map.Entry<String, String> entry : section.entrySet()) {
        String username = entry.getKey();
        String[] passwordAndRolesArray = StringUtils.split(entry.getValue());
        String password = passwordAndRolesArray[0];
        map.put(username, password);
    }
    return map;
}

From source file:org.ow2.proactive.workflowcatalog.security.LoginConfigurationIniRealm.java

License:Open Source License

public Ini.Section getUsersSection() {
    return ini.getSection(IniRealm.USERS_SECTION_NAME);
}