public Object getEncodedValue() { if (value != null) { return passwordEncoder.encodeCredential(userName, value); } return null; } }
public IdentitySearchCriteria sort(SortOrder order) throws UnsupportedCriterium { sorted = true; if (order.equals(SortOrder.ASCENDING)) { ascending = true; } else { ascending = false; } return this; }
public IdentitySession getIdentitySession() throws Exception { return identitySessionFactory.getCurrentIdentitySession(realmName); }
/** * Removes a role from the authenticated user * * @param role The name of the role to remove */ public void removeRole(String roleType, String group, String groupType) { for (Role role : activeRoles) { if (role.getRoleType().getName().equals(roleType) && role.getGroup().getName().equals(group) && role.getGroup().getGroupType().equals(groupType)) { activeRoles.remove(role); return; } } }
protected IdentityObjectRelationship createIdentityObjectRelationship(Role role) { return new SimpleIdentityObjectRelationship( createIdentityObject(role.getGroup()), createIdentityObject(role.getUser()), role.getRoleType().getName(), ROLE ); }
public boolean inGroup(String name, String groupType) { for (Group group : activeGroups) { if (group.getName().equals(name) && group.getGroupType().equals(groupType)) return true; } return false; }
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); }
public void recoverFromIDMError(Exception e) { try { // We need to restart Hibernate transaction if it's available. First rollback old one and then start new one Transaction idmTransaction = idmService_.getIdentitySession().getTransaction(); if (idmTransaction.isActive()) { idmTransaction.rollback(); idmTransaction.start(); log.info("IDM error recovery finished. Old transaction has been rolled-back and new transaction has been started"); } } catch (Exception e1) { log.warn("Error during recovery of old error", e1); } }
public void removeRoleType(RoleType roleType) throws IdentityException { checkNotNullArgument(roleType, "RoleType"); removeRoleType(roleType.getName()); }
public final org.picketlink.idm.api.Group getJBIDMGroup(String groupId) throws Exception { String[] ids = groupId.split("/"); String name = ids[ids.length - 1]; String parentId = null; if (groupId.contains("/")) { parentId = groupId.substring(0, groupId.lastIndexOf("/")); } String plGroupName = configuration.getPLIDMGroupName(name); return idmService_.getIdentitySession().getPersistenceManager() .findGroup(plGroupName, getConfiguration().getGroupType(parentId)); }
public void startTransaction() throws Exception { if (!getIdentitySession().getTransaction().isActive()) { getIdentitySession().beginTransaction(); } }
public void endTransaction() throws Exception { if (getIdentitySession().getTransaction().isActive()) { getIdentitySession().getTransaction().commit(); } }
public void recoverFromIDMError(Exception e) { log.error(e); try { // We need to restart Hibernate transaction if it's available. First rollback old one and then start new one Transaction idmTransaction = getIdentitySession().getTransaction(); if (idmTransaction.isActive()) { idmTransaction.rollback(); log.info("IDM error recovery finished. Old transaction has been rolled-back"); } } catch (Exception e1) { log.warn("Error during recovery of old error", e1); } }
protected SecureRandom getSecureRandomInstance() throws NoSuchAlgorithmException { if (registeredSecureRandomProvider != null) { return registeredSecureRandomProvider.getSecureRandom(); } else { return SecureRandom.getInstance(secureRandomAlgorithm); } } }
public boolean hasRole(String roleType, String group, String groupType) { if (!securityEnabled) return true; if (systemOp != null && Boolean.TRUE.equals(systemOp.get())) return true; tryLogin(); for (Role role : activeRoles) { if (role.getRoleType().getName().equals(roleType) && role.getGroup().getName().equals(group) && role.getGroup().getGroupType().equals(groupType)) { return true; } } return false; }
public void removeRole(Role role) throws IdentityException { checkNotNullArgument(role, "Role"); preRemove(role); getRepository().removeRelationship(getInvocationContext(), createIdentityObject(role.getGroup()), createIdentityObject(role.getUser()), ROLE, role.getRoleType().getName()); if (cache != null) { cache.invalidateAllQueries(cacheNS); cache.invalidateAllSearches(cacheNS); cache.removeRole(cacheNS, role); } postRemove(role); }
public void removeRoleType(String ns, RoleType roleType) { removeNode(getFqn(ns, NODE_ROLE_TYPES, roleType.getName())); }
@Override public void afterBegin() { try { // We need this as from Hibernate4 and with JTATransactionFactory, there is need to separately start IDM (Hibernate) // transaction as well even if JTA transaction is started if (!idmService.getIdentitySession().getTransaction().isActive()) { idmService.getIdentitySession().beginTransaction(); } } catch (Exception e) { throw new RuntimeException(e); } } }
public IdentitySession getIdentitySession() throws Exception { return getIdentitySessionFactory().getCurrentIdentitySession(realmName); }