public void writeExternal(Element element) throws WriteExternalException { Element passwords = new Element(PASSWORDS); for (final String cvsRoot : myCvsRootToStoringPasswordMap.keySet()) { Element password = new Element(PASSWORD); password.setAttribute(CVSROOT_ATTR, cvsRoot); password.setAttribute( PASSWORD_ATTR, PServerPasswordScrambler.getInstance() .scramble(myCvsRootToStoringPasswordMap.get(cvsRoot))); passwords.addContent(password); } element.addContent(passwords); passwords = new Element(PPKPASSWORDS); for (final String cvsRoot : myCvsRootToStoringPPKPasswordMap.keySet()) { Element password = new Element(PASSWORD); password.setAttribute(CVSROOT_ATTR, cvsRoot); password.setAttribute( PASSWORD_ATTR, PServerPasswordScrambler.getInstance() .scramble(myCvsRootToStoringPPKPasswordMap.get(cvsRoot))); passwords.addContent(password); } element.addContent(passwords); }
public void readExternal(Element element) throws InvalidDataException { Element passwords = element.getChild(PASSWORDS); if (passwords != null) { for (Iterator eachPasswordElement = passwords.getChildren(PASSWORD).iterator(); eachPasswordElement.hasNext(); ) { Element passElement = (Element) eachPasswordElement.next(); String cvsRoot = passElement.getAttributeValue(CVSROOT_ATTR); String password = passElement.getAttributeValue(PASSWORD_ATTR); if ((cvsRoot != null) && (password != null)) myCvsRootToStoringPasswordMap.put( cvsRoot, PServerPasswordScrambler.getInstance().unscramble(password)); } } passwords = element.getChild(PPKPASSWORDS); if (passwords != null) { for (Iterator eachPasswordElement = passwords.getChildren(PASSWORD).iterator(); eachPasswordElement.hasNext(); ) { Element passElement = (Element) eachPasswordElement.next(); String cvsRoot = passElement.getAttributeValue(CVSROOT_ATTR); String password = passElement.getAttributeValue(PASSWORD_ATTR); if ((cvsRoot != null) && (password != null)) myCvsRootToStoringPPKPasswordMap.put( cvsRoot, PServerPasswordScrambler.getInstance().unscramble(password)); } } }
private String getPServerConnectionPassword(String cvsRoot, CvsRootParser root) { String[] userAndPassword = root.USER_NAME.split(":"); if (userAndPassword.length > 1) { return PServerPasswordScrambler.getInstance().scramble(userAndPassword[1]); } else { return myBuilder.getPServerPassword(cvsRoot); } }