高德地图设置为不受信任的开发者,如何才能设置为受信任的开发者?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高德地图设置为不受信任的开发者,如何才能设置为受信任的开发者?相关的知识,希望对你有一定的参考价值。

  进入设置-通用-描述文件,找到需要你信任的文件,点击信任即可。
建议一定是确定信任的再点击,以免被其他流氓应用趁虚而入。
参考技术A 最简单粗暴的方法就是卸载了重新安装

spring Authentication.setAuthenticated(boolean) java.lang.IllegalArgumentException:无法将此令牌设置为受信任

【中文标题】spring Authentication.setAuthenticated(boolean) java.lang.IllegalArgumentException:无法将此令牌设置为受信任【英文标题】:spring Authentication.setAuthenticated(boolean) java.lang.IllegalArgumentException: Cannot set this token to trusted 【发布时间】:2011-12-29 01:37:50 【问题描述】:

我有以下代码(尝试以编程方式登录用户):

List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
authorities.add(new GrantedAuthorityImpl("ROLE_ADMIN"));
...
User tempUser = new User(correctUsername, 
    correctPassword, 
    true, true, true, true, // logging them in...
    authorities // type is List<GrantedAuthority>
);
...
Authentication authentication 
    = new UsernamePasswordAuthenticationToken(tempUser, authorities);
    // I'm using authorities again (List<GrantedAuthority>)
    // is this the right spot for it?
...
// this is the line causing the error
authentication.setAuthenticated(true);

当我尝试运行时,我得到以下信息:

java.lang.IllegalArgumentException: Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead

请注意,我在UserAuthentication 对象中都使用了GrantedAuthoritys 的authorities 列表。我不确定我应该在哪里使用这些。我正在尝试复制another SO question 的答案,但遇到了上面发布的异常。其他没有完全回答我的问题的类似问题:

How to programmatically log user in with Spring Security 3.1 Programmatically login in a user using spring security

经过一番搜索,我发现最接近答案的是the forum at springsource.org,而那个人使用的是deprecated method,但这是一种类似的方法。如何以编程方式登录用户?

【问题讨论】:

哪一行导致了问题? 最后一个;上面的评论说'这是导致错误的行(authentication.setAuthenticated(true); 【参考方案1】:

您不必显式调用authentication.setAuthenticated(true)(实际上是不允许的)。构造函数会为您执行此操作。

但是,您调用了错误的构造函数。你应该打电话给:

Authentication authentication 
    = new UsernamePasswordAuthenticationToken(tempUser, password, authorities);

检查 javadoc 中的 UsernamePasswordAuthenticationToken。

【讨论】:

太棒了!非常感谢。我能问一下为什么UserUsernamePasswordAuthenticationToken 构造函数都需要一个授权列表吗?无论如何它都有效,所以我会在可以接受的时候接受这个 这里碰巧发生了两个抽象层次的冲突。 UsernamePasswordAuthenticationToken 是实体的具体版本,可能会或可能不会经过身份验证(身份验证)。用户是独立于任何身份验证状态而存在的主体(用户的详细信息)的实现。 遇到同样的问题,假设我需要显式调用setAuthenticated() 方法。 所以意思是调用Authentication authentication = new UsernamePasswordAuthenticationToken(tempUser, password, authority);我可以调用 authentication.isAuthenticated(),它应该返回 TRUE?

以上是关于高德地图设置为不受信任的开发者,如何才能设置为受信任的开发者?的主要内容,如果未能解决你的问题,请参考以下文章

安卓高德地图开发java如何调用js自定义图层

JDK 解决证书不受信异常

高德地图 怎么设置默认显示气泡

在安卓开发中如何在自己设置的经纬度显示到高德地图上中心点

高德地图API如何设置Icon的imageSize?

spring Authentication.setAuthenticated(boolean) java.lang.IllegalArgumentException:无法将此令牌设置为受信任