<commit_before>/**
 * Original work: SecureSocial (https://github.com/jaliss/securesocial)
 * Copyright 2013 <NAME> (jaliss at gmail dot com) - twitter: @jaliss
 *
 * Derivative work: Silhouette (https://github.com/mohiva/play-silhouette)
 * Modifications Copyright 2015 Mohiva Organisation (license at mohiva dot com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mohiva.play.silhouette.api.services

import com.mohiva.play.silhouette.api.util.{ ExtractableRequest, ExecutionContextProvider }
import com.mohiva.play.silhouette.api.{ Authenticator, LoginInfo }
import play.api.http.HttpEntity
import play.api.mvc._

import scala.concurrent.Future

/**
 * A marker result which indicates that an operation on an authenticator was processed and
 * therefore it shouldn't updated automatically.
 *
 * Due the fact that the update method gets called on every subsequent request to update the
 * authenticator related data in the backing store and in the result, it isn't possible to
 * discard or renew the authenticator simultaneously. This is because the "update" method would
 * override the result created by the "renew" or "discard" method, because it will be executed
 * as last in the chain.
 *
 * As example:
 * If we discard the session in a Silhouette action then it will be removed from session. But
 * at the end the update method will embed the session again, because it gets called with the
 * result of the action.
 *
 * @param result The result to wrap.
 */
class AuthenticatorResult(result: Result)
  extends Result(result.header, result.body, result.newSession, result.newFlash, result.newCookies) {

  /**
   * Creates a new copy of a `AuthenticatorResult`.
   *
   * @param header     The response header, which contains status code and HTTP headers.
   * @param body       The response body.
   * @param newSession A new session.
   * @param newFlash   A new flash.
   * @param newCookies Some new cookies.
   * @return A copy of a `AuthenticatorResult`.
   */
  override def copy(
    header: ResponseHeader,
    body: HttpEntity,
    newSession: Option[Session] = None,
    newFlash: Option[Flash] = None,
    newCookies: Seq[Cookie] = Seq.empty
  ) = {
    AuthenticatorResult(super.copy(header, body, newSession, newFlash, newCookies))
  }
}

/**
 * The companion object.<commit_msg>Providing default for copy leads to emptying out of parameters, so removing these. (#517)<commit_after>/**
 * Original work: SecureSocial (https://github.com/jaliss/securesocial)
 * Copyright 2013 <NAME> (jaliss at gmail dot com) - twitter: @jaliss
 *
 * Derivative work: Silhouette (https://github.com/mohiva/play-silhouette)
 * Modifications Copyright 2015 Mohiva Organisation (license at mohiva dot com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mohiva.play.silhouette.api.services

import com.mohiva.play.silhouette.api.util.{ ExtractableRequest, ExecutionContextProvider }
import com.mohiva.play.silhouette.api.{ Authenticator, LoginInfo }
import play.api.http.HttpEntity
import play.api.mvc._

import scala.concurrent.Future

/**
 * A marker result which indicates that an operation on an authenticator was processed and
 * therefore it shouldn't updated automatically.
 *
 * Due the fact that the update method gets called on every subsequent request to update the
 * authenticator related data in the backing store and in the result, it isn't possible to
 * discard or renew the authenticator simultaneously. This is because the "update" method would
 * override the result created by the "renew" or "discard" method, because it will be executed
 * as last in the chain.
 *
 * As example:
 * If we discard the session in a Silhouette action then it will be removed from session. But
 * at the end the update method will embed the session again, because it gets called with the
 * result of the action.
 *
 * @param result The result to wrap.
 */
class AuthenticatorResult(result: Result)
  extends Result(result.header, result.body, result.newSession, result.newFlash, result.newCookies) {

  /**
   * Creates a new copy of a `AuthenticatorResult`.
   *
   * @param header     The response header, which contains status code and HTTP headers.
   * @param body       The response body.
   * @param newSession A new session.
   * @param newFlash   A new flash.
   * @param newCookies Some new cookies.
   * @return A copy of a `AuthenticatorResult`.
   */
  override def copy(
    header: ResponseHeader,
    body: HttpEntity,
    newSession: Option[Session],
    newFlash: Option[Flash],
    newCookies: Seq[Cookie]
  ) = {
    AuthenticatorResult(super.copy(header, body, newSession, newFlash, newCookies))
  }
}

/**
 * The companion object.
{'fraction_non_alphanumeric': 0.08102905145257262, 'fraction_numerical': 0.004725236261813091, 'mean_word_length': 3.8846153846153846, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4743864', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1550, 'n_words': 669}