Examples of MockIdentity


Examples of org.drools.guvnor.server.security.MockIdentity

            // Mock up SEAM contexts
            Map<String, Object> application = new HashMap<String, Object>();
            Lifecycle.beginApplication( application );
            Lifecycle.beginCall();
            MockIdentity midentity = new MockIdentity();
            RoleBasedPermissionResolver resolver = new RoleBasedPermissionResolver();
            resolver.setEnableRoleBasedAuthorization( true );
            midentity.addPermissionResolver( resolver );
            midentity.create();

            Contexts.getSessionContext().set( "org.jboss.seam.security.identity",
                                              midentity );
            Contexts.getSessionContext().set( "org.drools.guvnor.client.rpc.RepositoryService",
                                              impl );
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

        assertTrue(allowed);
    }

    @Test
    public void testAllowUserNoBasicAuthenticationHeaderNotAllowLogin() throws Exception {
        MockIdentity mockIdentity = new MockIdentity();
        mockIdentity.setIsLoggedIn(false);
        mockIdentity.setAllowLogin(false);
        setUpMockIdentity(mockIdentity);

        String encodedAuthToken = null;
        boolean allowed = RepositoryServlet.allowUser(encodedAuthToken);
        assertFalse(allowed);
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

        assertEquals("user", d[0]);
        assertEquals("pass", d[1]);
    }

    private MockIdentity getMockIdentity() {
        MockIdentity mockIdentity = new MockIdentity();
        mockIdentity.setIsLoggedIn(false);
        mockIdentity.setAllowLogin(true);
        return mockIdentity;
    }
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

                                      "" );
        ass.updateFormat( "drl" );
        ass.updateContent( "some content" );
        ass.checkin( "hey ho" );

        MockIdentity midentity = new MockIdentity();
        midentity.setIsLoggedIn( false );
        midentity.setAllowLogin( false );
        Contexts.getSessionContext().set( "org.jboss.seam.security.identity",
                                          midentity );

        RestAPIServlet serv = new RestAPIServlet();
        assertNotNull( serv.getAPI() );
        Map<String, String> headers = new HashMap<String, String>() {
            {
                put( "Irrelevant",
                     "garbage" );
            }
        };
        String uri = "http://loser/api/packages/testGetRestServlet/asset1.drl";
        MockHTTPRequest req = new MockHTTPRequest( uri,
                                                   headers );

        MockHTTPResponse res = new MockHTTPResponse();

        //try with no password
        serv.doGet( req,
                    res );
        assertEquals( HttpServletResponse.SC_UNAUTHORIZED,
                      res.errorCode );
        assertTrue( res.headers.containsKey( "WWW-Authenticate" ) );

        //try again with bad password
        headers = new HashMap<String, String>() {
            {
                put( "Authorization",
                     new String( Base64.encodeBase64( "foo:bar".getBytes() ) ) );
            }
        };
        req = new MockHTTPRequest( uri,
                                   headers );
        res = new MockHTTPResponse();
        serv.doGet( req,
                    res );
        assertEquals( HttpServletResponse.SC_UNAUTHORIZED,
                      res.errorCode );
        assertTrue( res.headers.containsKey( "WWW-Authenticate" ) );

        //finally, making it work
        midentity.setAllowLogin( true );

        headers = new HashMap<String, String>() {
            {
                put( "Authorization",
                     "BASIC " + new String( Base64.encodeBase64( "testuser:password".getBytes() ) ) );
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

        RulesRepository repo = impl.getRulesRepository();

        PackageItem pkg = repo.createPackage( "testPostRestServlet",
                                              "" );

        MockIdentity midentity = new MockIdentity();
        midentity.setIsLoggedIn( false );
        midentity.setAllowLogin( true );
        Contexts.getSessionContext().set( "org.jboss.seam.security.identity",
                                          midentity );

        Map<String, String> headers = new HashMap<String, String>() {
            {
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

                                      "abc" );
        ass.updateFormat( "drl" );
        ass.checkin( "" );
        long ver = ass.getVersionNumber();

        MockIdentity midentity = new MockIdentity();
        midentity.setIsLoggedIn( false );
        midentity.setAllowLogin( true );
        Contexts.getSessionContext().set( "org.jboss.seam.security.identity",
                                          midentity );

        Map<String, String> headers = new HashMap<String, String>() {
            {
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

        AssetItem ass = pkg.addAsset( "asset1",
                                      "abc" );
        ass.updateFormat( "drl" );
        ass.checkin( "" );

        MockIdentity midentity = new MockIdentity();
        midentity.setIsLoggedIn( false );
        midentity.setAllowLogin( true );
        Contexts.getSessionContext().set( "org.jboss.seam.security.identity",
                                          midentity );
        FileManagerUtils manager = new FileManagerUtils();
        manager.setRepository( repo );
        Contexts.getSessionContext().set( "fileManager",
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

      // Mock up SEAM contexts
      Map application = new HashMap<String, Object>();
      Lifecycle.beginApplication(application);
      Lifecycle.beginCall();
      MockIdentity midentity = new MockIdentity();
        RoleBasedPermissionResolver resolver = new RoleBasedPermissionResolver();
        resolver.setEnableRoleBasedAuthorization(true);
      midentity.addPermissionResolver(resolver);
      midentity.create();
     
      Contexts.getSessionContext().set(
          "org.jboss.seam.security.identity", midentity);
      Contexts.getSessionContext().set(
          "org.drools.guvnor.client.rpc.RepositoryService", impl);
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

      // Mock up SEAM contexts
      Map application = new HashMap<String, Object>();
      Lifecycle.beginApplication(application);
      Lifecycle.beginCall();
      MockIdentity midentity = new MockIdentity();
        RoleBasedPermissionResolver resolver = new RoleBasedPermissionResolver();
        resolver.setEnableRoleBasedAuthorization(true);
      midentity.addPermissionResolver(resolver);
      midentity.create();

      Contexts.getSessionContext().set(
          "org.jboss.seam.security.identity", midentity);
      Contexts.getSessionContext().set(
          "org.drools.guvnor.client.rpc.RepositoryService", impl);
View Full Code Here

Examples of org.drools.guvnor.server.security.MockIdentity

      // Mock up SEAM contexts
      Map application = new HashMap<String, Object>();
      Lifecycle.beginApplication(application);
      Lifecycle.beginCall();
      MockIdentity midentity = new MockIdentity();
        RoleBasedPermissionResolver resolver = new RoleBasedPermissionResolver();
        resolver.setEnableRoleBasedAuthorization(false);
      midentity.addPermissionResolver(resolver);
      midentity.create();

      Contexts.getSessionContext().set(
          "org.jboss.seam.security.identity", midentity);
      Contexts.getSessionContext().set(
          "org.drools.guvnor.client.rpc.RepositoryService", impl);
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.