public boolean principalExists(JetspeedPrincipal principal) if (principal.getId() == null) if (principal.getDomainId() != null) return principalExists(principal.getName(), principal.getType(), principal.getDomainId()); return principalExists(principal.getName(), principal.getType()); criteria.addEqualTo("id", principal.getId()); criteria.addEqualTo("type", principal.getType().getName()); criteria.addEqualTo("domainId", principal.getDomainId()); principalExists = (getPersistenceBrokerTemplate().getCount(query) == 1); jspmCache.putPrincipalQuery(cacheKey, (principalExists ? principal.getId() : JSPMCache.ANY_ID), null, principal.getDomainId(), principalExists);
public UserDataTableBean(JetspeedPrincipalResultList resultList) { totalRecords = resultList.getTotalSize(); this.records = new ArrayList<HashMap<String, String>>(); HashMap<String, String> record = null; for (JetspeedPrincipal p : resultList.getResults()) { record = new HashMap<String, String>(); record.put("userName", p.getName()); record.put("firstName", p.getInfoMap().get("user.name.given") == null ? "" : p.getInfoMap().get( "user.name.given")); record.put("lastName", p.getInfoMap().get("user.name.family") == null ? "" : p.getInfoMap().get( "user.name.family")); this.records.add(record); } }
public JetspeedPrincipalAssociationReference(Type type, JetspeedPrincipal ref, String associationName) { this.type = type; this.ref = ref; this.associationName = associationName; if (type == null || ref.getId() == null || ref.getName() == null || associationName == null) { throw new NullPointerException(); } }
private Collection<? extends JetspeedPrincipal> _getSSOUsersForPrincipal(JetspeedPrincipal principal, Long remoteSecurityDomain) throws SecurityException { return domainPrincipalAccess.getAssociatedTo(principal.getName(), getPrincipalType(), principal.getType(), IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME, remoteSecurityDomain, principal.getDomainId()); }
private JSPrincipalAssociation createJSPrincipalAssociation(String associationName, JetspeedPrincipal from, JetspeedPrincipal to) { JSPrincipalAssociation jsAssoc = new JSPrincipalAssociation(); jsAssoc.setName(associationName); jsAssoc.setFromType(from.getType().getName()); jsAssoc.setFromName(from.getName()); jsAssoc.setToType(to.getType().getName()); jsAssoc.setToName(to.getName()); return jsAssoc; }
public void updatePrincipal(JetspeedPrincipal principal) throws SecurityException { if (!principalExists(principal)) { throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(principal.getType().getName(), principal.getName())); } try { getPersistenceBrokerTemplate().store(principal); // evict from and put in cache to notify jspmCache.evictPrincipal(principal.getId()); jspmCache.putPrincipal(principal.getId(), principal); } catch (Exception pbe) { if (pbe instanceof DataIntegrityViolationException) { logger.error(pbe.getMessage(), pbe); throw new SecurityException(SecurityException.PRINCIPAL_UPDATE_FAILURE.createScoped(principal.getType().getName(), principal.getName())); } KeyedMessage msg = SecurityException.UNEXPECTED.create("JetspeedSecurityPersistenceManager", "removePrincipal", pbe.getMessage()); logger.error(msg, pbe); throw new SecurityException(msg, pbe); } }
_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())) _jsPrincipal.setSecurityAttributes(principal.getSecurityAttributes().getAttributeMap());
syncAll = true; else if (!principal.isMapped()) feedbackLogger.warn("Found {} principal: {} is not mapped therefore not synchronized!", principal.getType().getName(),principal.getName()); return null; List<? extends JetspeedPrincipal> associatedFrom = principalManager.getAssociatedFrom(principal.getName(), principal.getType(), relationType.getRelationType()); for (JetspeedPrincipal p : associatedFrom) SecurityAttributes principalAttrs = principal.getSecurityAttributes(); for (AttributeDef attrDef : entity.getAttributeDefinitions()) if (principalAttr != null) feedbackLogger.debug("Removing attribute {} for principal {}", principalAttr.getName(), principal.getName()); principalAttrs.removeAttribute(principalAttr.getName()); updated = true; new String[] {principalAttr.getName(), principal.getName(), attr.getValue()}); new String[] {principalAttr.getName(), principal.getName(), (principalAttr.getStringValue()), attr.getValue()}); feedbackLogger.debug("Storing attribute changes for principal {}", principal.getName()); principalManager.updatePrincipal(principal);
public void updatePrincipal(JetspeedPrincipal principal) throws SecurityException { validatePrincipal(principal); if (principal.isReadOnly() && !isSynchronizing()) { throw new SecurityException(SecurityException.PRINCIPAL_IS_READ_ONLY.createScoped(principal.getType().getName(), principal.getName())); } jpsm.updatePrincipal(principal); notifyUpdatedPrincipal(principal); }
public SecurityAttributeTypes getSecurityAttributeTypes() { return jp.getType().getAttributeTypes(); }
protected void processFound(List<JetspeedPrincipal> found, User user, Set<Long> resolvedIds, Set<Principal> principals, Map<String, UserSubjectPrincipalsResolver> resolvers) { for (int i = found.size() -1; i > -1; i--) { JetspeedPrincipal p = found.get(i); if (!p.isEnabled() || !resolvers.containsKey(p.getType().getName()) || !resolvedIds.add(p.getId())) { found.remove(i); } } for (JetspeedPrincipal p : found) { resolvers.get(p.getType().getName()).processPrincipal(p, user, resolvedIds, principals, resolvers); } }
public Entity createEntity(JetspeedPrincipal principal) { Set<Attribute> ldapAttrValues = new HashSet<Attribute>(); SecurityAttributes sas = principal.getSecurityAttributes(); for (AttributeDef attrDef : searchConfiguration.getEntityAttributeDefinitionsMap().values()) { if (attrDef.isMapped()) { SecurityAttribute sa = sas.getAttribute(attrDef.getMappedName()); if (sa != null) { // currently only single-valued attributes are supported AttributeImpl attr = new AttributeImpl(attrDef); attr.setValue(sa.getStringValue()); ldapAttrValues.add(attr); } } } return internalCreateEntity(principal.getName(), null, ldapAttrValues); }
protected final void validatePrincipal(JetspeedPrincipal principal) { if (!principal.getType().getName().equals(principalType.getName())) { throw new IllegalArgumentException("Principal is not of type "+principalType.getName()); } if (principal.isTransient()) { throw new IllegalArgumentException("Principal is transient"); } }
public Collection<SSOUser> getUsers(JetspeedPrincipal principal) throws SecurityException { Collection<SecurityDomain> allDomains = domainAccess.getDomainsOwnedBy(principal.getDomainId()); Collection<SSOUser> users = new ArrayList<SSOUser>(); for (SecurityDomain domain : allDomains){ users.addAll(getUsers(principal,domain.getDomainId())); } return users; }
principal.getSecurityAttributes().getAttribute(elem.getKey(), true).setStringValue(elem.getValue());
public void addAssociation(JetspeedPrincipal from, JetspeedPrincipal to, String associationName) throws SecurityException { if (!SynchronizationStateAccess.isSynchronizing() && !ldapEntityManager.isReadOnly()) { SecurityEntityRelationType relationType = ldapEntityManager.getSupportedEntityRelationType(associationName, from.getType().getName(), to.getType().getName()); if (relationType != null && relationType.isCreateAllowed()) { ldapEntityManager.addRelation(from.getName(), to.getName(), relationType); } } databaseStorageManager.addAssociation(from, to, associationName); }
public void removePrincipal(JetspeedPrincipal principal) throws SecurityException { if (!principalExists(principal)) { throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(principal.getType().getName(), principal.getName())); } try { getPersistenceBrokerTemplate().delete(principal); // evict from cache to notify jspmCache.evictPrincipal(principal.getId()); } catch (Exception pbe) { if (pbe instanceof DataIntegrityViolationException) { logger.error(pbe.getMessage(), pbe); throw new SecurityException(SecurityException.PRINCIPAL_NOT_REMOVABLE.createScoped(principal.getType().getName(), principal.getName())); } KeyedMessage msg = SecurityException.UNEXPECTED.create("JetspeedSecurityPersistenceManager", "removePrincipal", pbe.getMessage()); logger.error(msg, pbe); throw new SecurityException(msg, pbe); } }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof JetspeedPrincipal) { JetspeedPrincipal other = (JetspeedPrincipal)o; return (getName().equals(other.getName()) && getType().equals(other.getType()) && (((getDomainId() != null) ? getDomainId().longValue() : 0L) == ((other.getDomainId() != null) ? other.getDomainId().longValue() : 0L))); } return false; }