It's all about the answers!

Ask a question

Is there support for password files in the Plain Java Client API?

Nicolas Poisson (1023) | asked Jun 26 '14, 8:51 a.m.

We are running automated builds (Maven) through the Jazz Build Engine, which uses a password file, which is fine for CLI and Ant scripts, however there does not seem to be OOTB support for password files through the RTC Plain Java Client API (4.0.3). Am I stuck having to write a custom LoginHandler that decrypts the password? Or is there an easier way around this?


Accepted answer

permanent link
Kevin Ramer (4.5k8184200) | answered Jun 26 '14, 11:01 a.m.
edited Jun 26 '14, 12:44 p.m.
There is an ObfuscationHelper class in the Plain Java api.  A couple of lines is all you'd need



  props = this.getProperties(path);
  String pw=props.getProperty("password");
  String ctpw=new String(ObfuscationHelper.decrypt(pw.getBytes()));

  teamRepository = login(repositoryID, props.getProperty("userID"),ctpw );

And you'd need some way to do the encrypt (  ObfuscationHelper.encrypt or ObfuscationHelper.encryptString )

Or as the SCM and build tool kits likely use, you can just use the hashed password from one of those and decrypt it as I've shown.
Nicolas Poisson selected this answer as the correct answer

2 other answers

permanent link
sam detweiler (12.5k6195201) | answered Jun 26 '14, 8:54 a.m.
edited Jul 12 '14, 2:10 p.m.
see above,

here is a sample pgm to encryt and decrypt the string..




public class EncodePassword

     * @param args
    public static void main(String[] args)
        // TODO Auto-generated method stub
                String enpw = ObfuscationHelper.encryptString(args[0]);
                // you would use this output in any password file

                // here is how you would decrypt it for use in your application.
                // you could get this string from the commandline, or a file,
                // or a properties file (pw= string)
               String userpw=enpw;  (the encrypted or plain text password)
                   // try to decrypt
                catch(Exception ex)
                    // nothing to do, target variable not overwritten on error
            System.out.println("need password string");


permanent link
Morten Madsen (3053250) | answered Aug 14 '15, 10:55 a.m.
An implementation of a decryption of a password file inside an ANT task extending the AbstractTeamBuildTask from RTC would look like:
if (getPasswordFile() != null)
{"Detected password file. Decrypting password");"password file is [%s]", getPasswordFile().toString()));
	final Properties properties = new Properties();
	final FileInputStream in = new FileInputStream(getPasswordFile());
    for (Object key : properties.keySet())
    {"Key = [%s]", key.toString()));

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.