Package org.sonatype.security.configuration.model

Examples of org.sonatype.security.configuration.model.SecurityConfiguration


      throw new ConfigurationException("Could not upgrade Security configuration! Please replace the "
          + file.getAbsolutePath() + " file with a valid Security configuration file.");
    }

    // Need to decrypt the anonymous user's password
    SecurityConfiguration configuration = this.getConfiguration();
    if (StringUtils.isNotEmpty(configuration.getAnonymousPassword())) {
      String encryptedPassword = configuration.getAnonymousPassword();
      try {
        configuration.setAnonymousPassword(this.passwordHelper.decrypt(encryptedPassword));
      }
      catch (Exception e) {
        this.getLogger().error(
            "Failed to decrypt anonymous user's password in security-configuration.xml, password might be encrypted in memory.",
            e);
View Full Code Here


      fis = new FileInputStream(file);

      loadConfiguration(fis);

      // decrypte the anon users password
      SecurityConfiguration configuration = this.getConfiguration();
      if (configuration != null && StringUtils.isNotEmpty(configuration.getAnonymousPassword())) {
        String encryptedPassword = configuration.getAnonymousPassword();
        try {
          configuration.setAnonymousPassword(this.passwordHelper.decrypt(encryptedPassword));
        }
        catch (Exception e) {
          this.getLogger().error(
              "Failed to decrypt anonymous user's password in security-configuration.xml, password might be encrypted in memory.",
              e);
View Full Code Here

              + "******************************************************************************";
      getLogger().error(message);
      throw new IOException("Could not create configuration file " + file.getAbsolutePath(), e);
    }

    final SecurityConfiguration configuration = getConfiguration();
    checkNotNull(configuration, "Missing security configuration");
    // store clear text password, as we have to encrypt the persisted password
    final String clearPassword = configuration.getAnonymousPassword();
    try {
      configuration.setAnonymousPassword(passwordHelper.encrypt(clearPassword));
    }
    catch (Exception e) {
      getLogger().warn(
          "Failed to encrypt the anonymous users password, storing configuration with cleartext password!", e);
    }

    try {
      // perform the "safe save"
      getLogger().debug("Saving configuration: {}", file);
      final FileReplacer fileReplacer = new FileReplacer(file);
      fileReplacer.setDeleteBackupFile(true);

      fileReplacer.replace(new ContentWriter()
      {
        @Override
        public void write(final BufferedOutputStream output)
            throws IOException
        {
          new SecurityConfigurationXpp3Writer().write(output, configuration);
        }
      });
    }
    finally {

      // set back to clear text
      configuration.setAnonymousPassword(clearPassword);
    }
  }
View Full Code Here

    else {
      this.getLogger().warn("Default static security configuration not found in classpath: "
          + STATIC_SECURITY_RESOURCE);
    }

    SecurityConfiguration configuration = getConfiguration();

    return configuration;
  }
View Full Code Here

                                          ValidationRequest<SecurityConfiguration> request)
  {
    ValidationResponse validationResponse = new ValidationResponse();
    validationResponse.setContext(context);

    SecurityConfiguration configuration = request.getConfiguration();

    validationResponse.append(this.validateAnonymousUsername(context, configuration.getAnonymousUsername()));
    validationResponse.append(this.validateAnonymousPassword(context, configuration.getAnonymousPassword()));
    validationResponse.append(this.validateRealms(context, configuration.getRealms()));

    return validationResponse;
  }
View Full Code Here

  private void testUpgrade(String filename)
      throws Exception
  {
    copyFromClasspathToFile(UPGRADE_HOME + "/" + filename, getSecurityConfiguration());

    SecurityConfiguration configuration = configurationUpgrader
        .loadOldConfiguration(new File(getSecurityConfiguration()));

    assertThat(configuration.getVersion(), is(SecurityConfiguration.MODEL_VERSION));

    resultIsFine(UPGRADE_HOME + "/" + filename, configuration);
  }
View Full Code Here

    super.setUp();

    CONFIG_DIR.mkdirs();

    SecurityConfigurationSource source = this.lookup(SecurityConfigurationSource.class, "file");
    SecurityConfiguration config = source.loadConfiguration();

    config.setRealms(new ArrayList<String>(realmMap.keySet()));
    source.storeConfiguration();

    lookup(SecuritySystem.class).start();
  }
View Full Code Here

TOP

Related Classes of org.sonatype.security.configuration.model.SecurityConfiguration

Copyright © 2018 www.massapicom. 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.