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 F1629102B6 for ; Thu, 18 Apr 2013 15:58:34 +0000 (UTC) Received: (qmail 59121 invoked by uid 500); 18 Apr 2013 15:58:34 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 59056 invoked by uid 500); 18 Apr 2013 15:58:34 -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 58926 invoked by uid 99); 18 Apr 2013 15:58:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Apr 2013 15:58:33 +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, 18 Apr 2013 15:58:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BC3712388A36; Thu, 18 Apr 2013 15:58:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1469391 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/TokenProvider.java Date: Thu, 18 Apr 2013 15:58:11 -0000 To: oak-commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130418155811.BC3712388A36@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: angela Date: Thu Apr 18 15:58:11 2013 New Revision: 1469391 URL: http://svn.apache.org/r1469391 Log: OAK-91 : Implement Authentication Support (javadoc, annotations) Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/TokenProvider.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/TokenProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/TokenProvider.java?rev=1469391&r1=1469390&r2=1469391&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/TokenProvider.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/TokenProvider.java Thu Apr 18 15:58:11 2013 @@ -18,10 +18,11 @@ package org.apache.jackrabbit.oak.spi.se import java.util.Map; import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; import javax.jcr.Credentials; /** - * TokenProvider... TODO + * Interface to manage create and manage login tokens. */ public interface TokenProvider { @@ -39,18 +40,71 @@ public interface TokenProvider { */ String PARAM_TOKEN_LENGTH = "tokenLength"; - boolean doCreateToken(Credentials credentials); + /** + * Returns {@code true} if the given credentials indicate that a new token + * needs to be issued. + * + * @param credentials The current credentials. + * @return {@code true} if a new login token needs to be created, {@code false} otherwise. + */ + boolean doCreateToken(@Nonnull Credentials credentials); + /** + * Issues a new login token for the user with the specified credentials + * and returns the associated {@code TokenInfo}. + * + * @param credentials The current credentials. + * @return The {@code TokenInfo} associated with the new login token or + * {@code null} if no token has been created. + */ @CheckForNull - TokenInfo createToken(Credentials credentials); + TokenInfo createToken(@Nonnull Credentials credentials); + /** + * Issues a new login token for the user with the given {@code userId} + * and the specified attributes. + * + * @param userId The identifier of the user for which a new token should + * be created. + * @param attributes The attributes associated with the new token. + * @return The {@code TokenInfo} associated with the new login token or + * {@code null} if no token has been created. + */ @CheckForNull - TokenInfo createToken(String userId, Map attributes); + TokenInfo createToken(@Nonnull String userId, @Nonnull Map attributes); + /** + * Retrieves the {@code TokenInfo} associated with the specified login token + * or {@code null}. + * + * @param token A valid login token. + * @return the {@code TokenInfo} associated with the specified login token + * or {@code null}. + */ @CheckForNull - TokenInfo getTokenInfo(String token); + TokenInfo getTokenInfo(@Nonnull String token); - boolean removeToken(TokenInfo tokenInfo); + /** + * Tries to remove the login token and all related information. This method + * returns {@code true} if the removal was successful. + * + * @param tokenInfo The {@code TokenInfo} associated with the login token to + * be removed. + * @return {@code true} if the removal was successful, {@code false} otherwise. + */ + boolean removeToken(@Nonnull TokenInfo tokenInfo); - boolean resetTokenExpiration(TokenInfo tokenInfo, long loginTime); + /** + * Resets the expiration time of the login token associated with the given + * {@code TokenInfo}. Whether and when the expiration time of a given login + * token is being reset is an implementation detail. Implementations that + * don't allow for resetting the token's expiration time at all will always + * return {@code false}. + * + * @param tokenInfo The {@code TokenInfo} associated with the login token to + * be reset. + * @param loginTime The current login time. + * @return {@code true} if the expiration time has been reset, false otherwise. + */ + boolean resetTokenExpiration(@Nonnull TokenInfo tokenInfo, long loginTime); }