* If the credential provided is a PasswordCredential, userid and password * are extracted and set explcitely * * @param isPublic * public or private credential * @param newUser * the JS user object reference * @param credential * the credential object */ private void addJSPrincipalCredentials(boolean isPublic, JSPrincipal newPrincipal, Credential credential) { if (credential == null) return; if (credential instanceof PasswordCredential) { PasswordCredential pw = (PasswordCredential) credential; char [] pwdChars = (pw.getPassword() != null ? pw.getPassword().toCharArray() : null); newPrincipal.setCredential(pw.getUserName(), pwdChars, pw.getExpirationDate(), pw.isEnabled(), pw.isExpired(), pw.isUpdateRequired()); return; } else if (isPublic) newPrincipal.addPublicCredential(credential); else newPrincipal.addPrivateCredential(credential); } private JSPrincipal createJSPrincipal(JetspeedPrincipal principal) throws SecurityException { JSPrincipal _jsPrincipal = new JSPrincipal(); _jsPrincipal.setPrincipal(principal); _jsPrincipal.setType(principal.getType().getName()); _jsPrincipal.setName(principal.getName()); _jsPrincipal.setMapped(principal.isMapped()); _jsPrincipal.setEnabled(principal.isEnabled()); _jsPrincipal.setReadonly(principal.isReadOnly()); _jsPrincipal.setRemovable(principal.isRemovable()); _jsPrincipal.setExtendable(principal.isExtendable()); if (JetspeedPrincipalType.USER.equals(principal.getType().getName())) { Credential credential = userManager.getPasswordCredential((User) principal); Subject subject = userManager.getSubject((User) principal); if (credential != null) { addJSPrincipalCredentials(true, _jsPrincipal, credential); } for (Object o : subject.getPublicCredentials()) { credential = (Credential)o; addJSPrincipalCredentials(true, _jsPrincipal, credential); } for (Object o : subject.getPrivateCredentials()) { credential = (Credential)o; addJSPrincipalCredentials(false, _jsPrincipal, credential); } } _jsPrincipal.setSecurityAttributes(principal.getSecurityAttributes().getAttributeMap()); return _jsPrincipal; } }