GVKun编程网logo

TokenBasedRememberMeServices cookie加密解密(token的加密)

42

这篇文章主要围绕TokenBasedRememberMeServicescookie加密解密和token的加密展开,旨在为您提供一份详细的参考资料。我们将全面介绍TokenBasedRememberM

这篇文章主要围绕TokenBasedRememberMeServices cookie加密解密token的加密展开,旨在为您提供一份详细的参考资料。我们将全面介绍TokenBasedRememberMeServices cookie加密解密的优缺点,解答token的加密的相关问题,同时也会为您带来"Remember Monica: they''re just cookies, not love!"、android – Firebase Messaging Inactivity,断开与AppMeasurementService的连接[复制]、android – Gradle sync失败 – play-services-measurement-base、Angular ngx-cookie-service 不在 iframe 中创建 cookie的实用方法。

本文目录一览:

TokenBasedRememberMeServices cookie加密解密(token的加密)

TokenBasedRememberMeServices cookie加密解密(token的加密)

TokenBasedRememberMeServices.java :  » Security » acegi-security » org » acegisecurity » ui » rememberme » Java Open Source
Java Open Source » Security » acegi security	 	
acegi security » org » acegisecurity » ui » rememberme » TokenBasedRememberMeServices.java

/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 *
 * 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 org.acegisecurity.ui.rememberme;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.acegisecurity.Authentication;
import org.acegisecurity.providers.rememberme.RememberMeAuthenticationToken;
import org.acegisecurity.ui.AccessDeniedHandler;
import org.acegisecurity.ui.AuthenticationDetailsSource;
import org.acegisecurity.ui.AuthenticationDetailsSourceImpl;
import org.acegisecurity.ui.logout.LogoutHandler;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.RequestUtils;

/**
 * Identifies previously remembered users by a Base-64 encoded cookie.
 * 
 * <p>
 * This implementation does not rely on an external database, so is attractive
 * for simple applications. The cookie will be valid for a specific period from
 * the date of the last
 * {@link #loginSuccess(HttpServletRequest, HttpServletResponse, Authentication)}.
 * As per the interface contract, this method will only be called when the
 * principal completes a successful interactive authentication. As such the time
 * period commences from the last authentication attempt where they furnished
 * credentials - not the time period they last logged in via remember-me. The
 * implementation will only send a remember-me token if the parameter defined by
 * {@link #setParameter(String)} is present.
 * </p>
 * 
 * <p>
 * An {@link org.acegisecurity.userdetails.UserDetailsService} is required by
 * this implementation, so that it can construct a valid
 * <code>Authentication</code> from the returned {@link
 * org.acegisecurity.userdetails.UserDetails}. This is also necessary so that
 * the user''s password is available and can be checked as part of the encoded
 * cookie.
 * </p>
 * 
 * <p>
 * The cookie encoded by this implementation adopts the following form:
 * 
 * <pre>
 * username + ":" + expiryTime + ":" + Md5Hex(username + ":" + expiryTime + ":" + password + ":" + key)
 * </pre>
 * 
 * </p>
 * <p>
 * As such, if the user changes their password any remember-me token will be
 * invalidated. Equally, the system administrator may invalidate every
 * remember-me token on issue by changing the key. This provides some reasonable
 * approaches to recovering from a remember-me token being left on a public
 * machine (eg kiosk system, Internet cafe etc). Most importantly, at no time is
 * the user''s password ever sent to the user agent, providing an important
 * security safeguard. Unfortunately the username is necessary in this
 * implementation (as we do not want to rely on a database for remember-me
 * services) and as such high security applications should be aware of this
 * occasionally undesired disclosure of a valid username.
 * </p>
 * <p>
 * This is a basic remember-me implementation which is suitable for many
 * applications. However, we recommend a database-based implementation if you
 * require a more secure remember-me approach.
 * </p>
 * <p>
 * By default the tokens will be valid for 14 days from the last successful
 * authentication attempt. This can be changed using
 * {@link #setTokenValiditySeconds(long)}.
 * </p>
 * 
 * @author Ben Alex
 * @version $Id: TokenBasedRememberMeServices.java 1871 2007-05-25 03:12:49Z
 * benalex $
 */
public class TokenBasedRememberMeServices implements RememberMeServices, InitializingBean, LogoutHandler {
  // ~ Static fields/initializers
  // =====================================================================================

  public static final String ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY = "ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE";

  public static final String DEFAULT_PARAMETER = "_acegi_security_remember_me";

  protected static final Log logger = LogFactory.getLog(TokenBasedRememberMeServices.class);

  // ~ Instance fields
  // ================================================================================================

  protected AuthenticationDetailsSource authenticationDetailsSource = new AuthenticationDetailsSourceImpl();

  private String key;

  private String parameter = DEFAULT_PARAMETER;

  private UserDetailsService userDetailsService;

  protected long tokenValiditySeconds = 1209600; // 14 days

  private boolean alwaysRemember = false;

  private static final int DEFAULT_ORDER = Integer.MAX_VALUE; // ~ default

  private String cookieName = ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY;

  // ~ Methods
  // ========================================================================================================

  public void afterPropertiesSet() throws Exception {
    Assert.hasLength(key);
    Assert.hasLength(parameter);
    Assert.hasLength(cookieName);
    Assert.notNull(userDetailsService);
  }

  /**
   * Introspects the <code>Applicationcontext</code> for the single instance
   * of {@link AccessDeniedHandler}. If found invoke
   * setAccessDeniedHandler(AccessDeniedHandler accessDeniedHandler) method by
   * providing the found instance of accessDeniedHandler as a method
   * parameter. If more than one instance of <code>AccessDeniedHandler</code>
   * is found, the method throws <code>IllegalStateException</code>.
   * 
   * @param applicationContext to locate the instance
   */
  private void autoDetectAndUseAnyUserDetailsService(ApplicationContext applicationContext) {
    Map map = applicationContext.getBeansOfType(UserDetailsService.class);
    if (map.size() > 1) {
      throw new IllegalArgumentException(
          "More than one UserDetailsService beans detected please refer to the one using "
              + " [ principalRepositoryBeanRef  ] " + "attribute");
    }
    else if (map.size() == 1) {
      setUserDetailsService((UserDetailsService) map.values().iterator().next());
    }
  }

  public Authentication autoLogin(HttpServletRequest request, HttpServletResponse response) {
    Cookie[] cookies = request.getCookies();

    if ((cookies == null) || (cookies.length == 0)) {
      return null;
    }

    for (int i = 0; i < cookies.length; i++) {
      if (cookieName.equals(cookies[i].getName())) {
        String cookieValue = cookies[i].getValue();

        for (int j = 0; j < cookieValue.length() % 4; j++) {
          cookieValue = cookieValue + "=";
        }

        if (Base64.isArrayByteBase64(cookieValue.getBytes())) {
          if (logger.isDebugEnabled()) {
            logger.debug("Remember-me cookie detected");
          }

          // Decode token from Base64
          // format of token is:
          // username + ":" + expiryTime + ":" +
          // Md5Hex(username + ":" + expiryTime + ":" + password + ":"
          // + key)
          String cookieAsPlainText = new String(Base64.decodeBase64(cookieValue.getBytes()));
          String[] cookieTokens = StringUtils.delimitedListToStringArray(cookieAsPlainText, ":");

          if (cookieTokens.length == 3) {

            long tokenExpiryTime;

            try {
              tokenExpiryTime = new Long(cookieTokens[1]).longValue();
            }
            catch (NumberFormatException nfe) {
              cancelCookie(request, response,
                  "Cookie token[1] did not contain a valid number (contained ''" + cookieTokens[1]
                      + "'')");

              return null;
            }

            if (isTokenExpired(tokenExpiryTime)) {
              cancelCookie(request, response, "Cookie token[1] has expired (expired on ''"
                  + new Date(tokenExpiryTime) + "''; current time is ''" + new Date() + "'')");

              return null;
            }

            // Check the user exists
            // Defer lookup until after expiry time checked, to
            // possibly avoid expensive lookup
            UserDetails userDetails = loadUserDetails(request, response, cookieTokens);

            if (userDetails == null) {
              cancelCookie(request, response, "Cookie token[0] contained username ''" + cookieTokens[0]
                  + "'' but was not found");
              return null;
            }

            if (!isValidUserDetails(request, response, userDetails, cookieTokens)) {
              return null;
            }

            // Check signature of token matches remaining details
            // Must do this after user lookup, as we need the
            // DAO-derived password
            // If efficiency was a major issue, just add in a
            // UserCache implementation,
            // but recall this method is usually only called one per
            // HttpSession
            // (as if the token is valid, it will cause
            // SecurityContextHolder population, whilst
            // if invalid, will cause the cookie to be cancelled)
            String expectedTokenSignature = makeTokenSignature(tokenExpiryTime, userDetails);

            if (!expectedTokenSignature.equals(cookieTokens[2])) {
              cancelCookie(request, response, "Cookie token[2] contained signature ''" + cookieTokens[2]
                  + "'' but expected ''" + expectedTokenSignature + "''");

              return null;
            }

            // By this stage we have a valid token
            if (logger.isDebugEnabled()) {
              logger.debug("Remember-me cookie accepted");
            }

            RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken(this.key, userDetails,
                userDetails.getAuthorities());
            auth.setDetails(authenticationDetailsSource.buildDetails((HttpServletRequest) request));

            return auth;
          }
          else {
            cancelCookie(request, response, "Cookie token did not contain 3 tokens; decoded value was ''"
                + cookieAsPlainText + "''");

            return null;
          }
        }
        else {
          cancelCookie(request, response, "Cookie token was not Base64 encoded; value was ''" + cookieValue
              + "''");

          return null;
        }
      }
    }

    return null;
  }

  /**
   * @param tokenExpiryTime
   * @param userDetails
   * @return
   */
  protected String makeTokenSignature(long tokenExpiryTime, UserDetails userDetails) {
    String expectedTokenSignature = DigestUtils.md5Hex(userDetails.getUsername() + ":" + tokenExpiryTime + ":"
        + userDetails.getPassword() + ":" + this.key);
    return expectedTokenSignature;
  }

  protected boolean isValidUserDetails(HttpServletRequest request, HttpServletResponse response,
      UserDetails userDetails, String[] cookieTokens) {
    // Immediately reject if the user is not allowed to
    // login
    if (!userDetails.isAccountNonExpired() || !userDetails.isCredentialsNonExpired() || !userDetails.isEnabled()) {
      cancelCookie(request, response, "Cookie token[0] contained username ''" + cookieTokens[0]
          + "'' but account has expired, credentials have expired, or user is disabled");

      return false;
    }
    return true;
  }

  protected UserDetails loadUserDetails(HttpServletRequest request, HttpServletResponse response,
      String[] cookieTokens) {
    UserDetails userDetails = null;

    try {
      userDetails = this.userDetailsService.loadUserByUsername(cookieTokens[0]);
    }
    catch (UsernameNotFoundException notFound) {
      cancelCookie(request, response, "Cookie token[0] contained username ''" + cookieTokens[0]
          + "'' but was not found");

      return null;
    }
    return userDetails;
  }

  protected boolean isTokenExpired(long tokenExpiryTime) {
    // Check it has not expired
    if (tokenExpiryTime < System.currentTimeMillis()) {
      return true;
    }
    return false;
  }

  protected void cancelCookie(HttpServletRequest request, HttpServletResponse response, String reasonForLog) {
    if ((reasonForLog != null) && logger.isDebugEnabled()) {
      logger.debug("Cancelling cookie for reason: " + reasonForLog);
    }

    response.addCookie(makeCancelCookie(request));
  }

  public String getKey() {
    return key;
  }

  public String getParameter() {
    return parameter;
  }

  public long getTokenValiditySeconds() {
    return tokenValiditySeconds;
  }

  public UserDetailsService getUserDetailsService() {
    return userDetailsService;
  }

  public void loginFail(HttpServletRequest request, HttpServletResponse response) {
    cancelCookie(request, response, "Interactive authentication attempt was unsuccessful");
  }

  protected boolean rememberMeRequested(HttpServletRequest request, String parameter) {
    if (alwaysRemember) {
      return true;
    }

    return RequestUtils.getBooleanParameter(request, parameter, false);
  }

  public void loginSuccess(HttpServletRequest request, HttpServletResponse response,
      Authentication successfulAuthentication) {
    // Exit if the principal hasn''t asked to be remembered
    if (!rememberMeRequested(request, parameter)) {
      if (logger.isDebugEnabled()) {
        logger.debug("Did not send remember-me cookie (principal did not set parameter ''" + this.parameter
            + "'')");
      }

      return;
    }

    // Determine username and password, ensuring empty strings
    Assert.notNull(successfulAuthentication.getPrincipal());
    Assert.notNull(successfulAuthentication.getCredentials());

    String username = retrieveUserName(successfulAuthentication);
    String password = retrievePassword(successfulAuthentication);

    // If unable to find a username and password, just abort as
    // TokenBasedRememberMeServices unable to construct a valid token in
    // this case
    if (!StringUtils.hasLength(username) || !StringUtils.hasLength(password)) {
      return;
    }

    long expiryTime = System.currentTimeMillis() + (tokenValiditySeconds * 1000);

    // construct token to put in cookie; format is:
    // username + ":" + expiryTime + ":" + Md5Hex(username + ":" +
    // expiryTime + ":" + password + ":" + key)
    String signatureValue = DigestUtils.md5Hex(username + ":" + expiryTime + ":" + password + ":" + key);
    String tokenValue = username + ":" + expiryTime + ":" + signatureValue;
    String tokenValueBase64 = new String(Base64.encodeBase64(tokenValue.getBytes()));
    response.addCookie(makeValidCookie(tokenValueBase64, request, tokenValiditySeconds));

    if (logger.isDebugEnabled()) {
      logger
          .debug("Added remember-me cookie for user ''" + username + "'', expiry: ''" + new Date(expiryTime)
              + "''");
    }
  }

  public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
    cancelCookie(request, response, "Logout of user "
        + (authentication == null ? "Unknown" : authentication.getName()));
  }

  protected String retrieveUserName(Authentication successfulAuthentication) {
    if (isInstanceOfUserDetails(successfulAuthentication)) {
      return ((UserDetails) successfulAuthentication.getPrincipal()).getUsername();
    }
    else {
      return successfulAuthentication.getPrincipal().toString();
    }
  }

  protected String retrievePassword(Authentication successfulAuthentication) {
    if (isInstanceOfUserDetails(successfulAuthentication)) {
      return ((UserDetails) successfulAuthentication.getPrincipal()).getPassword();
    }
    else {
      return successfulAuthentication.getCredentials().toString();
    }
  }

  private boolean isInstanceOfUserDetails(Authentication authentication) {
    return authentication.getPrincipal() instanceof UserDetails;
  }

  protected Cookie makeCancelCookie(HttpServletRequest request) {
    Cookie cookie = new Cookie(cookieName, null);
    cookie.setMaxAge(0);
    cookie.setPath(StringUtils.hasLength(request.getContextPath()) ? request.getContextPath() : "/");

    return cookie;
  }

  protected Cookie makeValidCookie(String tokenValueBase64, HttpServletRequest request, long maxAge) {
    Cookie cookie = new Cookie(cookieName, tokenValueBase64);
    cookie.setMaxAge(new Long(maxAge).intValue());
    cookie.setPath(StringUtils.hasLength(request.getContextPath()) ? request.getContextPath() : "/");

    return cookie;
  }

  public void setAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource) {
    Assert.notNull(authenticationDetailsSource, "AuthenticationDetailsSource required");
    this.authenticationDetailsSource = authenticationDetailsSource;
  }

  public void setKey(String key) {
    this.key = key;
  }

  public void setParameter(String parameter) {
    this.parameter = parameter;
  }

  public void setCookieName(String cookieName) {
    this.cookieName = cookieName;
  }

  public void setTokenValiditySeconds(long tokenValiditySeconds) {
    this.tokenValiditySeconds = tokenValiditySeconds;
  }

  public void setUserDetailsService(UserDetailsService userDetailsService) {
    this.userDetailsService = userDetailsService;
  }

  public boolean isAlwaysRemember() {
    return alwaysRemember;
  }

  public void setAlwaysRemember(boolean alwaysRemember) {
    this.alwaysRemember = alwaysRemember;
  }

  public String getCookieName() {
    return cookieName;
  }

}

	

 

"Remember Monica: they''re just cookies, not love!"

一直在想, 手机, 移动. 手机 移动......没完没了. 加上媒体不停地炒作, 但终究是否, 这个概念是否已经结束了呢?

记得去年最火的就是facebook, 以致IT白痴都能说出扎克伯格的名字.

什么是"火"?

游戏火过一段并且有持续或者说坚持下去的迹象, 轻度社交曾经火过一段好日子, 今年则是手机上的单机游戏年. 好像全世界都真的已经连在了一起一样, 美国兴什么, 这边也兴什么.

总是觉得, 互联网上面的概念是没完没了的. 但是这个秋天却似突然安静下来, 并且与经济危机没有半点关系. 甚至, 这个秋天中美两国的大选都好像没什么关系一样. 没有人在乎, 媒体也是轻描淡写一下就过去了. 忍不住WONDER难道互联网就要这么安静下来了?

很多人以为游戏是孤独者的"游戏". 我从来不这么认为, 我认为游戏从来就是重度社交依赖者的"游戏". 它只不过是另一种, 并且是非常强或者说重的社交形式. 这些人都是重度社交渴求者, 他们只能从社交中获得快乐.

轻度社交不是游戏, 它是最典型的安慰剂, 如果说游戏在这一点上还不太明显的话. 有些人有手段没胆量, 有些人则胆量都没有. 轻度社交的就是这种. 大部分玩轻度社交的人都是些缄默症患.

没有正确的价值观, 或者说没有独立的生活, 或者说有观点但是没手段, 或者是有手段但是没胆量. 真正的游戏玩家都不会轻易退出的, 因为那个真的解决了他们的问题; 问题是轻度社交不能. 轻度社交是一个没有结果的东西. 没有真正的结果, 也没有形式上或者说安慰剂意义上的结果, 连阿Q的大任都担当不了, 所以必然被人淘汰.

有两种人: 一种人活在真实世界中, 一种人活在虚拟世界中. 所以注定社交或单机游戏是一场没有结果的戏. Remember, cookies 永远都是Cookies, 不可能变成Love.

前面的结果是因为只有两个世界: 一个真实世界, 一个虚拟世界. 不存在第三个世界. 生活大爆炸里面那个谢耳朵钻了虫洞, 却是自己做的一段视频而已. 其实整个SHOW就是对科学的讽刺, 其全部的内容除了那些为了拼凑内容而硬凑起来的东西外, 剩下的就全部都是对所谓科学的teasing而已. 这也是我为什么一直很尊敬, 或者说至少敬畏, 很多文学家的原因. 文学家有很多种, 比如写书的, 写剧本的, 写歌的,,, 很喜欢这些写东西的人,至少他们没有那么俗. 记得莫言对媒体说他当初写作就是为了糊口, 怎么会有人BUY呢? 所 以说,信则有, 不信则无. 文学是非常诡异的东西, 人的心理是非常诡异的东西, 流行是非常诡异的东西. 人的心理是最难捕捉的东西, 但是文学家们具有这个本事. 他能把你分析得透透彻彻的, 甚至原样呈现出来给你看. 但是那些肤浅的人就会以为你看你看, 我说的没错吧, 就知道他跟我们是一样的. OK,,信则有,不信则无! 愿咋咋地! 毕竟, 谁能把你怎么样叫?

我觉得文学家比心理学家厉害. 我甚至觉得, 心理学这个体系本身也是有问题的, 它是一种从文学的倒退. 是错误的方向. 其实关于人, 我们要研究的最重要的东西就是具体的人. 心理学通过形而上学的方法没错总能总结出一些东西, 但是这些东西, 他们的有效性有多长呢? 比如一首去年流行的歌, 放在今年就不行. 去年流行的产品, 放在今年也不行, 衣服都是按季换的, 我们能总结的永远都是过去, 却并不是将来. 并不是说休谟没有错, 休谟讲对了, 而是说, 心理学决对是个从文学的倒退. 这一点是for sure的. 因为现在的心理学, 其实基本上跟人的大脑关系并不大, 大部分结果都是从人们的日常语言或生活中得到. 只有很少一部分是来自神经学或大脑科学. 大脑科学自己都没有东西, 如何给别人东西?

真正的哲学家, 他们经常存在于你的身边. 他们从来不去尝试认识这个世界, 他们所尝试的都是利用这个世界. 搞认识的都是科学家, 不是哲学家. 真正的哲学家不搞认识, 他们是OVER认识的. 他们利用"科学家"们的认识, 为自己谋利益. 享乐主义者的观点是:我们不是来思考的, 我们是来享受人生的.

中国人全都是哲学家. 至于那些科学家, 总是尝试想成为哲学家, 但是哪有那么容易.

社交游戏是NONSENSE, 从来就只有社交, 有游戏, 没有社交游戏这一说. 这个东西, 如果你能剥离它的光环, 就会发现它是不存在的. 有也只能从属于社交这个概念而不是游戏的概念. 因为它与游戏没关系. 它是一种社交工具, 一咱连安慰剂都不如的东西. 真正的社交工具是什么 ? 是钱. 它怎么可能跟钱竞争呢?没有人斗得过钱.

关于互联网 人们总是有各种各样的信仰. 我查到大概从十年以前就有人做手机联网游戏, 今天我也还没见过有人在手机上玩这样的东西. 为什么?  为什么? ......怎么这么难?

你必须了解人性, 从人性着手. 而不是从技术着手. 从技术着手看运气, 从人性着手才是真正逻辑化, "科学"化的方法. 可是偏偏这些东西不能用科学的方法去解决, 你不能掉进认识论里面去. 一旦掉进去就别想出来.

 

 

android – Firebase Messaging Inactivity,断开与AppMeasurementService的连接[复制]

android – Firebase Messaging Inactivity,断开与AppMeasurementService的连接[复制]

参见英文答案 > V/FA: Processing queued up service tasks: 1 followed by V/FA: Inactivity,disconnecting from AppMeasurementService                                    3个
我试图使用FCM消息向Android模拟器设备发送通知,但我没有得到任何通知.
谷歌应用程序ID与google-services.json中的相同

这是我从控制台得到的:

D / FA:连接到远程服务

V / FA:处理排队的服务任务:1

V / FA:不活动,断开与AppMeasurementService的连接

我的build.gradle(模块:app):

android {
    compileSdkVersion 23
    buildToolsversion "23.0.1"
    defaultConfig {
        applicationId "com.example.cris.firebasenotificationexam"
        minSdkVersion 22
        targetSdkVersion 23

….

dependencies {
    compile filetree(dir: ''libs'',include: [''*.jar''])
    testCompile ''junit:junit:4.12''
    compile ''com.android.support:appcompat-v7:23.4.0''
    apply plugin: ''com.google.gms.google-services''
    compile ''com.google.firebase:firebase-messaging:9.0.2''
}

任何人都知道如何解决这个问题?

解决方法

日志消息:不活动,与AppMeasurementService断开连接是正常的,并不表示是否存在问题.

编辑build.gradle文件的依赖项块:

dependencies {
    compile filetree(dir: ''libs'',include: [''*.jar''])
    testCompile ''junit:junit:4.12''
    compile ''com.android.support:appcompat-v7:23.4.0''
    compile ''com.google.firebase:firebase-messaging:9.0.2''
}

// Moved the following statement.  Was in the dependencies block
apply plugin: ''com.google.gms.google-services''

Firebase Setup Guide中的更多细节.

另外,请考虑使用最新发布的库版本:9.8.0用于firebase-messaging,25.0.1用于appcompat-v7.

android – Gradle sync失败 – play-services-measurement-base

android – Gradle sync失败 – play-services-measurement-base

我的Android项目有问题,我无法构建,这是我的错误:

Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-measurement-base is being requested by varIoUs other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

我尝试了许多不同的解决方案,但问题仍然存在.
我在项目根目录上的gradle文件中有正确的依赖项和存储库:

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:4.0.1'
}

repositories {
    jcenter()
    mavenLocal()
    mavenCentral()
    maven {
        url "https://maven.google.com"
    }
}

在我的应用程序gradle上,我有以下依赖项:

implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-places:15.0.1"
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-analytics:15.0.2"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-tagmanager:15.0.2"
implementation "com.google.firebase:firebase-core:16.0.0"

一些建议?

解决方案是更新以下依赖项:

implementation "com.google.android.gms:play-services-analytics:16.0.0"
implementation "com.google.android.gms:play-services-tagmanager:16.0.0"

解决方法:

我有同样的错误,升级分析是关键:

实施’com.google.android.gms:play-services-analytics:16.0.0′

我知道你认为所有内容都是根据官方网站更新的,但是编写15.0.0并寻找建议会更好.

Angular ngx-cookie-service 不在 iframe 中创建 cookie

如何解决Angular ngx-cookie-service 不在 iframe 中创建 cookie?

我分别在两个不同的域 domain1.com 和 domain2.com 中部署了两个 Angular 应用程序。 当我单独使用时,每个应用都可以正常工作。

但是,如果我将 domain2.com 应用程序作为 iframe 嵌入到 domain1.com 应用程序中,则会为 domain2.com 创建 cookie。

下面是我使用 ngx-cookie-service 的 cookie 代码

this.cookieService.set(''cookieName'',"cookieValue");

我还尝试将 Secure 标志设置为 true 并且 Samesite= None 以相同的行为结束。 我错过了什么??

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

今天关于TokenBasedRememberMeServices cookie加密解密token的加密的讲解已经结束,谢谢您的阅读,如果想了解更多关于"Remember Monica: they''re just cookies, not love!"、android – Firebase Messaging Inactivity,断开与AppMeasurementService的连接[复制]、android – Gradle sync失败 – play-services-measurement-base、Angular ngx-cookie-service 不在 iframe 中创建 cookie的相关知识,请在本站搜索。

本文标签: