Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.SecurityAttribute


    }

    private String getUserAttribute(Map<String, SecurityAttribute> map, String name, String defaultValue)
    {
        String value = defaultValue;
        SecurityAttribute sa = map.get(name);
        if (sa != null)
        {
            value = sa.getStringValue();
            if (value == null)
                value = defaultValue;
        }
        return value;
    }
View Full Code Here


                protected void populateItem(ListItem item)
                {
                    final Map<String, SecurityAttribute> attributes = (Map<String, SecurityAttribute>) item
                            .getModelObject();
                    final SecurityAttribute attrib = attributes.get("value");
                    item.add(new TextField("name", new Model(attrib.getName()))
                    {

                        @Override
                        public boolean isEnabled()
                        {
                            return !attrib.isReadOnly();
                        }
                    });
                    item.add(new TextField("value", new PropertyModel<String>(attrib,"stringValue"))
                    {

                        @Override
                        public boolean isEnabled()
                        {
                            return !attrib.isReadOnly();
                        }
                    });
                    if (!attrib.isReadOnly())
                    {
                        Link deleteLink = new Link("link", item.getModel())
                        {

                            @Override
                            public void onClick()
                            {
                                try
                                {
                                    getPrincipal().getSecurityAttributes()
                                            .removeAttribute(attrib.getName());
                                    getManager()
                                            .updatePrincipal(getPrincipal());
                                }
                                catch (SecurityException e)
                                {
View Full Code Here

        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);
View Full Code Here

                if (attr == null)
                {
                    if (!syncAll)
                    {
                        // if principal has attr: remove it
                        SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName());
                        if (principalAttr != null)
                        {
                            if (logger.isDebugEnabled())
                            {
                                logger.debug("Removing attribute "+principalAttr.getName()+" for principal "+principal.getName()+".");
                            }
                            principalAttrs.removeAttribute(principalAttr.getName());
                            updated = true;
                        }
                    }
                }
                else if (syncAll)
                {
                    SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName(), true);
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("Adding attribute "+principalAttr.getName()+" for principal "+principal.getName()+". Value: "+attr.getValue());
                    }
                    principalAttr.setStringValue(attr.getValue());
                    updated = true;
                }
                else
                {
                    SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName(), true);
                    if (!StringUtils.equals(principalAttr.getStringValue(), attr.getValue()))
                    {
                        if (logger.isDebugEnabled())
                        {
                            logger.debug("Updating attribute "+principalAttr.getName()+" for principal "+principal.getName()+". Old value: "+(principalAttr.getStringValue())+" new value: "+attr.getValue());
                        }
                        principalAttr.setStringValue(attr.getValue());
                        updated = true;
                    }
                }
            }
        }
View Full Code Here

                protected void populateItem(ListItem item)
                {
                    final Map<String, SecurityAttribute> attributes = (Map<String, SecurityAttribute>) item
                            .getModelObject();
                    final SecurityAttribute attrib = attributes.get("value");
                    item.add(new TextField("name", new Model(attrib.getName()))
                    {

                        @Override
                        public boolean isEnabled()
                        {
                            return !attrib.isReadOnly();
                        }
                    });
                    item.add(new TextField("value", new PropertyModel<String>(attrib,"stringValue"))
                    {

                        @Override
                        public boolean isEnabled()
                        {
                            return !attrib.isReadOnly();
                        }
                    });
                    if (!attrib.isReadOnly())
                    {
                        Link deleteLink = new Link("link", item.getModel())
                        {

                            @Override
                            public void onClick()
                            {
                                try
                                {
                                    getPrincipal().getSecurityAttributes()
                                            .removeAttribute(attrib.getName());
                                    getManager()
                                            .updatePrincipal(getPrincipal());
                                }
                                catch (SecurityException e)
                                {
View Full Code Here

                protected void populateItem(ListItem item)
                {
                    final Map<String, SecurityAttribute> attributes = (Map<String, SecurityAttribute>) item
                            .getModelObject();
                    final SecurityAttribute attrib = attributes.get("value");
                    item.add(new TextField("name", new Model(attrib.getName()))
                    {

                        @Override
                        public boolean isEnabled()
                        {
                            return !attrib.isReadOnly();
                        }
                    });
                    item.add(new TextField("value", new PropertyModel<String>(attrib,"stringValue"))
                    {

                        @Override
                        public boolean isEnabled()
                        {
                            return !attrib.isReadOnly();
                        }
                    });
                    if (!attrib.isReadOnly())
                    {
                        Link deleteLink = new Link("link", item.getModel())
                        {

                            @Override
                            public void onClick()
                            {
                                try
                                {
                                    getPrincipal().getSecurityAttributes()
                                            .removeAttribute(attrib.getName());
                                    getManager()
                                            .updatePrincipal(getPrincipal());
                                }
                                catch (SecurityException e)
                                {
View Full Code Here

                    {
                        if (!userMgr.getAnonymousUser().equals(userPrincipal.getName())
                                && userMgr.userExists(userPrincipal.getName()))
                        {
                            User user = userMgr.getUser(userPrincipal.getName());
                            SecurityAttribute attrib = user.getSecurityAttributes().getAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
                            if (attrib != null)
                            {
                                String localeString = attrib.getStringValue();
                                if (localeString != null)
                                {
                                    locale = JetspeedLocale.convertStringToLocale(localeString);
                                }
                            }
View Full Code Here

        {
            throw new ProfilerException("Cannot retrieve user for " + userPrincipal.getName());
        }
       
        SecurityAttributes secAttrs = user.getSecurityAttributes();
        SecurityAttribute secAtttr = secAttrs.getAttribute(PortalReservedParameters.USER_HOMEPAGE_REFRESH_FLAG);
       
        if (secAtttr != null && Boolean.parseBoolean(secAtttr.getStringValue()))
        {
            try
            {
                String templateFolder = (String) request.getAttribute(PortalReservedParameters.USER_HOMEPAGE_TEMPLATE_PATH);
               
                if (templateFolder == null)
                {
                    SecurityAttribute secAttrTemplatePath = secAttrs.getAttribute(PortalReservedParameters.USER_HOMEPAGE_TEMPLATE_PATH);
                   
                    if (secAttrTemplatePath != null)
                    {
                        templateFolder = secAttrTemplatePath.getStringValue();
                       
                        if (templateFolder != null && "".equals(templateFolder.trim()))
                        {
                            templateFolder = null;
                        }
View Full Code Here

                    logger.debug("Updating principal "+updatedPrincipal.getName()+" of type "+updatedPrincipal.getType().getName()+" ...");
                }
                SecurityAttributes principalAttrs = updatedPrincipal.getSecurityAttributes();
                for (Map.Entry<String, Attribute> entityAttrEntry : mappedEntityAttrs.entrySet())
                {
                    SecurityAttribute principalAttr = principalAttrs.getAttribute(entityAttrEntry.getKey());
                    Attribute entityAttr = entityAttrEntry.getValue();
                    if (principalAttr != null)
                    {
                        if (entityAttr.getDefinition().isMultiValue())
                        {
                            // TODO : multi-valued Principal attrs are not yet
                            // supported
                        }
                        else
                        {
                            if (!StringUtils.equals(principalAttr.getStringValue(), entityAttr.getValue()))
                            {
                                attrsToBeUpdated.add(entityAttr);
                            }
                        }
                    }
                    else
                    {
                        attrsToBeUpdated.add(entityAttr);
                    }
                }
            }
            SecurityAttributes principalAttrs = updatedPrincipal.getSecurityAttributes();
            Map<String, SecurityAttributeType> securityAttrTypes = principalAttrs.getSecurityAttributeTypes().getAttributeTypeMap();
            // Step 1. update principal's attributes
            for (Attribute addedEntityAttr : attrsToBeUpdated)
            {
                if (!addedEntityAttr.getDefinition().isMultiValue())
                {
                    SecurityAttribute principalAttr = null;
                    try
                    {
                        SecurityAttributeType securityAttrType = securityAttrTypes.get(addedEntityAttr.getMappedName());
                        if (securityAttrType != null)
                        {
                            principalAttr = principalAttrs.getAttribute(addedEntityAttr.getMappedName(), true);
                        }
                        if (principalAttr != null)
                            principalAttr.setStringValue(addedEntityAttr.getValue());
                        if (logger.isDebugEnabled()){
                            logger.debug("Marked attribute "+principalAttr.getName()+" as updated for principal "+updatedPrincipal.getName()+". New value: "+principalAttr.getStringValue());
                        }
                    }
                    catch (SecurityException e)
                    {
                        if (logger.isErrorEnabled())
View Full Code Here

   
    public void setSecurityAttributes(Map<String, SecurityAttribute> sa)
    {
        for (Map.Entry<String, SecurityAttribute> e : sa.entrySet())
        {
            SecurityAttribute attrib = e.getValue();
            JSNVPElement element = new JSNVPElement(attrib.getName(), attrib.getStringValue());
            element.setReadOnly(attrib.isReadOnly());
            element.setAttribute("datatype",attrib.getDataType().name());
            element.setAttribute("registered",Boolean.toString(attrib.isRegistered()));
            element.setAttribute("required",Boolean.toString(attrib.isRequired()));
            element.setAttribute("category",attrib.getCategory());
            secAttrs.add(element);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.SecurityAttribute

Copyright © 2018 www.massapicom. 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.