Search in sources :

Example 1 with JBossSecurityContext

use of org.jboss.security.plugins.JBossSecurityContext in project teiid by teiid.

the class TestJBossSecurityHelper method testAuthenticate.

public void testAuthenticate() throws Exception {
    Credentials credentials = new Credentials("pass1".toCharArray());
    String domains = "testFile";
    AuthenticationManager authManager = new AuthenticationManager() {

        public String getSecurityDomain() {
            return null;
        }

        public boolean isValid(Principal principal, Object credential, Subject activeSubject) {
            return true;
        }

        public boolean isValid(Principal principal, Object credential) {
            return true;
        }

        @Override
        public Principal getTargetPrincipal(Principal anotherDomainPrincipal, Map<String, Object> contextMap) {
            return null;
        }

        @Override
        public Subject getActiveSubject() {
            return null;
        }

        @Override
        public void logout(Principal arg0, Subject arg1) {
        }
    };
    final SecurityDomainContext securityContext = new SecurityDomainContext(authManager, null, null, null, null, null);
    JBossSecurityHelper ms = buildSecurityHelper(domains, securityContext);
    // $NON-NLS-1$
    Object c = ms.authenticate(domains, "user1", credentials, null);
    // $NON-NLS-1$
    assertTrue(c instanceof JBossSecurityContext);
    assertEquals(domains, ((JBossSecurityContext) c).getSecurityDomain());
}
Also used : AuthenticationManager(org.jboss.security.AuthenticationManager) JBossSecurityContext(org.jboss.security.plugins.JBossSecurityContext) Map(java.util.Map) Credentials(org.teiid.security.Credentials) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal) Subject(javax.security.auth.Subject) SecurityDomainContext(org.jboss.as.security.plugins.SecurityDomainContext)

Aggregations

Principal (java.security.Principal)1 Map (java.util.Map)1 Subject (javax.security.auth.Subject)1 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)1 AuthenticationManager (org.jboss.security.AuthenticationManager)1 SimplePrincipal (org.jboss.security.SimplePrincipal)1 JBossSecurityContext (org.jboss.security.plugins.JBossSecurityContext)1 Credentials (org.teiid.security.Credentials)1