jelmerk / maven-settings-decoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle server without <username>

hankolerd opened this issue · comments

Not all server definitions use the username element. I just want to suggest handling of those elements that use only password (when using OUATH), or just passphrase (when dealing with encrypted files). Examples:


<server>
	<!-- Works fine with username and password -->
	<id>central</id>
	<username>aibaioe</username>
	<password>{mBwLxJFyppMH2940209mabioawHA8HnHPnWCEwddpceLlunQ=}</password>
</server>
<server>
	<!-- Password-only throws IndexOutOfBoundsException -->
	<id>github</id>
	<password>656044bd7622c1981903n28492niban83a49224</password>
</server>
<server>
	<!-- Passphrase-only throws IndexOutOfBoundsException -->
	<id>gpg.passphrase</id>
	<passphrase>{pRfzVmCm7joHKeWh1y4p3c5ama2njfdITbrmhURqcwPMQij/gK5ue6e80uMqK4N}</passphrase>
</server>

Here is the stacktrace when field is missing:

Exception in thread "main" org.sonatype.plexus.components.cipher.PlexusCipherException: java.lang.ArrayIndexOutOfBoundsException
	at org.sonatype.plexus.components.cipher.PBECipher.decrypt64(PBECipher.java:193)
	at org.sonatype.plexus.components.cipher.DefaultPlexusCipher.decrypt(DefaultPlexusCipher.java:72)
	at org.sonatype.plexus.components.cipher.DefaultPlexusCipher.decryptDecorated(DefaultPlexusCipher.java:89)
	at org.github.jelmerk.maven.settings.Decorder.decodePassword(Decorder.java:66)
	at org.github.jelmerk.maven.settings.Decorder.printPasswords(Decorder.java:107)
	at org.github.jelmerk.maven.settings.Decorder.main(Decorder.java:61)