Java Code Examples for org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException#getMessage()
The following examples show how to use
org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException#getMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractHelmMojo.java From helm-maven-plugin with MIT License | 5 votes |
/** * Get credentials for given helm repo. If username is not provided the repo * name will be used to search for credentials in <code>settings.xml</code>. * * @param repository Helm repo with id and optional credentials. * @return Authentication object or <code>null</code> if no credentials are present. * @throws IllegalArgumentException Unable to get authentication because of misconfiguration. * @throws MojoExecutionException Unable to get password from settings.xml */ PasswordAuthentication getAuthentication(HelmRepository repository) throws IllegalArgumentException, MojoExecutionException { String id = repository.getName(); if (repository.getUsername() != null) { if (repository.getPassword() == null) { throw new IllegalArgumentException("Repo " + id + " has a username but no password defined."); } getLog().debug("Repo " + id + " has credentials definded, skip searching in server list."); return new PasswordAuthentication(repository.getUsername(), repository.getPassword().toCharArray()); } Server server = settings.getServer(id); if (server == null) { getLog().info("No credentials found for " + id + " in configuration or settings.xml server list."); return null; } getLog().debug("Use credentials from server list for " + id + "."); if (server.getUsername() == null || server.getPassword() == null) { throw new IllegalArgumentException("Repo " + id + " was found in server list but has no username/password."); } try { return new PasswordAuthentication(server.getUsername(), getSecDispatcher().decrypt(server.getPassword()).toCharArray()); } catch (SecDispatcherException e) { throw new MojoExecutionException(e.getMessage()); } }
Example 2
Source File: AbstractBaseConfluenceMojo.java From maven-confluence-plugin with Apache License 2.0 | 5 votes |
/** * Issue 39 * * Load username password from settings if user has not set them in JVM properties * * @throws MojoExecutionException */ private void loadUserInfoFromSettings() throws MojoExecutionException { if ((getUsername() == null || getPassword() == null) && (mavenSettings != null)) { if (this.serverId == null) throw new MojoExecutionException("'serverId' must be set! (username and/or password are not provided)"); Server server = this.mavenSettings.getServer(this.serverId); if (server == null) throw new MojoExecutionException(String.format("server with id [%s] not found in settings!", this.serverId)); if (getUsername() == null && server.getUsername() != null) username = server.getUsername(); if (getPassword() == null && server.getPassword() != null) { try { // // FIX to resolve // org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: // java.io.FileNotFoundException: ~/.settings-security.xml (No such file or directory) // if (securityDispatcher instanceof DefaultSecDispatcher) { //System.setProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, sb.toString() ); ((DefaultSecDispatcher) securityDispatcher).setConfigurationFile("~/.m2/settings-security.xml"); } password = securityDispatcher.decrypt(server.getPassword()); } catch (SecDispatcherException e) { throw new MojoExecutionException(e.getMessage()); } } } }
Example 3
Source File: SignConfig.java From webstart with MIT License | 5 votes |
private String decrypt(String encoded ) throws MojoExecutionException { try { return securityDispatcher.decrypt( encoded ); } catch ( SecDispatcherException e ) { throw new MojoExecutionException( "error using security dispatcher: " + e.getMessage(), e ); } }
Example 4
Source File: SqlExecMojo.java From sql-maven-plugin with Apache License 2.0 | 4 votes |
/** * Load username password from settings if user has not set them in JVM properties * * @throws MojoExecutionException */ private void loadUserInfoFromSettings() throws MojoExecutionException { if ( this.settingsKey == null ) { this.settingsKey = getUrl(); } if ( ( getUsername() == null || getPassword() == null ) && ( settings != null ) ) { Server server = this.settings.getServer( this.settingsKey ); if ( server != null ) { if ( getUsername() == null ) { setUsername( server.getUsername() ); } if ( getPassword() == null && server.getPassword() != null ) { try { setPassword( securityDispatcher.decrypt( server.getPassword() ) ); } catch ( SecDispatcherException e ) { throw new MojoExecutionException( e.getMessage() ); } } } } if ( getUsername() == null ) { // allow empty username setUsername( "" ); } if ( getPassword() == null ) { // allow empty password setPassword( "" ); } }