Examples of Ini


Examples of org.apache.shiro.config.Ini

    InputStream inputStream = null;
    try {
      LOGGER.info("Opening " + path);
      String dfsUri = fileSystem.getDefaultUri(fileSystem.getConf()).toString();
      inputStream = fileSystem.open(path);
      Ini ini = new Ini();
      ini.load(inputStream);
      return ini;
    } finally {
      if(inputStream != null) {
        try {
          inputStream.close();
View Full Code Here

Examples of org.apache.shiro.config.Ini

  private void parse() {
    configErrors.clear();
    configWarnings.clear();
    Table<String, String, Set<String>> groupRolePrivilegeTableTemp = HashBasedTable.create();
    Ini ini;
    LOGGER.info("Parsing " + resourcePath);
    LOGGER.info("Filesystem: " + fileSystem.getUri());
    try {
      try {
        ini = PolicyFiles.loadFromPath(fileSystem, resourcePath);
      } catch (IOException e) {
        configErrors.add("Failed to read policy file " + resourcePath +
          " Error: " + e.getMessage());
        throw new SentryConfigurationException("Error loading policy file " + resourcePath, e);
      } catch (IllegalArgumentException e) {
        configErrors.add("Failed to read policy file " + resourcePath +
          " Error: " + e.getMessage());
        throw new SentryConfigurationException("Error loading policy file " + resourcePath, e);
      }

      if(LOGGER.isDebugEnabled()) {
        for(String sectionName : ini.getSectionNames()) {
          LOGGER.debug("Section: " + sectionName);
          Ini.Section section = ini.get(sectionName);
          for(String key : section.keySet()) {
            String value = section.get(key);
            LOGGER.debug(key + " = " + value);
          }
        }
      }
      parseIni(null, ini, validators, resourcePath, groupRolePrivilegeTableTemp);
      mergeResult(groupRolePrivilegeTableTemp);
      groupRolePrivilegeTableTemp.clear();
      Ini.Section filesSection = ini.getSection(DATABASES);
      if(filesSection == null) {
        LOGGER.info("Section " + DATABASES + " needs no further processing");
      } else if (!allowPerDatabaseSection) {
        String msg = "Per-db policy file is not expected in this configuration.";
        throw new SentryConfigurationException(msg);
      } else {
        for(Map.Entry<String, String> entry : filesSection.entrySet()) {
          String database = Strings.nullToEmpty(entry.getKey()).trim().toLowerCase();
          Path perDbPolicy = new Path(Strings.nullToEmpty(entry.getValue()).trim());
          if(isRelative(perDbPolicy)) {
            perDbPolicy = new Path(resourcePath.getParent(), perDbPolicy);
          }
          try {
            LOGGER.debug("Parsing " + perDbPolicy);
            Ini perDbIni = PolicyFiles.loadFromPath(perDbPolicy.getFileSystem(conf), perDbPolicy);
            if(perDbIni.containsKey(USERS)) {
              configErrors.add("Per-db policy file cannot contain " + USERS + " section in " +  perDbPolicy);
              throw new SentryConfigurationException("Per-db policy files cannot contain " + USERS + " section");
            }
            if(perDbIni.containsKey(DATABASES)) {
              configErrors.add("Per-db policy files cannot contain " + DATABASES
                  + " section in " + perDbPolicy);
              throw new SentryConfigurationException("Per-db policy files cannot contain " + DATABASES + " section");
            }
            parseIni(database, perDbIni, validators, perDbPolicy, groupRolePrivilegeTableTemp);
View Full Code Here

Examples of org.apache.shiro.config.Ini

      return Collections.emptySet();
    }
  }

  private void parseGroups(FileSystem fileSystem, Path resourcePath) throws IOException {
    Ini ini = PolicyFiles.loadFromPath(fileSystem, resourcePath);
    Section usersSection = ini.getSection(PolicyFileConstants.USERS);
    if (usersSection == null) {
      LOGGER.warn("No section " + PolicyFileConstants.USERS + " in the " + resourcePath);
      return;
    }
    for (Entry<String, String> userEntry : usersSection.entrySet()) {
View Full Code Here

Examples of org.apache.shiro.config.Ini

    @Before
    public void setup() {
        sm = new DefaultWebSecurityManager();
        sm.setSessionMode(DefaultWebSecurityManager.NATIVE_SESSION_MODE);
        Ini ini = new Ini();
        Ini.Section section = ini.addSection(IniRealm.USERS_SECTION_NAME);
        section.put("lonestarr", "vespa");
        sm.setRealm(new IniRealm(ini));
    }
View Full Code Here

Examples of org.apache.shiro.config.Ini

     * Asserts fix for <a href="https://issues.apache.org/jira/browse/SHIRO-350">SHIRO-350</a>.
     */
    @Test
    public void testBuildNonWebSubjectWithDefaultServletContainerSessionManager() {

        Ini ini = new Ini();
        Ini.Section section = ini.addSection(IniRealm.USERS_SECTION_NAME);
        section.put("user1", "user1");

        WebIniSecurityManagerFactory factory = new WebIniSecurityManagerFactory(ini);

        WebSecurityManager securityManager = (WebSecurityManager)factory.getInstance();
View Full Code Here

Examples of org.apache.shiro.config.Ini

    @Before
    public void setup() {
        sm = new DefaultWebSecurityManager();
        sm.setSessionMode(DefaultWebSecurityManager.NATIVE_SESSION_MODE);
        Ini ini = new Ini();
        Ini.Section section = ini.addSection(IniRealm.USERS_SECTION_NAME);
        section.put("lonestarr", "vespa");
        sm.setRealm(new IniRealm(ini));
    }
View Full Code Here

Examples of org.apache.shiro.config.Ini

  protected void parse() {
    LOGGER.info("Parsing " + resourcePath);
    Roles roles = new Roles();
    try {
      perDbResources.clear();
      Ini ini = PolicyFiles.loadFromPath(fileSystem, resourcePath);
      if(LOGGER.isDebugEnabled()) {
        for(String sectionName : ini.getSectionNames()) {
          LOGGER.debug("Section: " + sectionName);
          Ini.Section section = ini.get(sectionName);
          for(String key : section.keySet()) {
            String value = section.get(key);
            LOGGER.debug(key + " = " + value);
          }
        }
      }
      ImmutableSetMultimap<String, String> globalRoles;
      Map<String, ImmutableSetMultimap<String, String>> perDatabaseRoles = Maps.newHashMap();
      globalRoles = parseIni(null, ini);
      Ini.Section filesSection = ini.getSection(DATABASES);
      if(filesSection == null) {
        LOGGER.info("Section " + DATABASES + " needs no further processing");
      } else {
        for(Map.Entry<String, String> entry : filesSection.entrySet()) {
          String database = Strings.nullToEmpty(entry.getKey()).trim().toLowerCase();
          Path perDbPolicy = new Path(Strings.nullToEmpty(entry.getValue()).trim());
          if(isRelative(perDbPolicy)) {
            perDbPolicy = new Path(resourcePath.getParent(), perDbPolicy);
          }
          try {
            LOGGER.info("Parsing " + perDbPolicy);
            Ini perDbIni = PolicyFiles.loadFromPath(perDbPolicy.getFileSystem(conf), perDbPolicy);
            if(perDbIni.containsKey(USERS)) {
              throw new ConfigurationException("Per-db policy files cannot contain " + USERS + " section");
            }
            if(perDbIni.containsKey(DATABASES)) {
              throw new ConfigurationException("Per-db policy files cannot contain " + DATABASES + " section");
            }
            ImmutableSetMultimap<String, String> currentDbRoles = parseIni(database, perDbIni);
            perDatabaseRoles.put(database, currentDbRoles);
            perDbResources.add(perDbPolicy);
View Full Code Here

Examples of org.apache.shiro.config.Ini

      return Collections.emptyList();
    }
  }

  private void parseGroups(FileSystem fileSystem, Path resourcePath) throws IOException {
    Ini ini = PolicyFiles.loadFromPath(fileSystem, resourcePath);
    Section usersSection = ini.getSection(PolicyFileConstants.USERS);
    if (usersSection == null) {
      LOGGER.warn("No section " + PolicyFileConstants.USERS + " in the " + resourcePath);
      return;
    }
    for (Entry<String, String> userEntry : usersSection.entrySet()) {
View Full Code Here

Examples of org.apache.shiro.config.Ini

  public static Ini loadFromPath(FileSystem fileSystem, Path path) throws IOException {
    InputStream inputStream = null;
    try {
      LOGGER.info("Opening " + path);
      inputStream = fileSystem.open(path);
      Ini ini = new Ini();
      ini.load(inputStream);
      return ini;
    } finally {
      if(inputStream != null) {
        try {
          inputStream.close();
View Full Code Here

Examples of org.apache.shiro.config.Ini

     * Test that ensures the WebIniSecurityManagerFactory will automatically add the default
     * filters to the pool of beans before the INI configuration is interpreted.
     */
    @Test
    public void testDefaultFiltersPresent() {
        Ini ini = new Ini();
        //just a normal configuration line in the MAIN section for any of the default filtes should work
        //out of the box.  So, create the main section and just config one of them:
        Ini.Section section = ini.addSection(IniSecurityManagerFactory.MAIN_SECTION_NAME);
        section.put("authc.loginUrl", "/login.jsp");

        WebIniSecurityManagerFactory factory = new WebIniSecurityManagerFactory(ini);
        org.apache.shiro.mgt.SecurityManager sm = factory.getInstance();
        assertNotNull(sm);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.