public void removeProfile(String userName, UserProfile profile) { Map<String, String> profileAttrs = profile.getUserInfoMap(); String[] attrKeys = new String[profileAttrs.keySet().size()]; attrKeys = profileAttrs.keySet().toArray(attrKeys); try { getIdentitySession().getAttributesManager().removeAttributes(userName, attrKeys); } catch (Exception e) { // TODO: handleException("Identity operation error: ", e); } } }
public void setEnabled(String userName, boolean enabled) throws Exception { Attribute[] attrs = new Attribute[] { new SimpleAttribute(UserDAOImpl.USER_ENABLED, String.valueOf(enabled)) }; IdentitySession session = getIdentitySession(); AttributesManager am = session.getAttributesManager(); am.updateAttributes(userName, attrs); }
Map<String, Attribute> presentAttrs = identitySession.getAttributesManager().getAttributes(type);
public void setProfile(String userName, UserProfile profile) { Map<String, String> profileAttrs = profile.getUserInfoMap(); Set<Attribute> attrs = new HashSet<Attribute>(); for (Map.Entry<String, String> entry : profileAttrs.entrySet()) { String attrValue = entry.getValue(); // Treat empty strings as null (needed for compatibility with Oracle as Oracle always treats empty strings as null) if ("".equals(attrValue)) { attrValue = null; } attrs.add(new SimpleAttribute(entry.getKey(), attrValue)); } Attribute[] attrArray = new Attribute[attrs.size()]; attrArray = attrs.toArray(attrArray); try { getIdentitySession().getAttributesManager().updateAttributes(userName, attrArray); } catch (Exception e) { // TODO: handleException("Identity operation error: ", e); } }
Attribute attr = identitySession.getAttributesManager().getAttribute(object, attributeName);
@Override protected String getSalt(String username) { try { AttributesManager am = getIdentitySession().getAttributesManager(); Attribute salt = am.getAttribute(username, PASSWORD_SALT_USER_ATTRIBUTE); // User does not have salt attribute in DB. Let's generate a fresh one and save it to DB. if (salt == null) { SecureRandom pseudoRng = getSecureRandomInstance(); String saltStr = String.valueOf(pseudoRng.nextLong()); am.addAttribute(username, PASSWORD_SALT_USER_ATTRIBUTE, saltStr); log.fine("Salt has been randomly generated for user " + username); return saltStr; } else { return (String)salt.getValue(); } } catch (Exception ie) { throw new RuntimeException(ie); } }
private void enableUser(User u, IdentitySession session) { if (u instanceof UserImpl) { ((UserImpl) u).setEnabled(true); Attribute[] attrs = new Attribute[] { new SimpleAttribute(UserDAOImpl.USER_ENABLED, String.valueOf(true)) }; AttributesManager am = session.getAttributesManager(); try { am.updateAttributes(u.getUserName(), attrs); } catch (Exception e) { LOG.error(e); } } } }
attrs = getIdentitySession().getAttributesManager().getAttributes(userName); } catch (Exception e) {
public void populateUser(User user, IdentitySession session) { orgService.flush(); AttributesManager am = session.getAttributesManager();
orgService.flush(); attrs = getIdentitySession().getAttributesManager().getAttributes(jbidGroup); } catch (Exception e) {
public void persistUserInfo(User user, IdentitySession session, boolean isNew) throws Exception { orgService.flush(); AttributesManager am = session.getAttributesManager();
getIdentitySession().getAttributesManager().updateAttributes(jbidGroup, attrs); } catch (Exception e) {
org.picketlink.idm.api.User idmUser = session.getPersistenceManager().findUser(user.getUserName()); authenticated = session.getAttributesManager().validatePassword(idmUser, password); } catch (Exception e) { handleException("Cannot authenticate user: " + username + "; ", e);
@Override public User setEnabled(String userName, boolean enabled, boolean broadcast) throws Exception { if (log.isTraceEnabled()) { Tools.logMethodIn(log, LogLevel.TRACE, "setEnabled", new Object[] { "userName", userName, "enabled", enabled, "broadcast", broadcast }); } orgService.flush(); IdentitySession session = service_.getIdentitySession(); User foundUser = getPopulatedUser(userName, session, UserStatus.ANY); if (foundUser == null || foundUser.isEnabled() == enabled) { return foundUser; } ((UserImpl) foundUser).setEnabled(enabled); if (broadcast) preSetEnabled(foundUser); Attribute[] attrs = new Attribute[] { new SimpleAttribute(USER_ENABLED, String.valueOf(enabled)) }; AttributesManager am = session.getAttributesManager(); try { am.updateAttributes(userName, attrs); } catch (Exception e) { handleException("Cannot update enabled status for user: " + userName + "; ", e); } if (getIntegrationCache() != null) { getIntegrationCache().invalidateAll(); } if (broadcast) postSetEnabled(foundUser); return foundUser; }
public User findUserByUniqueAttribute(String attributeName, String attributeValue, UserStatus userStatus) throws Exception { if (log.isTraceEnabled()) { Tools.logMethodIn(log, LogLevel.TRACE, "findUserByUniqueAttribute", new Object[] { "findUserByUniqueAttribute", attributeName, attributeValue, userStatus }); } IdentitySession session = service_.getIdentitySession(); org.picketlink.idm.api.User plUser = null; try { orgService.flush(); plUser = session.getAttributesManager().findUserByUniqueAttribute(attributeName, attributeValue); } catch (Exception e) { handleException("Cannot find user by unique attribute: attrName=" + attributeName + ", attrValue=" + attributeValue + "; ", e); } User user = null; if (plUser != null) { user = new UserImpl(plUser.getId()); populateUser(user, session); if (!userStatus.matches(user.isEnabled())) { user = null; } } if (log.isTraceEnabled()) { Tools.logMethodOut(log, LogLevel.TRACE, "findUserByUniqueAttribute", user); } return user; }
boolean success = identitySession.getAttributesManager().validateCredentials( u, new Credential[]{credentials.getCredential()});