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(); } }
protected String resolvePrincipals(RequestContext context, RuleCriterion criterion, Subject subject, String jptName) { StringBuffer result = new StringBuffer(); int count = 0; for (JetspeedPrincipal principal : SubjectHelper.getPrincipals(subject, jptName)) { if (count > 0) { result.append(VALUE_DELIMITER); } result.append(principal.getName()); count++; } if (count == 0) { return null; } return result.toString(); }
protected String combinePrincipals(RequestContext context, RuleCriterion criterion, Subject subject, String jptName) { StringBuffer result = new StringBuffer(); int count = 0; for (JetspeedPrincipal principal : SubjectHelper.getPrincipals(subject, jptName)) { if (count > 0) { result.append(COMBO_DELIMITER); } result.append(principal.getName()); count++; } if (count == 0) { return null; } return result.toString(); }
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 void removePrincipal(JetspeedPrincipal principal) throws SecurityException { validatePrincipal(principal); if (principal.getName().equals(getAnonymousUser())) { throw new SecurityException(SecurityException.ANONYMOUS_USER_PROTECTED.create(principal.getName())); } super.removePrincipal(principal); }
public void addAssociation(SSOUser user, JetspeedPrincipal principal) throws SSOException { try{ ssoUserManagerSPI.addSSOUserToPrincipal(user, principal); } catch (SecurityException secex){ throw new SSOException("Unable to associate principal "+principal.getName() + " with SSO user "+user.getName()); } }
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; }
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 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 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); }
public void removeAssociation(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.isRemoveAllowed()) { ldapEntityManager.removeRelation(from.getName(), to.getName(), relationType); } } databaseStorageManager.removeAssociation(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); } }
@SuppressWarnings("unchecked") public void beforeRemoveTo(JetspeedPrincipal to) throws SecurityException { if (associationType.isDependent()) { List<JetspeedPrincipal> fromList = (List<JetspeedPrincipal>)getManagerTo().getAssociatedTo(to.getName(), to.getType(), associationType.getAssociationName()); for (JetspeedPrincipal from : fromList) { getManagerFrom().removePrincipal(from); } } else if (associationType.isRequired() && !isSynchronizing()) { if (!getManagerTo().getAssociatedTo(to.getName(), to.getType(), associationType.getAssociationName()).isEmpty()) { throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(to.getType().getName(), to.getName(), associationType.getFromPrincipalType().getName(), associationType.getAssociationName())); } } }
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); } }
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); }
JetspeedPrincipal pfrom = jpah.getManagerFrom().getPrincipal(from.getName()); if (pfrom == null) throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(from.getType().getName(), from.getName())); JetspeedPrincipal pto = jpah.getManagerTo().getPrincipal(to.getName()); if (pto == null) throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(to.getType().getName(), to.getName()));
if (associationType.isSingular() && !getManagerFrom().getAssociatedFrom(from.getName(), from.getType(), associationType.getAssociationName()).isEmpty()) throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_SINGULAR_MIXED.createScoped(from.getType().getName(),associationType.getAssociationName(), from.getName(), to.getType().getName())); throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_SINGULAR.createScoped(from.getType().getName(),associationType.getAssociationName(), from.getName(), from.getType().getName())); if (associationType.isDominant() && !getManagerTo().getAssociatedTo(to.getName(), to.getType(), associationType.getAssociationName()).isEmpty()) throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_DOMINANT_MIXED.createScoped(to.getType().getName(),associationType.getAssociationName(), to.getName(), from.getType().getName())); throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_DOMINANT.createScoped(to.getType().getName(),associationType.getAssociationName(), to.getName(), to.getType().getName()));
public void revokeAllPermissions(JetspeedPrincipal principal) throws SecurityException { Long principalId = null; Criteria criteria = new Criteria(); if (principal.isTransient() || principal.getId() == null) { Long securityDomain = ((principal.getDomainId() != null) ? principal.getDomainId() : getDefaultSecurityDomainId()); principalId = getPrincipalId(principal.getName(), principal.getType().getName(), securityDomain); } else { principalId = principal.getId(); } criteria.addEqualTo("principalId", principalId); Query query = QueryFactory.newQuery(JetspeedPrincipalPermission.class,criteria); try { getPersistenceBrokerTemplate().deleteByQuery(query); // evict from principal cache to notify jspmCache.evictPrincipal(principalId); } catch (Exception pbe) { KeyedMessage msg = SecurityException.UNEXPECTED.create("JetspeedSecurityPersistenceManager", "revokeAllPermissions", pbe.getMessage()); logger.error(msg, pbe); throw new SecurityException(msg, pbe); } }