001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/ds/resource/legal-notices/cddl.txt
011     * or http://www.opensource.org/licenses/cddl1.php.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/ds/resource/legal-notices/cddl.txt.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2010-2014 UnboundID Corp.
026     */
027    package com.unboundid.directory.sdk.broker.types;
028    
029    import com.unboundid.util.Mutable;
030    import com.unboundid.util.NotExtensible;
031    import com.unboundid.util.ThreadSafety;
032    import com.unboundid.util.ThreadSafetyLevel;
033    
034    import java.util.Date;
035    import java.util.Set;
036    
037    /**
038     * This class provides a data structure for working with OAuth2 refresh tokens.
039     */
040    @NotExtensible()
041    @Mutable()
042    @ThreadSafety(level= ThreadSafetyLevel.COMPLETELY_THREADSAFE)
043    public final class RefreshToken extends Token
044    {
045      /**
046       * Construct a new refresh token instance.
047       *
048       * @param applicationId The application ID with which this token is
049       *                      associated. Must not be null.
050       * @param generateTimestamp The time that this token was generated. Must not
051       *                          be null.
052       * @param maxValiditySeconds The maximum length of time in seconds that this
053       *                           token will be considered valid. Must not be null
054       *                           and must not be negative.
055       * @param scopeIds The set of scopes for which the client has been authorized.
056       *                 Must not be null.
057       */
058      public RefreshToken(final String applicationId, final Date generateTimestamp,
059                          final long maxValiditySeconds, final Set<String> scopeIds)
060      {
061        super(applicationId, scopeIds, generateTimestamp, maxValiditySeconds);
062      }
063    
064      /**
065       * Appends a string representation of this refresh token to the provided
066       * buffer.
067       *
068       * @param  buffer  The buffer to which the string representation should be
069       *                 appended.
070       */
071      protected void toString(final StringBuilder buffer)
072      {
073        buffer.append("RefreshToken(generateTimestamp=");
074        buffer.append(getGenerateTimestamp());
075        buffer.append(", maxValiditySeconds=");
076        buffer.append(getMaxValiditySeconds());
077        buffer.append(", value=");
078        buffer.append(getValue());
079        buffer.append("')");
080      }
081    }