Package com.dtolabs.rundeck.core.authorization

Examples of com.dtolabs.rundeck.core.authorization.Attribute


     * Creates an authorization environment for a project.
     * @param project project name
     * @return environment to evaluate authorization for a project
     */
    public static Set<Attribute> authorizationEnvironment(final String project) {
        return Collections.singleton(new Attribute(URI.create(EnvironmentalContext.URI_BASE + "project"),
                project));
    }
View Full Code Here


            //empty env
            assertFalse(test.matches(env));

            //single matching env
            env.add(new Attribute(new URI("test://project"), "abc"));
            assertTrue(test.matches(env));

            //multi attrs, matches context value
            env.add(new Attribute(new URI("test://application"), "bloo"));
            assertTrue(test.matches(env));
        }
        {
            final Map context=new HashMap();
            context.put("project", "ab[c");
            final YamlPolicy.YamlEnvironmentalContext test = new YamlPolicy.YamlEnvironmentalContext(
                "test://", context);

            assertTrue(test.isValid());
            final HashSet<Attribute> env = new HashSet<Attribute>();

            //invalid regex should be equality check
            env.add(new Attribute(new URI("test://project"), "abc"));
            assertFalse(test.matches(env));

            env.clear();
            env.add(new Attribute(new URI("test://project"), "ab[c"));
            assertTrue(test.matches(env));

        }
    }
View Full Code Here

            "test://", context);

        assertTrue(test.isValid());
        final HashSet<Attribute> env = new HashSet<Attribute>();
        assertFalse(test.matches(env));
        env.add(new Attribute(new URI("test://project"), "abc"));
        assertFalse(test.matches(env));
        env.add(new Attribute(new URI("test://application"), "bloo"));
        assertTrue(test.matches(env));

        final HashSet<Attribute> env2 = new HashSet<Attribute>();
        env2.add(new Attribute(new URI("test://application"), "bloo"));
        assertFalse(test.matches(env2));
    }
View Full Code Here

            assertFalse(test.isValid());
            assertTrue(test.getValidation().contains("Context section: project: expected 'String', saw"));
            final HashSet<Attribute> env = new HashSet<Attribute>();
            assertFalse(test.matches(env));
            env.add(new Attribute(new URI("test://project"), "abc"));
            assertFalse(test.matches(env));
            env.add(new Attribute(new URI("test://application"), "bloo"));
            assertFalse(test.matches(env));
        }
        {
            final Map context=new HashMap();
            //key is not a string
            context.put(new HashMap(), "monkey");
            final YamlPolicy.YamlEnvironmentalContext test = new YamlPolicy.YamlEnvironmentalContext(
                "test://", context);

            assertFalse(test.isValid());
            assertTrue(test.getValidation().contains("Context section key expected 'String', saw"));
            final HashSet<Attribute> env = new HashSet<Attribute>();
            assertFalse(test.matches(env));
            env.add(new Attribute(new URI("test://project"), "abc"));
            assertFalse(test.matches(env));
            env.add(new Attribute(new URI("test://application"), "bloo"));
            assertFalse(test.matches(env));
        }
        {
            final Map context = new HashMap();
            //key is not a valid URI component
            context.put(" project", "monkey");
            final YamlPolicy.YamlEnvironmentalContext test = new YamlPolicy.YamlEnvironmentalContext(
                "test://", context);

            assertFalse(test.isValid());
            assertTrue(test.getValidation().contains("invalid URI"));
            final HashSet<Attribute> env = new HashSet<Attribute>();
            assertFalse(test.matches(env));
            env.add(new Attribute(new URI("test://project"), "abc"));
            assertFalse(test.matches(env));
            env.add(new Attribute(new URI("test://application"), "bloo"));
            assertFalse(test.matches(env));
        }
    }
View Full Code Here

                    builder.append(action);
                   
                    builder.append("> env<");
                    Iterator<Attribute> eiter = environment.iterator();
                    while(eiter.hasNext()) {
                        Attribute a = eiter.next();
                        builder.append(a);
                        if(eiter.hasNext()) {
                            builder.append(", ");
                        }
                    }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.authorization.Attribute

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.