Examples of PolicyDTO


Examples of ma.glasnost.orika.test.crossfeatures.PolicyElementsTestCaseClasses.PolicyDTO

        elements.add(new OtherElement());
        elements.add(new OneOtherElement());
       
        policy.setElements(elements);
       
        PolicyDTO dto = factory.getMapperFacade().map(policy, PolicyDTO.class);
       
        Assert.assertEquals(elements.size(), dto.getElements().size());
    }
View Full Code Here

Examples of ma.glasnost.orika.test.crossfeatures.PolicyElementsTestCaseClasses.PolicyDTO

        elements.add(new OtherElement());
        elements.add(new OneOtherElement());
       
        policy.setElements(elements);
       
        PolicyDTO dto = factory.getMapperFacade().map(policy, PolicyDTO.class);
       
        Assert.assertEquals(elements.size(), dto.getElements().size());
       
        for (PolicyElementDTO element: dto.getElements()) {
            if (element instanceof CustomerElementDTO) {
                Assert.assertEquals("Adil", ((CustomerElementDTO) element).getName());
            }
        }
       
View Full Code Here

Examples of ma.glasnost.orika.test.crossfeatures.PolicyElementsTestCaseClasses.PolicyDTO

        elements.add(new OtherElement());
        elements.add(new OneOtherElement());
       
        policy.setElements(elements);
       
        PolicyDTO dto = factory.getMapperFacade(Policy.class, PolicyDTO.class).map(policy);
       
        Assert.assertEquals(elements.size(), dto.getElements().size());
    }
View Full Code Here

Examples of ma.glasnost.orika.test.crossfeatures.PolicyElementsTestCaseClasses.PolicyDTO

        elements.add(new OtherElement());
        elements.add(new OneOtherElement());
       
        policy.setElements(elements);
       
        PolicyDTO dto = factory.getMapperFacade(Policy.class, PolicyDTO.class).map(policy);
       
        Assert.assertEquals(elements.size(), dto.getElements().size());
       
        for (PolicyElementDTO element: dto.getElements()) {
            if (element instanceof CustomerElementDTO) {
                Assert.assertEquals("Adil", ((CustomerElementDTO) element).getName());
            }
        }
       
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.dto.PolicyDTO

     * @return
     * @throws IdentityException
     */
    public PolicyDTO readPolicyDTO(String policyId) throws IdentityException {
        Resource resource = null;
        PolicyDTO dto = null;
        try {
            resource = store.getPolicy(policyId);
            if (resource == null) {
                return null;
            }
            dto = new PolicyDTO();
            dto.setPolicyId(policyId);
            dto.setPolicy(new String((byte[]) resource.getContent()));
            if ("true".equals(resource.getProperty("isActive"))) {
                dto.setActive(true);
            }
            dto.setPolicyType(resource.getProperty("policyType"));
            //read policy meta data that is used for basic policy editor
            dto.setPolicyEditor(resource.getProperty("policyEditor"));
            String policyMetaDataAmount = resource.getProperty("policyData");
            if(policyMetaDataAmount != null){
                int amount = Integer.parseInt(policyMetaDataAmount);
                String[] policyData = new String[amount];
                for(int i = 0; i < amount; i++){
                    policyData[i] = resource.getProperty("policyData" + i);
                }
                dto.setPolicyMetaData(policyData);
            }          
            return dto;
        } catch (RegistryException e) {
            log.error("Error while loading entitlement policy", e);
            throw new IdentityException("Error while loading entitlement policy", e);
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.dto.PolicyDTO

     * @throws IdentityException
     */
    private PolicyDTO readPolicyDTO(Resource resource) throws IdentityException {
        String policy = null;
        AbstractPolicy absPolicy = null;
        PolicyDTO dto = null;
        try {
            policy = new String((byte[]) resource.getContent());
            absPolicy = PolicyReader.getInstance(null, null).getPolicy(policy);
            dto = new PolicyDTO();
            dto.setPolicyId(absPolicy.getId().toASCIIString());
            dto.setPolicy(policy);
            if ("true".equals(resource.getProperty("isActive"))) {
                dto.setActive(true);
            }
            dto.setPolicyType(resource.getProperty("policyType"));
            //read policy meta data that is used for basic policy editor
            dto.setPolicyEditor(resource.getProperty("policyEditor"));           
            String policyMetaDataAmount = resource.getProperty("policyData");
            if(policyMetaDataAmount != null){
                int amount = Integer.parseInt(policyMetaDataAmount);
                String[] policyData = new String[amount];
                for(int i = 0; i < amount; i++){
                    policyData[i] = resource.getProperty("policyData" + i);
                }
                dto.setPolicyMetaData(policyData);
            }
            return dto;
           
        } catch (RegistryException e) {
            log.error("Error while loading entitlement policy", e);
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.dto.PolicyDTO

     *             throws when fails or registry error occurs
     */
    public void importPolicyFromRegistry(String policyRegistryPath) throws IdentityException {

        Registry registry;
        PolicyDTO policyDTO = new PolicyDTO();
        String policy = "";
        BufferedReader bufferedReader = null;
        InputStream inputStream = null;

        // Finding from which registry by comparing prefix of resource path
        String resourceUri = policyRegistryPath.substring(policyRegistryPath.lastIndexOf(':') + 1);
        String registryIdentifier = policyRegistryPath.substring(0,
                policyRegistryPath.lastIndexOf(':'));
        if (IdentityRegistryResources.CONFIG_REGISTRY_IDENTIFIER.equals(registryIdentifier)) {
            registry = getConfigSystemRegistry();
        } else {
            registry = getGovernanceUserRegistry();
        }

        try {
            Resource resource = registry.get(resourceUri);
            inputStream = resource.getContentStream();
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            String stringLine;
            StringBuffer buffer = new StringBuffer(policy);
            while ((stringLine = bufferedReader.readLine()) != null) {
                buffer.append(stringLine);
            }
            policy = buffer.toString();
            policyDTO.setPolicy(policy.replaceAll(">\\s+<", "><"));
            addPolicy(policyDTO);
        } catch (RegistryException e) {
            throw new IdentityException("Registry Error occurs while reading policy from registry");
        } catch (IOException e) {
            throw new IdentityException("I/O Error occurs while reading policy from registry");
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.dto.PolicyDTO

     */
    public PolicyDTO getPolicy(String policyId) throws IdentityException {
        PolicyStoreReader policyReader = null;
        EntitlementEngine.getInstance(getGovernanceUserRegistry(), CarbonContext.getCurrentContext().getTenantId())
        if (TEMPLATE_POLICY.equals(policyId)) {
            PolicyDTO policy = new PolicyDTO();
            policy.setPolicy(EntitlementServiceComponent.getTemplatePolicy());
            policy.setPolicyId(policyId);
            return policy;
        }

        policyReader = new PolicyStoreReader(new PolicyStore(getGovernanceUserRegistry()));
        return policyReader.readPolicyDTO(policyId);
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO

     * @param policyId
     * @return
     * @throws AxisFault
     */
    public PolicyDTO getPolicy(String policyId) throws AxisFault {
        PolicyDTO dto = null;
        try {
            dto = stub.getPolicy(policyId);
            dto.setPolicy(dto.getPolicy().trim().replaceAll("><", ">\n<"));           
        } catch (Exception e) {
            String message = "Error while loading the policy from backend service";
            handleException(message, e);
        }
        return dto;
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO

     *
     * @param request
     * @throws AxisFault
     */
    public void importPolicy(HttpServletRequest request) throws AxisFault {
        PolicyDTO dto = null;
        try {
            if (ServletFileUpload.isMultipartContent(request)) {
                List items = parseRequest(new ServletRequestContext(request));
                byte[] content = null;
                String fileName = null;
                for (Object item : items) {
                    DiskFileItem diskFileItem = (DiskFileItem) item;
                    String name = diskFileItem.getFieldName();
                    if (name.equals("policyFromFileSystem")) {
                        content = diskFileItem.get();
                        fileName = diskFileItem.getName();
                        int index = fileName.lastIndexOf("\\");
                        fileName = fileName.substring(index + 1);
                    }
                }
                dto = new PolicyDTO();
                dto.setPolicy(new String(content));
                dto.setPolicy(dto.getPolicy().trim().replaceAll(">\\s+<", "><"));
                stub.addPolicy(dto);
            } else {
                throw new Exception("Error while importing the policy at the backend service");
            }
        } catch (Exception e) {
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.