Package org.opensaml.xacml.ctx

Examples of org.opensaml.xacml.ctx.AttributeType


       
        // Subject
        List<AttributeType> attributes = new ArrayList<AttributeType>();
        AttributeValueType subjectIdAttributeValue =
            RequestComponentBuilder.createAttributeValueType(principal.getName());
        AttributeType subjectIdAttribute =
            RequestComponentBuilder.createAttributeType(
                    XACMLConstants.SUBJECT_ID,
                    XACMLConstants.XS_STRING,
                    issuer,
                    Collections.singletonList(subjectIdAttributeValue)
            );
        attributes.add(subjectIdAttribute);
       
        if (roles != null) {
            List<AttributeValueType> roleAttributes = new ArrayList<AttributeValueType>();
            for (String role : roles) {
                if (role != null) {
                    AttributeValueType subjectRoleAttributeValue =
                        RequestComponentBuilder.createAttributeValueType(role);
                    roleAttributes.add(subjectRoleAttributeValue);
                }
            }
           
            if (!roleAttributes.isEmpty()) {
                AttributeType subjectRoleAttribute =
                    RequestComponentBuilder.createAttributeType(
                            XACMLConstants.SUBJECT_ROLE,
                            XACMLConstants.XS_ANY_URI,
                            issuer,
                            roleAttributes
                    );
                attributes.add(subjectRoleAttribute);
            }
        }
        SubjectType subjectType = RequestComponentBuilder.createSubjectType(attributes, null);
       
        // Resource
        attributes.clear();
        for (String resource : resources) {
            if (resource != null) {
                AttributeValueType resourceAttributeValue =
                    RequestComponentBuilder.createAttributeValueType(resource);
                AttributeType resourceAttribute =
                    RequestComponentBuilder.createAttributeType(
                            XACMLConstants.RESOURCE_ID,
                            XACMLConstants.XS_STRING,
                            null,
                            Collections.singletonList(resourceAttributeValue)
                    );
                attributes.add(resourceAttribute);
            }
        }
        ResourceType resourceType = RequestComponentBuilder.createResourceType(attributes, null);
       
        // Action
        AttributeValueType actionAttributeValue =
            RequestComponentBuilder.createAttributeValueType(actionToUse);
        AttributeType actionAttribute =
            RequestComponentBuilder.createAttributeType(
                    XACMLConstants.ACTION_ID,
                    XACMLConstants.XS_STRING,
                    null,
                    Collections.singletonList(actionAttributeValue)
            );
        attributes.clear();
        attributes.add(actionAttribute);
        ActionType actionType = RequestComponentBuilder.createActionType(attributes);
       
        // Environment
        attributes.clear();
        if (sendDateTime) {
            DateTime dateTime = new DateTime();
            AttributeValueType environmentAttributeValue =
                RequestComponentBuilder.createAttributeValueType(dateTime.toString());
            AttributeType environmentAttribute =
                RequestComponentBuilder.createAttributeType(
                        XACMLConstants.CURRENT_DATETIME,
                        XACMLConstants.XS_DATETIME,
                        null,
                        Collections.singletonList(environmentAttributeValue)
View Full Code Here


        super(targetNamespaceURI, targetLocalName);
    }

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
        AttributeType attribute = (AttributeType) parentObject;
    
        if (childObject instanceof AttributeValueType) {
            attribute.getAttributeValues().add((AttributeValueType)childObject);
        } else {
            super.processChildElement(parentObject, childObject);
        }
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {

        AttributeType attrib = (AttributeType) xmlObject;

        if (attribute.getLocalName().equals(AttributeType.ATTRIBUTEID_ATTTRIB_NAME)) {
            attrib.setAttributeID(attribute.getValue());
        } else if (attribute.getLocalName().equals(AttributeType.DATATYPE_ATTRIB_NAME)) {
            attrib.setDataType(attribute.getValue());
        } else if (attribute.getLocalName().equals(AttributeType.ISSUER_ATTRIB_NAME)) {
            attrib.setIssuer(attribute.getValue());
        } else {
            super.processAttribute(xmlObject, attribute);
        }
    }
View Full Code Here

        super(targetNamespaceURI, targetLocalName);
    }

    /** {@inheritDoc} */
    protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
        AttributeType attribute = (AttributeType) samlElement;

        if (attribute.getIssuer() != null) {
            domElement.setAttributeNS(null, AttributeType.ISSUER_ATTRIB_NAME, attribute.getIssuer());
        }

        if (attribute.getDataType() != null) {
            domElement.setAttributeNS(null, AttributeType.DATATYPE_ATTRIB_NAME, attribute.getDataType());
        }

        if (attribute.getAttributeID() != null) {
            domElement.setAttributeNS(null, AttributeType.ATTRIBUTEID_ATTTRIB_NAME, attribute.getAttributeID());
        }
    }
View Full Code Here

    ) {
        if (attributeTypeBuilder == null) {
            attributeTypeBuilder = (XACMLObjectBuilder<AttributeType>)
                builderFactory.getBuilder(AttributeType.DEFAULT_ELEMENT_NAME);
        }
        AttributeType attributeType = attributeTypeBuilder.buildObject();
        attributeType.setAttributeID(attributeId);
        attributeType.setDataType(dataType);
        attributeType.setIssuer(issuer);
        attributeType.getAttributeValues().addAll(attributeValues);
       
        return attributeType;
    }
View Full Code Here

    private CtxAttributeTypeHelper() {}
   
    public static AttributeType build(String attributeId, String dataType, String value) {

        AttributeType attribute = (AttributeType) builderFactory.getBuilder(elementQName).buildObject(
                elementQName);

        attribute.setAttributeID(attributeId);
        attribute.setDataType(dataType);
        attribute.getAttributeValues().add(CtxAttributeValueHelper.build(value));

        return attribute;

    }
View Full Code Here

       
        // Subject
        List<AttributeType> attributes = new ArrayList<AttributeType>();
        AttributeValueType subjectIdAttributeValue =
            RequestComponentBuilder.createAttributeValueType(principal.getName());
        AttributeType subjectIdAttribute =
            RequestComponentBuilder.createAttributeType(
                    XACMLConstants.SUBJECT_ID,
                    XACMLConstants.XS_STRING,
                    issuer,
                    Collections.singletonList(subjectIdAttributeValue)
            );
        attributes.add(subjectIdAttribute);
       
        for (String role : roles) {
            AttributeValueType subjectRoleAttributeValue =
                RequestComponentBuilder.createAttributeValueType(role);
            AttributeType subjectRoleAttribute =
                RequestComponentBuilder.createAttributeType(
                        XACMLConstants.SUBJECT_ROLE,
                        XACMLConstants.XS_ANY_URI,
                        issuer,
                        Collections.singletonList(subjectRoleAttributeValue)
                );
            attributes.add(subjectRoleAttribute);
        }
        SubjectType subjectType = RequestComponentBuilder.createSubjectType(attributes, null);
       
        // Resource
        AttributeValueType resourceAttributeValue =
            RequestComponentBuilder.createAttributeValueType(resource);
        AttributeType resourceAttribute =
            RequestComponentBuilder.createAttributeType(
                    XACMLConstants.RESOURCE_ID,
                    XACMLConstants.XS_STRING,
                    null,
                    Collections.singletonList(resourceAttributeValue)
            );
        attributes.clear();
        attributes.add(resourceAttribute);
        ResourceType resourceType = RequestComponentBuilder.createResourceType(attributes, null);
       
        // Action
        AttributeValueType actionAttributeValue =
            RequestComponentBuilder.createAttributeValueType(actionToUse);
        AttributeType actionAttribute =
            RequestComponentBuilder.createAttributeType(
                    XACMLConstants.ACTION_ID,
                    XACMLConstants.XS_STRING,
                    null,
                    Collections.singletonList(actionAttributeValue)
            );
        attributes.clear();
        attributes.add(actionAttribute);
        ActionType actionType = RequestComponentBuilder.createActionType(attributes);
       
        // Environment
        attributes.clear();
        if (sendDateTime) {
            DateTime dateTime = new DateTime();
            AttributeValueType environmentAttributeValue =
                RequestComponentBuilder.createAttributeValueType(dateTime.toString());
            AttributeType environmentAttribute =
                RequestComponentBuilder.createAttributeType(
                        XACMLConstants.CURRENT_DATETIME,
                        XACMLConstants.XS_DATETIME,
                        null,
                        Collections.singletonList(environmentAttributeValue)
View Full Code Here

TOP

Related Classes of org.opensaml.xacml.ctx.AttributeType

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.