Examples of GlobalConfigurationResource


Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

  @Override
  protected void runOnce()
      throws Exception
  {
    // disable anonymous access
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    settings.setSecurityAnonymousAccessEnabled(false);
    SettingsMessageUtil.save(settings);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

  public void init()
      throws Exception
  {
    baseUrl = nexusBaseUrl.replace("nexus", "nexus1696").replace("http", "https");

    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    RestApiSettings restApiSettings = new RestApiSettings();
    restApiSettings.setForceBaseUrl(true);
    restApiSettings.setBaseUrl(baseUrl);
    settings.setGlobalRestApiSettings(restApiSettings);

    SettingsMessageUtil.save(settings);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

  public void resetBaseUrl()
      throws Exception
  {
    baseUrl = nexusBaseUrl;

    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    RestApiSettings restApiSettings = new RestApiSettings();
    restApiSettings.setForceBaseUrl(true);
    restApiSettings.setBaseUrl(baseUrl);
    settings.setGlobalRestApiSettings(restApiSettings);

    SettingsMessageUtil.save(settings);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

  @Override
  protected void runOnce()
      throws Exception
  {
    // disable anonymous access
    GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
    settings.setSecurityAnonymousAccessEnabled(false);
    SettingsMessageUtil.save(settings);

  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

    if (!DEFAULT_CONFIG_NAME.equals(configurationName) && !CURRENT_CONFIG_NAME.equals(configurationName)) {
      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND);
    }
    else {
      GlobalConfigurationResource resource = new GlobalConfigurationResource();

      if (DEFAULT_CONFIG_NAME.equals(configurationName)) {
        fillDefaultConfiguration(request, resource);
      }
      else {
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

    }
    else {
      GlobalConfigurationResourceResponse configRequest = (GlobalConfigurationResourceResponse) payload;

      if (configRequest != null) {
        GlobalConfigurationResource resource = configRequest.getData();

        try {
          if (resource.getSmtpSettings() != null) {
            SmtpSettings settings = resource.getSmtpSettings();

            getNexusEmailer().setSMTPHostname(settings.getHost());

            // lookup old password
            String oldPassword = getNexusEmailer().getSMTPPassword();

            if (settings.getPassword() == null) {
              settings.setPassword("");
            }
            getNexusEmailer().setSMTPPassword(this.getActualPassword(settings.getPassword(), oldPassword));

            getNexusEmailer().setSMTPPort(settings.getPort());

            getNexusEmailer().setSMTPSslEnabled(settings.isSslEnabled());

            getNexusEmailer().setSMTPTlsEnabled(settings.isTlsEnabled());

            if (settings.getUsername() == null) {
              settings.setUsername("");
            }
            getNexusEmailer().setSMTPUsername(settings.getUsername());

            getNexusEmailer().setSMTPSystemEmailAddress(
                new Address(settings.getSystemEmailAddress().trim()));
          }

          if (resource.getGlobalConnectionSettings() != null) {
            RemoteConnectionSettings s = resource.getGlobalConnectionSettings();

            getGlobalRemoteConnectionSettings().setConnectionTimeout(s.getConnectionTimeout() * 1000);

            getGlobalRemoteConnectionSettings().setRetrievalRetryCount(s.getRetrievalRetryCount());

            getGlobalRemoteConnectionSettings().setQueryString(s.getQueryString());

            getGlobalRemoteConnectionSettings().setUserAgentCustomizationString(s.getUserAgentString());
          }

          setGlobalProxySettings(resource.getRemoteProxySettings(), getGlobalRemoteProxySettings());

          getNexusConfiguration().setRealms(resource.getSecurityRealms());

          final String anonymousUsername = resource.getSecurityAnonymousUsername();
          final String anonymousPassword =
              getActualPassword(resource.getSecurityAnonymousPassword(),
                  getNexusConfiguration().getAnonymousPassword());

          if (resource.isSecurityAnonymousAccessEnabled() && !StringUtils.isEmpty(anonymousUsername)
              && !StringUtils.isEmpty(anonymousPassword)) {
            getNexusConfiguration().setAnonymousAccess(true, anonymousUsername, anonymousPassword);
          }
          else if (resource.isSecurityAnonymousAccessEnabled()) {
            // the supplied anon auth info is wrong/empty
            getLogger().warn(
                "Nexus refused to apply configuration, the supplied anonymous username/pwd information is empty.");

            throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, getNexusErrorResponse(
                "securityAnonymousUsername", "Cannot be empty when Anonynous access is enabled"));
          }
          else {
            getNexusConfiguration().setAnonymousAccess(false, null, null);
          }

          if (resource.getGlobalRestApiSettings() != null) {
            RestApiSettings restApiSettings = resource.getGlobalRestApiSettings();

            getGlobalRestApiSettings().setForceBaseUrl(restApiSettings.isForceBaseUrl());

            if (StringUtils.isEmpty(resource.getGlobalRestApiSettings().getBaseUrl())) {
              getGlobalRestApiSettings().setBaseUrl(null);
            }
            else {
              getGlobalRestApiSettings().setBaseUrl(
                  new Reference(restApiSettings.getBaseUrl()).getTargetRef().toString());
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

  @Test
  public void testUpgrade()
      throws Exception
  {
    // Nexus should be started, lets check which Realms are loaded
    GlobalConfigurationResource globalConfig = SettingsMessageUtil.getCurrentSettings();

    // Assuming the LDAP realm
    List<String> realms = globalConfig.getSecurityRealms();
    Assert.assertEquals("Ldap realm was not configured, realms found are: " + realms, realms.get(0),
        "LdapAuthenticatingRealm");
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.GlobalConfigurationResource

  @Test
  public void testGlobalConfigurationResourceResponse() {
    GlobalConfigurationResourceResponse resourceResponse = new GlobalConfigurationResourceResponse();

    GlobalConfigurationResource resource = new GlobalConfigurationResource();
    resource.setSecurityAnonymousAccessEnabled(true);
    resource.setSecurityAnonymousPassword("anonPass");
    resource.setSecurityAnonymousUsername("anonUser");
    // TODO: Figure out why this is causing test to fail...
    // resource.setSecurityRealms( Arrays.asList( "realm1", "realm2" ) );

    RestApiSettings restSet = new RestApiSettings();
    restSet.setBaseUrl("baseUrl");
    restSet.setForceBaseUrl(false);
    resource.setGlobalRestApiSettings(restSet);

    RemoteConnectionSettings connSet = new RemoteConnectionSettings();
    connSet.setConnectionTimeout(2);
    connSet.setQueryString("queryString");
    connSet.setRetrievalRetryCount(6);
    connSet.setUserAgentString("userAgentString");
    resource.setGlobalConnectionSettings(connSet);

    RemoteHttpProxySettingsDTO proxyHttpSet = new RemoteHttpProxySettingsDTO();
    proxyHttpSet.setProxyHostname("proxyHostname1");
    proxyHttpSet.setProxyPort(78);
    AuthenticationSettings authSet = new AuthenticationSettings();
    authSet.setNtlmDomain("ntlmDomain1");
    authSet.setNtlmHost("ntlmHost1");
    authSet.setPassword("password1");
    authSet.setUsername("username1");
    proxyHttpSet.setAuthentication(authSet);

    RemoteHttpProxySettingsDTO proxyHttpsSet = new RemoteHttpProxySettingsDTO();
    proxyHttpsSet.setProxyHostname("proxyHostname2");
    proxyHttpsSet.setProxyPort(87);
    AuthenticationSettings httpsAuthSet = new AuthenticationSettings();
    httpsAuthSet.setNtlmDomain("ntlmDomain2");
    httpsAuthSet.setNtlmHost("ntlmHost2");
    httpsAuthSet.setPassword("password2");
    httpsAuthSet.setUsername("username2");
    proxyHttpsSet.setAuthentication(httpsAuthSet);

    RemoteProxySettingsDTO proxySet = new RemoteProxySettingsDTO();
    proxySet.setHttpProxySettings(proxyHttpSet);
    proxySet.setHttpsProxySettings(proxyHttpsSet);

    resource.setRemoteProxySettings(proxySet);

    SmtpSettings smtpSet = new SmtpSettings();
    smtpSet.setHost("host");
    smtpSet.setPassword("password");
    smtpSet.setPort(42);
    smtpSet.setSslEnabled(true);
    smtpSet.setSystemEmailAddress("foo@bar.com");
    smtpSet.setTlsEnabled(true);
    smtpSet.setUsername("username");
    resource.setSmtpSettings(smtpSet);

    resourceResponse.setData(resource);

    this.marshalUnmarchalThenCompare(resourceResponse);
    this.validateXmlHasNoPackageNames(resourceResponse);
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.