Package java.lang

Examples of java.lang.Exception


            }
            catch (SSOException ssoex)
            {
                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL);
                ssoex.printStackTrace();
                throw new Exception(ssoex.getMessage());
            }
        }
        else
        {
            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL);
        }

        // Add another remote principal for the same user
        if (ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
        {
            System.out.println("No SSO Credential for user:" + TEST_USER + " site: " + TEST_URL2);

            // Add credential
            try
            {
                ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
                ssoBroker.setRealmForSite(TEST_URL2, "Nagios Access");
               
                System.out.println("SSO Credential added for user:" + TEST_USER + " site: " + TEST_URL2);
            }
            catch (SSOException ssoex)
            {
                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL2);
                ssoex.printStackTrace();
                throw new Exception(ssoex.getMessage());
            }
        }
        else
        {
            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL2);
        }

        // Add the credentail again -- should get an error
        try
        {
            ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
            throw new Exception("Added same credentail twice -- API should prevent users from doing that.");

        }
        catch (SSOException ssoex)
        {
            System.out.println("Adding same SSO Credential twice failed (as expected) Message :" + ssoex.getMessage());
        }
        catch (Exception e)
        {
            throw new Exception("Adding SSO Credential twice throw an unandled exception. Error: " + e.getMessage());
        }

        // Test if the credential where persisted

        // Test credential update
        SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL);

        SSOContext ssocontext2 = ssoBroker.getCredentials(subject, TEST_URL2);
        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);

        try
        {
            // Update Remote credential
            System.out.println("SSO Credential Update");
            ssoBroker.updateCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_2);

            ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
            System.out.println("SSO Credential updated: User:" + ssocontext.getRemotePrincipalName() + " Password: "
                    + ssocontext.getRemoteCredential());

        }
        catch (SSOException ssoex)
        {
            System.out.println("SSO Credential update FAILED for user:" + TEST_USER + " site: " + TEST_URL);
            throw new Exception(ssoex.getMessage());
        }
         
        /*
         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
         * constraint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
         * releases try { // Remove credential for Site ssoBroker.removeCredentialsForSite(subject, TEST_URL);
         * System.out.println("SSO Credential removed for user:" + TEST_USER+ " site: " + TEST_URL); }
         * catch(SSOException ssoex) { System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " +
         * TEST_URL); throw new Exception(ssoex.getMessage()); }
         */

        Iterator sites = ssoBroker.getSites("");
        while (sites.hasNext())
        {
            SSOSite site = (SSOSite) sites.next();
            System.out.println("Site = " + site.getName());
        }
        // Cleanup
        try
        {
          ssoBroker.removeCredentialsForSite(subject, TEST_URL);
          ssoBroker.removeCredentialsForSite(subject, TEST_URL2);
          System.out.println("SSO Credential removed for user:" + TEST_USER+ " sites: " + TEST_URL + " " + TEST_URL2);
        }
        catch(SSOException ssoex)
        {
          System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " + TEST_URL + " and " + TEST_URL2);
          throw new Exception(ssoex.getMessage());
        }

    }
View Full Code Here


            ssoBroker = (SSOProvider) ctx.getBean("ssoProvider");
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            throw new Exception("Exception while setup SSO TEST");
        }
    }
View Full Code Here

            }
            catch (SSOException ssoex)
            {
                System.out.println("SSO Credential add FAILED for Group:" + TEST_GROUP + " site: " + TEST_URL);
                ssoex.printStackTrace();
                throw new Exception(ssoex.getMessage());
            }
        }
        else
        {
            System.out.println("Group:" + TEST_GROUP + " site: " + TEST_URL + " has already a remote credential");
        }

        // Create Principal for User
        principal = new UserPrincipalImpl(TEST_GROUP_USER);
        principals = new HashSet();
        principals.add(principal);
        subject = new Subject(true, principals, new HashSet(), new HashSet());

        // User should have credential for site
        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
        {
            // Group expansion failed. User not recognized
            System.out.println("No SSO Credential for user:" + TEST_GROUP_USER + " site: " + TEST_URL);

            // Test failure
            try
            {
                ums.removeUser(TEST_GROUP_USER);
                gms.removeGroup(TEST_GROUP);
            }
            catch (SecurityException sex)
            {
                assertTrue("could not remove user and group. exception caught: " + sex, false);
            }

            throw new Exception("SSO Unit test for Group support failed");
        }
        else
        {
            // Group lookup succesful
            System.out.println("SSO Test for Group support successful" + "\nSSO Credential for user:" + TEST_GROUP_USER
                    + " site: " + TEST_URL + " found. User is member of Group " + TEST_GROUP);
        }

        // Cleanup test.

        /*
         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
         * constraint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
         * releases
         */
        try
        {
            // Remove credential for Site
            ssoBroker.removeCredentialsForSite("/group/" + TEST_GROUP, TEST_URL);
            System.out.println("SSO Credential removed for Group:" + TEST_GROUP + " site: " + TEST_URL);
        }
        catch (SSOException ssoex)
        {
            System.out.println("SSO Credential remove FAILED for Group:" + TEST_GROUP + " site: " + TEST_URL);
            throw new Exception(ssoex.getMessage());
        }

        try
        {
            ums.removeUser(TEST_GROUP_USER);
View Full Code Here

            }
            catch (SSOException ssoex)
            {
                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL);
                ssoex.printStackTrace();
                throw new Exception(ssoex.getMessage());
            }
        }
        else
        {
            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL);
        }

        // Add another remote principal for the same user
        if (ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
        {
            System.out.println("No SSO Credential for user:" + TEST_USER + " site: " + TEST_URL2);

            // Add credential
            try
            {
                ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
                ssoBroker.setRealmForSite(TEST_URL2, "Nagios Access");
               
                System.out.println("SSO Credential added for user:" + TEST_USER + " site: " + TEST_URL2);
            }
            catch (SSOException ssoex)
            {
                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL2);
                ssoex.printStackTrace();
                throw new Exception(ssoex.getMessage());
            }
        }
        else
        {
            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL2);
        }

        // Add the credentail again -- should get an error
        try
        {
            ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
            throw new Exception("Added same credentail twice -- API should prevent users from doing that.");

        }
        catch (SSOException ssoex)
        {
            System.out.println("Adding same SSO Credential twice failed (as expected) Message :" + ssoex.getMessage());
        }
        catch (Exception e)
        {
            throw new Exception("Adding SSO Credential twice throw an unandled exception. Error: " + e.getMessage());
        }

        // Test if the credential where persisted

        // Test credential update
        SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL);

        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);

        try
        {
            // Update Remote credential
            System.out.println("SSO Credential Update");
            ssoBroker.updateCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_2);

            ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
            System.out.println("SSO Credential updated: User:" + ssocontext.getRemotePrincipalName() + " Password: "
                    + ssocontext.getRemoteCredential());

        }
        catch (SSOException ssoex)
        {
            System.out.println("SSO Credential update FAILED for user:" + TEST_USER + " site: " + TEST_URL);
            throw new Exception(ssoex.getMessage());
        }
         
        /*
         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
         * constraint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
         * releases try { // Remove credential for Site ssoBroker.removeCredentialsForSite(subject, TEST_URL);
         * System.out.println("SSO Credential removed for user:" + TEST_USER+ " site: " + TEST_URL); }
         * catch(SSOException ssoex) { System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " +
         * TEST_URL); throw new Exception(ssoex.getMessage()); }
         */

        Iterator sites = ssoBroker.getSites("");
        while (sites.hasNext())
        {
            SSOSite site = (SSOSite) sites.next();
            System.out.println("Site = " + site.getName());
        }
        // Cleanup
        try
        {
          ssoBroker.removeCredentialsForSite(subject, TEST_URL);
          ssoBroker.removeCredentialsForSite(subject, TEST_URL2);
          System.out.println("SSO Credential removed for user:" + TEST_USER+ " sites: " + TEST_URL + " " + TEST_URL2);
        }
        catch(SSOException ssoex)
        {
          System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " + TEST_URL + " and " + TEST_URL2);
          throw new Exception(ssoex.getMessage());
        }

    }
View Full Code Here

        int num = cs.getCookieCount();
        for( int i=0; i< num ; i++ ) {
            System.out.println("Cookie: " + cs.getCookie( i ));
        }
        if (num != 0)
          throw new Exception("wrong number of cookies " + num);
    }
View Full Code Here

        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());

        int num = cs.getCookieCount();
        if (num != 2)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("1 - Cookie: " + co);
        ServerCookie co2 = cs.getCookie(1);
        System.out.println("2 - Cookie: " + co2);

        String coname = co.getName().toString();
        String coval  = co.getValue().toString();
        if ( ! name.equals(coname))
          throw new Exception("1 - wrong name " + coname + " != " + name);
        if ( ! val.equals(coval))
          throw new Exception("1 - wrong value " + coval + " != " + val);

        String coname2 = co2.getName().toString();
        String coval2  = co2.getValue().toString();
        if ( ! name2.equals(coname2))
          throw new Exception("2 - wrong name " + coname2 + " != " + name2);
        if ( ! val2.equals(coval2))
          throw new Exception("2 - wrong value " + coval2 + " != " + val2);
    }
View Full Code Here

        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());

        int num = cs.getCookieCount();
        if (num != 3)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("1 - Cookie: " + co);
        ServerCookie co2 = cs.getCookie(1);
        System.out.println("2 - Cookie: " + co2);
        ServerCookie co3 = cs.getCookie(2);
        System.out.println("3 - Cookie: " + co3);

        String coname = co.getName().toString();
        String coval  = co.getValue().toString();
        if ( ! name.equals(coname))
          throw new Exception("1 - wrong name " + coname + " != " + name);
        if ( ! val.equals(coval))
          throw new Exception("1 - wrong value " + coval + " != " + val);

        String coname2 = co2.getName().toString();
        String coval2  = co2.getValue().toString();
        if ( ! name2.equals(coname2))
          throw new Exception("2 - wrong name " + coname2 + " != " + name2);
        if ( ! val2.equals(coval2))
          throw new Exception("2 - wrong value " + coval2 + " != " + val2);

        String coname3 = co3.getName().toString();
        String coval3  = co3.getValue().toString();
        if ( ! name3.equals(coname3))
          throw new Exception("3 - wrong name " + coname3 + " != " + name3);
        if ( ! val2.equals(coval2))
          throw new Exception("3 - wrong value " + coval3 + " != " + val3);
    }
View Full Code Here

        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());

        int num = cs.getCookieCount();
        if (num != 4)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("1 - Cookie: " + co);
        ServerCookie co2 = cs.getCookie(1);
        System.out.println("2 - Cookie: " + co2);
        ServerCookie co3 = cs.getCookie(2);
        System.out.println("3 - Cookie: " + co3);
        ServerCookie co4 = cs.getCookie(3);
        System.out.println("4 - Cookie: " + co4);

        String coname = co.getName().toString();
        String coval  = co.getValue().toString();
        if ( ! name.equals(coname))
          throw new Exception("1 - wrong name " + coname + " != " + name);
        if ( ! val.equals(coval))
          throw new Exception("1 - wrong value " + coval + " != " + val);

        String coname2 = co2.getName().toString();
        String coval2  = co2.getValue().toString();
        if ( ! name2.equals(coname2))
          throw new Exception("2 - wrong name " + coname2 + " != " + name2);
        if ( ! val2.equals(coval2))
          throw new Exception("2 - wrong value " + coval2 + " != " + val2);

        String coname3 = co3.getName().toString();
        String coval3  = co3.getValue().toString();
        if ( ! name3.equals(coname3))
          throw new Exception("3 - wrong name " + coname3 + " != " + name3);
        if ( ! val3.equals(coval3))
          throw new Exception("3 - wrong value " + coval3 + " != " + val3);

        String coname4 = co4.getName().toString();
        String coval4  = co4.getValue().toString();
        if ( ! name4.equals(coname4))
          throw new Exception("4 - wrong name " + coname4 + " != " + name4);
        if ( ! val4.equals(coval4))
          throw new Exception("4 - wrong value " + coval4 + " != " + val4);
    }
View Full Code Here

    if (ontology==null) {
      try {
        ontology = new OntologyFactory(this.conf).getOntology();
      } catch (Exception e) {
        throw new Exception("Failed to instantiate ontology");
      }
    }

    //foreach sample file
    for (int i=0; i<sampleFiles.length; i++) {
View Full Code Here

        System.out.println("Processing [" + s + "]");
        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());
        int num = cs.getCookieCount();
        if (num != 1)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("One Cookie: " + co);
        if (co.getVersion() != val)
          throw new Exception("wrong version " + co.getVersion() + " != " + val);
    }
View Full Code Here

TOP

Related Classes of java.lang.Exception

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.