Examples of JetspeedPrincipalManager


Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

        for (Map.Entry<String, JetspeedPrincipalType> entry : this.principalManagerProvider.getPrincipalTypeMap().entrySet())
        {
            String typeName = entry.getKey();
           
            JetspeedPrincipalType type = this.principalManagerProvider.getPrincipalType(typeName);
            JetspeedPrincipalManager principalManager = this.principalManagerProvider.getManager(type);
           
            for (JetspeedPrincipal principal : principalManager.getPrincipals(""))
            {
                try
                {
                    JSPrincipal _tempPrincipal = createJSPrincipal(principal);
                    refs.getPrincipalMap(typeName).put(_tempPrincipal.getName(), _tempPrincipal);
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

    private void exportJetspeedPrincipalAssociations(ExportRefs refs, JSSnapshot snapshot, Map settings, Logger log) throws SecurityException, SerializerException
    {
        Map<String, JetspeedPrincipalType> principalTypes = this.principalManagerProvider.getPrincipalTypeMap();
        Map<String, JetspeedPrincipalType> copiedPrincipalTypes = new HashMap<String, JetspeedPrincipalType>(principalTypes);
        JetspeedPrincipalManager principalManager = null;
        JetspeedPrincipalManager otherPrincipalManager = null;
       
        for (String principalTypeName : principalTypes.keySet())
        {
            principalManager = this.principalManagerProvider.getManager(this.principalManagerProvider.getPrincipalType(principalTypeName));
           
            for (JetspeedPrincipal principal : principalManager.getPrincipals(""))
            {
                for (JetspeedPrincipalAssociationType assocType : principalManager.getAssociationTypes())
                {
                    for (String otherPrincipalTypeName : copiedPrincipalTypes.keySet())
                    {
                        otherPrincipalManager = this.principalManagerProvider.getManager(this.principalManagerProvider.getPrincipalType(otherPrincipalTypeName));
                       
                        for (JetspeedPrincipal toPrincipal : otherPrincipalManager.getAssociatedFrom(principal.getName(), principal.getType(), assocType.getAssociationName()))
                        {
                            JSPrincipalAssociation jsAssoc = createJSPrincipalAssociation(assocType, principal, toPrincipal);
                            snapshot.addPrincipalAssociation(jsAssoc);
                        }
                    }
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

    }
   
    protected JetspeedPrincipal synchronizeEntity(Entity entity, Set<JetspeedPrincipalAssociationReference> toAssociations) throws SecurityException
    {
        JetspeedPrincipal principal = getJetspeedPrincipal(entity.getType(), entity.getId());
        JetspeedPrincipalManager principalManager = principalManagerProvider.getManager(principalManagerProvider.getPrincipalType(entity.getType()));

        boolean syncAll = false;
       
        if (principal == null)
        {
            // principal does not exist yet, create a new one using the principal manager
            principal = principalManager.newPrincipal(entity.getId(), true);
            principalManager.addPrincipal(principal, toAssociations);
            syncAll = true;
        }
        else if (!principal.isMapped())
        {
            feedbackLogger.warn("Found {} principal: {} is not mapped therefore not synchronized!", principal.getType().getName(),principal.getName());
            return null;
        }
        else
        {
            // sync relations
            for (final SecurityEntityRelationType relationType : securityEntityManager.getSupportedEntityRelationTypes(entity.getType()))
            {
                if (relationType.getFromEntityType().equals(entity.getType()))
                {
                    List<? extends JetspeedPrincipal> associatedFrom = principalManager.getAssociatedFrom(principal.getName(), principal.getType(), relationType.getRelationType());
                    for (JetspeedPrincipal p : associatedFrom)
                    {
                        if (toAssociations.isEmpty() ||
                                        !toAssociations.remove(new JetspeedPrincipalAssociationReference(JetspeedPrincipalAssociationReference.Type.TO, p, relationType.getRelationType())))
                        {
                            principalManager.removeAssociation(principal, p, relationType.getRelationType());
                        }
                    }
                }
            }
            for (JetspeedPrincipalAssociationReference ref : toAssociations)
            {
                principalManager.addAssociation(principal, ref.ref, ref.associationName);
            }
        }
        boolean updated = false;       
        SecurityAttributes principalAttrs = principal.getSecurityAttributes();
        for (AttributeDef attrDef : entity.getAttributeDefinitions())
        {
            if (attrDef.isMapped() && !attrDef.isMultiValue())
            {
                Attribute attr = entity.getAttribute(attrDef.getName());
                if (attr == null)
                {
                    if (!syncAll)
                    {
                        // if principal has attr: remove it
                        SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName());
                        if (principalAttr != null)
                        {
                            feedbackLogger.debug("Removing attribute {} for principal {}", principalAttr.getName(), principal.getName());
                            principalAttrs.removeAttribute(principalAttr.getName());
                            updated = true;
                        }
                    }
                }
                else if (syncAll)
                {
                    SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName(), true);
                    if (feedbackLogger.isDebugEnabled())
                    {
                        feedbackLogger.debug("Adding attribute {} for principal {}. Value: {}",
                                             new String[] {principalAttr.getName(), principal.getName(), attr.getValue()});
                    }
                    principalAttr.setStringValue(attr.getValue());
                    updated = true;
                }
                else
                {
                    SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName(), true);
                    if (!StringUtils.equals(principalAttr.getStringValue(), attr.getValue()))
                    {
                        if (feedbackLogger.isDebugEnabled())
                        {
                            feedbackLogger.debug("Attribute attribute {} for principal {}. Old value: {}, new value: {}",
                                                 new String[] {principalAttr.getName(), principal.getName(), (principalAttr.getStringValue()), attr.getValue()});
                        }
                        principalAttr.setStringValue(attr.getValue());
                        updated = true;
                    }
                }
            }
        }
        if (updated)
        {
            feedbackLogger.debug("Storing attribute changes for principal {}", principal.getName());
            principalManager.updatePrincipal(principal);
        }
        feedbackLogger.debug("Synchronized entity {} id: {} mapped attributes", entity.getType(), entity.getId());
        return principal;
    }
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

        return principal;
    }

    protected JetspeedPrincipal getJetspeedPrincipal(String principalType, String principalName) throws SecurityException
    {
        JetspeedPrincipalManager principalManager = principalManagerProvider.getManager(principalManagerProvider.getPrincipalType(principalType));
        if (principalManager != null)
        {
            return principalManager.getPrincipal(principalName);
        }
        throw new SecurityException(SecurityException.UNKNOWN_PRINCIPAL_TYPE.create(principalType));
    }
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

                for (JetspeedPrincipalType type : principalManagerProvider.getPrincipalTypeMap().values())
                {
                    String typeName = type.getName();
                    userType = JetspeedPrincipalType.USER.equals(typeName);
                   
                    JetspeedPrincipalManager principalManager = principalManagerProvider.getManager(type);
                   
                    for (JetspeedPrincipal principal : principalManager.getPrincipals(""))
                    {
                        if (!(userType && anonymousUser.equals(principal.getName())))
                        {
                            principalManager.removePrincipal(principal);
                        }
                    }
                }
            }
            catch (Exception e)
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

        }
        log.debug("recreateOldUsers - done");
       
        log.debug("processing jetspeed principals");
       
        JetspeedPrincipalManager principalManager = null;
       
        for (JSPrincipal jsPrincipal : snapshot.getPrincipals())
        {
            String typeName = jsPrincipal.getType();
            if (JetspeedPrincipalType.USER.equals(typeName))
            {
                recreateUserPrincipal(refs, snapshot, settings, log, jsPrincipal, passwordEncoding);
            }
            else
            {
                String name = jsPrincipal.getName();
               
                try
                {
                    JetspeedPrincipalType type = this.principalManagerProvider.getPrincipalType(typeName);
                    principalManager = this.principalManagerProvider.getManager(type);
                    JetspeedPrincipal principal = null;
                   
                    if (!(principalManager.principalExists(name)))
                    {
                        principal = principalManager.newPrincipal(name, jsPrincipal.isMapped());
                        JSSecurityAttributes jsSecAttrs = jsPrincipal.getSecurityAttributes();
                        if (jsSecAttrs != null)
                        {
                            for (JSNVPElement elem : jsSecAttrs.getValues())
                            {
                                principal.getSecurityAttributes().getAttribute(elem.getKey(), true).setStringValue(elem.getValue());
                            }
                        }
                        principalManager.addPrincipal(principal, null);
                    }
                   
                    principal = principalManager.getPrincipal(name);
                    refs.getPrincipalMap(typeName).put(name, principal);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

            throws SerializerException
    {
        log.debug("recreateJetspeedPrincipalAssociations");
       
        Map<String, JetspeedPrincipalType> principalTypes = this.principalManagerProvider.getPrincipalTypeMap();
        JetspeedPrincipalManager principalManager = null;
        JetspeedPrincipalManager fromPrincipalManager = null;
        JetspeedPrincipal from = null;
        JetspeedPrincipal to = null;
       
        try
        {
            for (JSPrincipalAssociation jsAssoc : snapshot.getPrincipalAssociations())
            {
                principalManager = this.principalManagerProvider.getManager(principalTypes.get(jsAssoc.getToType()));
                to = principalManager.getPrincipal(jsAssoc.getToName());
                fromPrincipalManager = this.principalManagerProvider.getManager(principalTypes.get(jsAssoc.getFromType()));
                from = fromPrincipalManager.getPrincipal(jsAssoc.getFromName());
                principalManager.addAssociation(from, to, jsAssoc.getName());
            }
        }
        catch (Exception e)
        {
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

        for (Map.Entry<String, JetspeedPrincipalType> entry : this.principalManagerProvider.getPrincipalTypeMap().entrySet())
        {
            String typeName = entry.getKey();
           
            JetspeedPrincipalType type = this.principalManagerProvider.getPrincipalType(typeName);
            JetspeedPrincipalManager principalManager = this.principalManagerProvider.getManager(type);
           
            for (JetspeedPrincipal principal : principalManager.getPrincipals(""))
            {
                try
                {
                    JSPrincipal _tempPrincipal = createJSPrincipal(principal);
                    refs.getPrincipalMap(typeName).put(_tempPrincipal.getName(), _tempPrincipal);
View Full Code Here

Examples of org.apache.jetspeed.security.JetspeedPrincipalManager

    private void exportJetspeedPrincipalAssociations(ExportRefs refs, JSSnapshot snapshot, Map settings, Logger log) throws SecurityException, SerializerException
    {
        Map<String, JetspeedPrincipalType> principalTypes = this.principalManagerProvider.getPrincipalTypeMap();
        Map<String, JetspeedPrincipalType> copiedPrincipalTypes = new HashMap<String, JetspeedPrincipalType>(principalTypes);
        JetspeedPrincipalManager principalManager = null;
        JetspeedPrincipalManager otherPrincipalManager = null;
       
        for (String principalTypeName : principalTypes.keySet())
        {
            principalManager = this.principalManagerProvider.getManager(this.principalManagerProvider.getPrincipalType(principalTypeName));
           
            for (JetspeedPrincipal principal : principalManager.getPrincipals(""))
            {
                Set<String> associationNames = new HashSet<String>();
                for (JetspeedPrincipalAssociationType assocType : principalManager.getAssociationTypes())
                {
                    String associationName = assocType.getAssociationName();
                    if (associationNames.add(associationName))
                    {
                        for (String otherPrincipalTypeName : copiedPrincipalTypes.keySet())
                        {
                            otherPrincipalManager = this.principalManagerProvider.getManager(this.principalManagerProvider.getPrincipalType(otherPrincipalTypeName));
                           
                            for (JetspeedPrincipal toPrincipal : otherPrincipalManager.getAssociatedFrom(principal.getName(), principal.getType(), associationName))
                            {
                                JSPrincipalAssociation jsAssoc = createJSPrincipalAssociation(associationName, principal, toPrincipal);
                                snapshot.addPrincipalAssociation(jsAssoc);
                            }
                        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.