Package org.apache.geronimo.security.jaas

Examples of org.apache.geronimo.security.jaas.NamedUsernamePasswordCredential


                throw new IllegalStateException("Subject missing but authentication turned on");
            } else {
                Set creds = subject.getPrivateCredentials(NamedUsernamePasswordCredential.class);
                boolean found = false;
                for (Iterator iterator = creds.iterator(); iterator.hasNext();) {
                    NamedUsernamePasswordCredential namedUsernamePasswordCredential = (NamedUsernamePasswordCredential) iterator.next();
                    if (credentialsName.equals(namedUsernamePasswordCredential.getName())) {
                        call.setUsername(namedUsernamePasswordCredential.getUsername());
                        call.setPassword(new String(namedUsernamePasswordCredential.getPassword()));
                        found = true;
                        break;
                    }
                }
                if (!found) {
View Full Code Here


                throw new IllegalStateException("Subject missing but authentication turned on");
            } else {
                Set creds = subject.getPrivateCredentials(NamedUsernamePasswordCredential.class);
                boolean found = false;
                for (Iterator iterator = creds.iterator(); iterator.hasNext();) {
                    NamedUsernamePasswordCredential namedUsernamePasswordCredential = (NamedUsernamePasswordCredential) iterator.next();
                    if (credentialsName.equals(namedUsernamePasswordCredential.getName())) {
                        call.setUsername(namedUsernamePasswordCredential.getUsername());
                        call.setPassword(new String(namedUsernamePasswordCredential.getPassword()));
                        found = true;
                        break;
                    }
                }
                if (!found) {
View Full Code Here

        GerNamedUsernamePasswordCredentialType[] namedCredentials = defaultPrincipalType.getNamedUsernamePasswordCredentialArray();
        if (namedCredentials.length > 0) {
            Set defaultCredentialSet = new HashSet();
            for (int i = 0; i < namedCredentials.length; i++) {
                GerNamedUsernamePasswordCredentialType namedCredentialType = namedCredentials[i];
                NamedUsernamePasswordCredential namedCredential = new NamedUsernamePasswordCredential(namedCredentialType.getUsername(), namedCredentialType.getPassword().toCharArray(), namedCredentialType.getName());
                defaultCredentialSet.add(namedCredential);
            }
            defaultPrincipal.setNamedUserPasswordCredentials(defaultCredentialSet);
        }
        return defaultPrincipal;
View Full Code Here

    }

    public void testParsingOne() throws Exception {
        loginModule.parseCredentials("foo:bar=baz", passwordCredentials);
        assertEquals(1, passwordCredentials.size());
        NamedUsernamePasswordCredential cred = passwordCredentials.iterator().next();
        checkCredential(cred, "foo", "bar", "baz");
    }
View Full Code Here

    }
    public void testParsingTwo() throws Exception {
        loginModule.parseCredentials("foo:bar=baz,foo2:bar2=baz2", passwordCredentials);
        assertEquals(2, passwordCredentials.size());
        Iterator<NamedUsernamePasswordCredential> iterator = passwordCredentials.iterator();
        NamedUsernamePasswordCredential cred = iterator.next();
        checkCredential(cred, "foo", "bar", "baz");
        cred = iterator.next();
        checkCredential(cred, "foo2", "bar2", "baz2");
    }
View Full Code Here

        GerNamedUsernamePasswordCredentialType[] namedCredentials = defaultPrincipalType.getNamedUsernamePasswordCredentialArray();
        if (namedCredentials.length > 0) {
            Set defaultCredentialSet = new HashSet();
            for (int i = 0; i < namedCredentials.length; i++) {
                GerNamedUsernamePasswordCredentialType namedCredentialType = namedCredentials[i];
                NamedUsernamePasswordCredential namedCredential = new NamedUsernamePasswordCredential(namedCredentialType.getUsername().trim(), namedCredentialType.getPassword().trim().toCharArray(), namedCredentialType.getName().trim());
                defaultCredentialSet.add(namedCredential);
            }
            defaultPrincipal.setNamedUserPasswordCredentials(defaultCredentialSet);
        }
        return defaultPrincipal;
View Full Code Here

                throw new IllegalStateException("Subject missing but authentication turned on");
            } else {
                Set creds = subject.getPrivateCredentials(NamedUsernamePasswordCredential.class);
                boolean found = false;
                for (Iterator iterator = creds.iterator(); iterator.hasNext();) {
                    NamedUsernamePasswordCredential namedUsernamePasswordCredential = (NamedUsernamePasswordCredential) iterator.next();
                    if (credentialsName.equals(namedUsernamePasswordCredential.getName())) {
                        call.setUsername(namedUsernamePasswordCredential.getUsername());
                        call.setPassword(new String(namedUsernamePasswordCredential.getPassword()));
                        found = true;
                        break;
                    }
                }
                if (!found) {
View Full Code Here

        assertTrue("expected non-null subject", subject != null);
        assertEquals("Principals", 0, subject.getPrincipals().size());
        assertEquals("Private credentials", 1, subject.getPrivateCredentials().size());
        assertEquals("NamedUsernamePasswordCredential private credentials", 1, subject.getPrivateCredentials(NamedUsernamePasswordCredential.class).size());
        assertEquals("Public credentials", 0, subject.getPublicCredentials().size());
        NamedUsernamePasswordCredential namedupc = (NamedUsernamePasswordCredential) subject.getPrivateCredentials().toArray()[0];
        assertEquals("Credential name", "cred1", namedupc.getName());
        assertEquals("Username", "name1", namedupc.getUsername());
        assertEquals("Password", "pwd1", new String(namedupc.getPassword()));

        context.logout();

        assertEquals("Private credentials upon logout", 0, subject.getPrivateCredentials().size());
        assertTrue("id of server subject should be null", ContextManager.getSubjectId(subject) == null);
View Full Code Here

        try {
            context.logout();
        } catch(Exception e) {
            fail("logout failed");
        }
        NamedUsernamePasswordCredential namedupc = (NamedUsernamePasswordCredential) subject.getPrivateCredentials().toArray()[0];
        assertTrue("credential should have been destroyed", namedupc.isDestroyed());
    }
View Full Code Here

        String username = ((NameCallback) callbacks[0]).getName();
        char[] password = ((PasswordCallback) callbacks[1]).getPassword();

        if (username == null || password == null) return false;

        nupCredential = new NamedUsernamePasswordCredential(username, password, name);

        return false;
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.security.jaas.NamedUsernamePasswordCredential

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.