Java 8 UnsupportedCallbackException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 UnsupportedCallbackException class.

This code example shows how to use the following methods:getCallback
        } catch (IOException e) {
            LoginException le = new LoginException("Failed to get username/password");
            le.initCause(e);
            throw le;
        } catch (UnsupportedCallbackException e) {
            LoginException le = new LoginException("CallbackHandler does not support: " + e.getCallback());
            le.initCause(e);
            throw le;
        } 
        info[0] = username;
        info[1] = password;
        return info;
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:equals, getMessage, getCallback
 
    /** 
     * Test for UnsupportedCallbackException(Callback c, String msg) ctor  
     */ 
    public final void testUnsupportedCallbackException_02() { 
        UnsupportedCallbackException ce = new UnsupportedCallbackException(nc, "message");
        assertEquals ("message", ce.getMessage());
        assertEquals(nc, ce.getCallback());
        try { 
            throw ce;
        }catch (Exception e){
            assertTrue(ce.equals(e));
            assertEquals(nc, ce.getCallback());
        } 
 
    } 
 
    /** 
     * Test for UnsupportedCallbackException(Callback c, String msg) ctor  
     * when callback and msg is null  
6
CodeRank
This code example shows how to use the following methods:getCallback
        } catch (IOException e) {
            LoginException le = new LoginException("Failed to get username/password");
            le.initCause(e);
            throw le;
        } catch (UnsupportedCallbackException e) {
            LoginException le = new LoginException("CallbackHandler does not support: " + e.getCallback());
            le.initCause(e);
            throw le;
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getMessage
        try { 
            callbackHandler.handle(callbacks);
        } catch (IOException ioe) {
            throw new LoginException(ioe.getMessage());
        } catch (UnsupportedCallbackException uce) {
            throw new LoginException(uce.getMessage() + " Unable to obtain client certificates.");
        } 
        certificates = ((CertificateCallback)callbacks[0]).getCertificates();
 
        username = getUserNameForCertificates(certificates);
        if (username == null) {
            throw new FailedLoginException("No user for client certificate: " + getDistinguishedName(certificates));
        } 
 
        groups = getUserGroups(username);
 
        if (debug) {
            LOG.debug("Certificate for user: " + username);
        } 
        return true; 
6
CodeRank
This code example shows how to use the following methods:
    public void login_throwUnsupportedCallbackException() throws LoginException, IOException,
            UnsupportedCallbackException {
        this.options.put("debug", "true");
        this.loginModule.initialize(this.subject, this.callbackHandler, null, this.options);
        Assert.assertTrue(this.loginModule.isAllowGuestLogin());
        PowerMockito.doThrow(new UnsupportedCallbackException(new NameCallback("Callback Exception")))
                .when(this.callbackHandler).handle(Matchers.any(Callback[].class));
        this.loginModule.login();
    } 
 
    @Test(expected = LoginException.class)
    public void logon_noCallbackHandler() throws LoginException {
        this.loginModule.login();
    } 
 
    @Test
    public void logout_abortNoUser() throws LoginException {
        this.loginModule.initialize(this.subject, this.callbackHandler, null, this.options);
        Assert.assertTrue(this.loginModule.abort());
    } 
5
CodeRank
This code example shows how to use the following methods:getMessage, getCallback
    /** 
     * javax.security.auth.callback.UnsupportedCallbackExceptionTest#UnsupportedCallbackException(Callback callback, String msg) 
     * Assertion: constructs with null callback parameter and null message. 
     */ 
    public void testUnsupportedCallbackException03() { 
        UnsupportedCallbackException ucE = new UnsupportedCallbackException(null, null);
        assertNull("getMessage() must return null.", ucE.getMessage());
        assertNull("getCallback() must return null.", ucE.getCallback());
    } 
 
    /** 
     * javax.security.auth.callback.UnsupportedCallbackExceptionTest#UnsupportedCallbackException(Callback callback, String msg) 
     * Assertion: constructs with null callback parameter and not null message. 
     */ 
    public void testUnsupportedCallbackException04() { 
        UnsupportedCallbackException ucE;
        for (int i = 0; i < msgs.length; i++) {
            ucE = new UnsupportedCallbackException(null, msgs[i]);
            assertEquals("getMessage() must return: ".concat(msgs[i]), ucE.getMessage(), msgs[i]);
            assertNull("getCallback() must return null.", ucE.getCallback());
5
CodeRank
This code example shows how to use the following methods:
            UnsupportedCallbackException { 
        if (callback == null) { 
            throw new UnsupportedCallbackException(null, "callback is null"); 
        } 
        if (callback.length == 0) { 
            throw new UnsupportedCallbackException(null, "callback is empty"); 
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
        try { 
            this.callbackHandler.handle(callbacks);
        } catch (IOException e) {
            throw new LoginException(e.getMessage());
        } catch (UnsupportedCallbackException e) {
            throw new LoginException(e.getMessage());
        } 
        String userName = nameCallback.getName();
        String password = new String(passwordCallback.getPassword());
        if (!TESTUSER.equals(userName)) {
            throw new LoginException("wrong username");
        } 
        if (!TESTPASS.equals(password)) {
            throw new LoginException("wrong password");
        } 
        subject.getPrincipals().add(new SimplePrincipal(userName));
        subject.getPrincipals().add(new SimpleGroup(TESTGROUP));
        return true; 
    } 
 
4
CodeRank
This code example shows how to use the following methods:getMessage
This code example shows how to use the following methods:getMessage
        try { 
            handler.handle(new Callback[] { mockNameCallback,
                    mockPasswordCallback });
        } 
        catch (final UnsupportedCallbackException e) {
            fail(e.getMessage());
        } 
 
        verify(mockNameCallback, mockPasswordCallback);
    } 
 
    /** 
     * Test method for {@link CredentialsCallbackHandler#handle(Callback[])}. 
     */ 
    @Test
    public void testHandleWithNameCallback() { 
        final Credential c = Credential.builder().userName("foo")
                .password("bar".toCharArray()).build();
 
        final NameCallback mockCallback = createMock(NameCallback.class);
3
CodeRank
See Code Examples for Java 8 UnsupportedCallbackException Methods: