Best code examples for Java 8 Subject class (javax.security.auth.Subject)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Subject class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 Subject examples from Open Source projects
This code example shows how to use the following methods:
        UserInfo userInfo = channel.getConnection().getUserInfo(); 
        final Subject subject; 
        if (userInfo instanceof SubjectUserInfo) { 
            subject = ((SubjectUserInfo) userInfo).getSubject(); 
        } else { 
            subject = new Subject(); 
        } 
 
        handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler, subject)); 
 
        channel.receiveMessage(handler.getReceiver()); 
        return handler; 
    } 
} 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getPrincipals
    public String getUserName() {
        return userName;
    } 
 
    public Collection<Principal> getPrincipals() {
        return subject.getPrincipals();
    } 
 
    public Subject getSubject() {
        return subject;
    } 
 
} 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getPrincipals, getPrivateCredentials
 
        options.put("cacheAssertions", "true");
        options.put("cacheTimeout", "1");
 
        server.content = SUCCESS_RESPONSE.getBytes(server.encoding);
        module.initialize(
                subject,
                new ServiceAndTicketCallbackHandler(SERVICE, TICKET),
                new HashMap<String, Object>(),
                options);
        module.login();
        module.commit();
        assertEquals(this.subject.getPrincipals().size(), 3);
        assertEquals(TICKET, this.subject.getPrivateCredentials().iterator().next().toString());
 
        // Logout should destroy all authenticated state data including assertion cache entries 
        module.logout();
        assertEquals(0, subject.getPrincipals().size());
        assertEquals(0, subject.getPrivateCredentials().size());
        server.content = FAILURE_RESPONSE.getBytes(server.encoding);

7
CodeRank
This code example shows how to use the following methods: getPrincipals, getPrivateCredentials
			return false; 
		} 
 
		Subject subject = getSubject();
 
		Set<Principal> principals = subject.getPrincipals();
 
		principals.add(getPrincipal());
 
		Set<Object> privateCredentials = subject.getPrivateCredentials();
 
		privateCredentials.add(getPassword()); 
 
		try { 
			Principal group = (Principal)InstanceFactory.newInstance(
				_JGROUP, String.class, "Roles");
			Object role = InstanceFactory.newInstance( 
				_JROLE, String.class, "users");
 
			MethodKey methodKey = new MethodKey(
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getPrincipals, getPrivateCredentials, getPublicCredentials
    /** 
     * javax.security.auth.Subject#Subject() 
     */ 
    public void test_Constructor_01() { 
        try { 
            Subject s = new Subject();
            assertNotNull("Null object returned", s);
            assertTrue("Set of principal is not empty", s.getPrincipals().isEmpty());
            assertTrue("Set of private credentials is not empty", s.getPrivateCredentials().isEmpty());
            assertTrue("Set of public credentials is not empty", s.getPublicCredentials().isEmpty());
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        } 
    } 
 
    /** 
     * javax.security.auth.Subject#doAs(Subject subject, PrivilegedAction action) 
     */ 
    public void test_doAs_01() { 
        Subject subj = new Subject();
Full Snippet Info
7
CodeRank
See Code Examples for Java 8 Subject Methods: