Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6A0B810920 for ; Thu, 10 Oct 2013 07:50:27 +0000 (UTC) Received: (qmail 79201 invoked by uid 500); 10 Oct 2013 07:50:27 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 79152 invoked by uid 500); 10 Oct 2013 07:50:23 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 78639 invoked by uid 99); 10 Oct 2013 07:50:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 07:50:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 07:50:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7A7CE238896F; Thu, 10 Oct 2013 07:49:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1530868 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/TokenDefaultLoginModuleTest.java Date: Thu, 10 Oct 2013 07:49:58 -0000 To: oak-commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131010074958.7A7CE238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: angela Date: Thu Oct 10 07:49:58 2013 New Revision: 1530868 URL: http://svn.apache.org/r1530868 Log: OAK-91 : authentication (test impersonation with token creation) Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/TokenDefaultLoginModuleTest.java Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/TokenDefaultLoginModuleTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/TokenDefaultLoginModuleTest.java?rev=1530868&r1=1530867&r2=1530868&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/TokenDefaultLoginModuleTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/TokenDefaultLoginModuleTest.java Thu Oct 10 07:49:58 2013 @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authentication; +import java.security.Principal; import java.util.Collections; import javax.jcr.GuestCredentials; import javax.jcr.SimpleCredentials; @@ -28,7 +29,9 @@ import org.apache.jackrabbit.oak.Abstrac import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.security.authentication.token.TokenLoginModule; +import org.apache.jackrabbit.oak.spi.security.authentication.AuthInfoImpl; import org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration; +import org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials; import org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo; import org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider; import org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl; @@ -178,6 +181,29 @@ public class TokenDefaultLoginModuleTest } @Test + public void testTokenCreationAndImpersonation() throws Exception { + ContentSession cs = null; + try { + SimpleCredentials sc = (SimpleCredentials) getAdminCredentials(); + sc.setAttribute(".token", ""); + + ImpersonationCredentials ic = new ImpersonationCredentials(sc, new AuthInfoImpl(((SimpleCredentials) getAdminCredentials()).getUserID(), Collections.emptyMap(), Collections.emptySet())); + cs = login(ic); + + Object token = sc.getAttribute(".token").toString(); + assertNotNull(token); + TokenCredentials tc = new TokenCredentials(token.toString()); + + cs.close(); + cs = login(tc); + } finally { + if (cs != null) { + cs.close(); + } + } + } + + @Test public void testInvalidTokenCredentials() throws Exception { ContentSession cs = null; try {