Package javax.security.sasl

Examples of javax.security.sasl.AuthenticationException


                           entry = realmMap.get(userName);
                        }
                     }
                  }
                  if (entry == null) {
                     throw new AuthenticationException("No matching user found");
                  }
                  for (String group : entry.getGroups()) {
                     subject.getPrincipals().add(new SimpleGroupPrincipal(group));
                  }
                  passwordCallback.setPassword(entry.getPassword());
View Full Code Here


            HashMap<String, String> directivesMap, String directive,
            boolean mandatory) throws AuthenticationException {
        String value = directivesMap.get(directive);
        if (value == null) {
            if (mandatory) {
                throw new AuthenticationException("\"" + directive
                        + "\" mandatory directive is missing");
            }

            return "";
        }
View Full Code Here

    @Override
    protected Object[] getData() {
        String msg = null;
        Exception cause = new Exception(msgs[1]);
        return new Object[] { new AuthenticationException(),
                new AuthenticationException(msg),
                new AuthenticationException(msgs[1]),
                new AuthenticationException(msg, null),
                new AuthenticationException(msgs[0], null),
                new AuthenticationException(msg, cause),
                new AuthenticationException(msgs[1], cause)
                };
    }
View Full Code Here

     * Assertion:
     * constructs AuthenticationException with defined detail message.
     * Parameter <code>detail</code> is not null.
     */
    public void testAuthenticationException02() {
        AuthenticationException tE;
        for (int i = 0; i < msgs.length; i++) {
            tE = new AuthenticationException(msgs[i]);
            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
                    .getMessage(), msgs[i]);
            assertNull("getCause() must return null", tE.getCause());
        }
    }
View Full Code Here

     * Test for <code>AuthenticationException(String detail)</code> constructor
     * Assertion: constructs AuthenticationException when <code>detail</code> is null
     */
    public void testAuthenticationException03() {
        String msg = null;
        AuthenticationException tE = new AuthenticationException(msg);
        assertNull("getMessage() must return null.", tE.getMessage());
        assertNull("getCause() must return null", tE.getCause());
    }
View Full Code Here

     * Test for <code>AuthenticationException(String detail, Throwable ex)</code> constructor
     * Assertion: constructs AuthenticationException when <code>ex</code> is null
     * <code>detail</code> is null
     */
    public void testAuthenticationException04() {
        AuthenticationException tE = new AuthenticationException(null, null);
        assertNull("getMessage() must return null", tE.getMessage());
        assertNull("getCause() must return null", tE.getCause());
    }
View Full Code Here

     * Test for <code>AuthenticationException(String detail, Throwable ex)</code> constructor
     * Assertion: constructs AuthenticationException when <code>ex</code> is null
     * <code>detail</code> is not null
     */
    public void testAuthenticationException05() {
        AuthenticationException tE;
        for (int i = 0; i < msgs.length; i++) {
            tE = new AuthenticationException(msgs[i], null);
            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
                    .getMessage(), msgs[i]);
            assertNull("getCause() must return null", tE.getCause());
        }
    }
View Full Code Here

     * Test for <code>AuthenticationException(String detail, Throwable  ex)</code> constructor
     * Assertion: constructs AuthenticationException when <code>ex</code> is not null
     * <code>detail</code> is null
     */
    public void testAuthenticationException06() {       
        AuthenticationException tE = new AuthenticationException(null, tCause);
        if (tE.getMessage() != null) {
            String toS = tCause.toString();
            String getM = tE.getMessage();
            assertTrue("getMessage() must should ".concat(toS), (getM
                    .indexOf(toS) != -1));
        }
        assertEquals("getCause() must return ".concat(tCause.toString()),
                tE.getCause(), tCause);
    }
View Full Code Here

     * Test for <code>AuthenticationException(String detail, Throwable ex)</code> constructor
     * Assertion: constructs AuthenticationException when <code>ex</code> is not null
     * <code>detail</code> is not null
     */
    public void testAuthenticationException07() {
        AuthenticationException tE;
        for (int i = 0; i < msgs.length; i++) {
            tE = new AuthenticationException(msgs[i], tCause);
            String getM = tE.getMessage();
            String toS = tCause.toString();
            if (msgs[i].length() > 0) {
                assertTrue("getMessage() must contain ".concat(msgs[i]), getM
                        .indexOf(msgs[i]) != -1);
                if (!getM.equals(msgs[i])) {
                    assertTrue("getMessage() should contain ".concat(toS), getM
                            .indexOf(toS) != -1);
                }
            }
            assertEquals("getCause() must return "
                        .concat(tCause.toString()), tE.getCause(), tCause);
        }
    }
View Full Code Here

                null,
                new Exception(
                        "New Exception for toString() method verification"),
                new Throwable(), new Exception("exception", new Exception()) };

        AuthenticationException eT;
        eT = new AuthenticationException();
        assertNotNull("Incorrect null string", eT.toString());
        for (int i = 0; i < msgs.length; i++) {
            eT = new AuthenticationException(msgs[i]);
            assertTrue("Incorrect result string", eT.toString()
                    .indexOf(msgs[i]) >= 0);

            for (int j = 0; j < th.length; j++) {
                eT = new AuthenticationException(msgs[i], th[j]);
                assertTrue("Incorrect result string", eT.toString().indexOf(
                        msgs[i]) >= 0);
                if (th[j] != null) {
                    assertTrue("Incorrect result string", eT.toString()
                            .indexOf(th[j].toString()) >= 0);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.security.sasl.AuthenticationException

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.