Package org.auraframework.def

Examples of org.auraframework.def.DefinitionAccess


    }

    <D extends Definition> String hasAccess(DefDescriptor<?> referencingDescriptor, D def,
            Cache<String, String> accessCheckCache) {
        // If the def is access="global" or does not require authentication then anyone can see it
        DefinitionAccess access = def.getAccess();
        if (access.isGlobal() || !access.requiresAuthentication()) {
            return null;
        }

        ConfigAdapter configAdapter = Aura.getConfigAdapter();
        String referencingNamespace = null;
View Full Code Here


    /**
     * Verify authentication values specified with access attribute.
     * @throws Exception
     */
    public void testParseSpecifiedAuthentication()throws Exception{
        DefinitionAccess access = definitionParser.parseAccess(null, "authenticated");
        assertTrue(access.requiresAuthentication());
       
        access = definitionParser.parseAccess(null, "unauthenticated");
        assertFalse(access.requiresAuthentication());
       
        //Case insensitive too
        access = definitionParser.parseAccess(null, "AUTHENTICATED");
        assertTrue(access.requiresAuthentication());
       
        //No authentication specified
        access = definitionParser.parseAccess(null, "PRIVATE");
        assertTrue(access.requiresAuthentication());
       
        //Both authentication values specified
        try{
            definitionParser.parseAccess(null, "AUTHENTICATED, UNAUTHENTICATED");
            fail("Should not allow to specify both authentication values.");
View Full Code Here

   
    /**
     * Verify access values specified using access attribute.
     */
    public void testParseSpecifiedAccess() throws Exception{
        DefinitionAccess access = definitionParser.parseAccess(null, "GLOBAL");
        assertTrue(access.isGlobal());
       
        access = definitionParser.parseAccess(null, "PRIVATE");
        assertFalse(access.isGlobal());
        assertTrue(access.isPrivate());
       
        access = definitionParser.parseAccess(null, "INTERNAL");
        assertTrue(access.isInternal());
       
        access = definitionParser.parseAccess(null, "PUBLIC");
        assertTrue(access.isPublic());
       
        //Multiple access levels specified
        try{
            definitionParser.parseAccess(null, "GLOBAL, PRIVATE");
            fail("Should not allow to specify more than one access level.");
View Full Code Here

        }
    }
   
    public void testParseStaticMethods()throws Exception{
        //Positive test case
        DefinitionAccess access = definitionParser.parseAccess(null, "org.auraframework.test.TestAccessMethods.allowGlobal");
        assertTrue(access.isGlobal());
       
        //Negative test cases
        for(String s : new String[]{
                "org.auraframework.test.TestAccessMethods.privateMethod",
                "org.auraframework.test.TestAccessMethods.allowAuthenticated", //Return type is not Access
                "java://org.auraframework.test.TestAccessMethods.allowGlobal",
                "org.auraframework.test.TestAccessMethods.nonStaticMethod",
                "org.auraframework.test.TestAccessMethods.allowGlobal, org.auraframework.test.TestAccessMethods.allowPrivate",
                "org.auraframework.test.TestAccessMethods.lostSoul",
                "org.auraframework.test.LostParent.lostSoul",
                })
        {
            try{
                definitionParser.parseAccess(null, s);
                fail("Should have failed because this access method is unusable :"+ s);
            }catch(InvalidAccessValueException expected){
                //Expected
            }
        }
        access = definitionParser.parseAccess(null, "org.auraframework.test.TestAccessMethods.throwsException");
        try{
            access.isGlobal();
            fail("Should throw an AuraRuntimeException when access method throws an exception.");
        }catch(AuraRuntimeException expected){
            assertTrue(expected.getMessage().startsWith("Exception executing access-checking method"));
        }
       
View Full Code Here

        }
       
    }
   
    public void testValidation_AccessLevelAndStaticMethodSpecified()throws Exception{
        DefinitionAccess access = definitionParser.parseAccess(null, "org.auraframework.test.TestAccessMethods.allowGlobal, PRIVATE");
        try{
            access.validate(null, false, false);
            fail("Access attribute may not specify enum value when a static method is also specified");
        }catch(InvalidAccessValueException expected){}
    }
View Full Code Here

            fail("Access attribute may not specify enum value when a static method is also specified");
        }catch(InvalidAccessValueException expected){}
    }
   
    public void testValidation_AuthenticationAllowedOnlyInSystemNamespace()throws Exception{
        DefinitionAccess access = definitionParser.parseAccess(null, "AUTHENTICATED");
        access.validate(StringSourceLoader.DEFAULT_NAMESPACE, true, false);
       
        //AUTHENTICATED/UNAUTHENTICATED not supported in custom namespaces
        try{
            access.validate(StringSourceLoader.DEFAULT_CUSTOM_NAMESPACE, true, false);
            fail("Authentication values for access should not be allowed in custom namespaces");
        }catch(InvalidAccessValueException expected){          
        }
    }
View Full Code Here

     * Verify that authentication values cannot be used when validate() is asked not to allow it.
     * @throws Exception
     */
    public void testValidation_AuthenticationCannotBeUsedWhenNotAllowed()throws Exception{
        Boolean allowAuthentication = false;
        DefinitionAccess access = definitionParser.parseAccess(null, "AUTHENTICATED");
        try{
            access.validate(StringSourceLoader.DEFAULT_NAMESPACE, allowAuthentication, false);
            fail("Should not have processed athentication");
        }catch(InvalidAccessValueException expected){}
    }
View Full Code Here

    }
   
   
    public void testValidation_PrivateAccess()throws Exception{
        boolean allowPrivate = true;
        DefinitionAccess access = definitionParser.parseAccess(null, "PRIVATE");
        access.validate(null, false, allowPrivate);
       
        allowPrivate = false;
        try{
            access.validate(null, false, allowPrivate);
            fail("PRIVATE access should not be allowed");
        }catch(InvalidAccessValueException expected){}
    }
View Full Code Here

            fail("PRIVATE access should not be allowed");
        }catch(InvalidAccessValueException expected){}
    }
   
    public void testValidation_InternalAccess()throws Exception{
        DefinitionAccess access = definitionParser.parseAccess(null, "INTERNAL");
        access.validate(StringSourceLoader.DEFAULT_NAMESPACE, false, false);
       
        //INTERNAL not supported in custom namespaces
        try{
            access.validate(StringSourceLoader.DEFAULT_CUSTOM_NAMESPACE, false, false);
            fail("INTERNAL should not be allowed in custom namespaces");
        }catch(InvalidAccessValueException expected){}
    }
View Full Code Here

            fail("INTERNAL should not be allowed in custom namespaces");
        }catch(InvalidAccessValueException expected){}
    }
   
    public void testValidation_StaticMethodsUsageRestriction() throws Exception{
        DefinitionAccess access = definitionParser.parseAccess(null, "org.auraframework.test.TestAccessMethods.allowGlobal");
        access.validate(StringSourceLoader.DEFAULT_NAMESPACE, false, false);
       
        //static methods not supported in custom namespaces
        try{
            access.validate(StringSourceLoader.DEFAULT_CUSTOM_NAMESPACE, false, false);
            fail("static methods should not be allowed in custom namespaces");
        }catch(InvalidAccessValueException expected){}
       
    }
View Full Code Here

TOP

Related Classes of org.auraframework.def.DefinitionAccess

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.