What is the most secure way to authorize an user in Android?

In my app, user logs in with a web service, and web service returns an Authorization Key. After that point, every request user makes is done with this key. My question is how to securely store this key? I have been storing it in SharedPreferences, but that does not sound very secure to me. You are right using shared preferences is not the approach to follow. You should utilise Android Keys

什么是在Android中授权用户的最安全的方式?

在我的应用程序中,用户使用Web服务登录,Web服务返回授权密钥。 在那之后,用户做出的每个请求都使用此密钥完成。 我的问题是如何安全地存储此密钥? 我一直在SharedPreferences中存储它,但对我来说听起来并不安全。 您正确使用共享偏好不是遵循的方法。 您应该使用Android密钥仓库系统用于任何此类目的,这是首选方法。 Android Keystore系统允许您将密钥存储在容器中,以便从设备中提取更加困难。 一旦密钥存储在

Zuul route from root path

I have some microservices discovered with Eureka. Most of them provide some API. And I have "edge" service called "Gateway service" which is Zuul Proxy actually. The thing is that there is a web application. It was hosted by gateway service for a long time and there was not any problem with that. But right now I need to host this client on separate service behind gateway.

Zuul路径从根路径

我有一些与Eureka一起发现的微服务。 他们大多提供一些API。 我实际上有Zuul Proxy的“边缘”服务叫做“网关服务”。 问题是有一个Web应用程序。 它由网关服务主持了很长时间,并没有任何问题。 但现在我需要在网关后面的单独服务中托管此客户端。 这不是一个问题。 我创建了新的服务并将Web应用程序放在那里。 但事情是Zuul在网关服务上有下一个配置 zuul: ignoredServices: '*' prefix: /api sensitiveHeaders: Cook

How to cast a String value to an Enum value by Class?

This question already has an answer here: Lookup Java enum by string value 23 answers It's actually kind of a pain because of the way Enum is declared. You wouldn't be able to call valueOf with a Class<?> (nor eg a Class<? extends Enum<?>> ). The only way to do it without unchecked casting is to go through getEnumConstants : public boolean tryCast(String value){

如何通过类将字符串值转换为Enum值?

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 这实际上是一种痛苦,因为Enum被宣布的方式。 你不能用Class<?>调用valueOf (也不能用Class<? extends Enum<?>> )。 没有未经检查的转换的唯一方法是通过getEnumConstants : public boolean tryCast(String value){ for(Object o : enumClass.getEnumConstants()) { Enum<?> e = (Enum<?>) o; if(e.

Getting java enum by name

This question already has an answer here: Lookup Java enum by string value 23 answers How can I lookup a Java enum from its String value? 10 answers 每个Java枚举都有方法valueOf(String name) ,它通过名称返回枚举。 MyEnum foo = MyEnum.valueOf("TOTO"); MyEnum bar = MyEnum.valueOf("ZOZO");

通过名称获取Java枚举

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 我如何从它的字符串值查找Java枚举? 10个答案 每个Java枚举都有方法valueOf(String name) ,它通过名称返回枚举。 MyEnum foo = MyEnum.valueOf("TOTO"); MyEnum bar = MyEnum.valueOf("ZOZO");

Converting String to enum

This question already has an answer here: Lookup Java enum by string value 23 answers Day day = Day.valueOf("SUNDAY");

将字符串转换为枚举

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 Day day = Day.valueOf("SUNDAY");

Java create enum from String

This question already has an answer here: Lookup Java enum by string value 23 answers 添加并使用这种方法public static PaymentType parse(String type) { for (PaymentType paymentType : PaymentType.values()) { if (paymentType.getType().equals(type)) { return paymentType; } } return null; //or you can throw exception } Enum does not have ready to use method

Java从String创建枚举

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 添加并使用这种方法public static PaymentType parse(String type) { for (PaymentType paymentType : PaymentType.values()) { if (paymentType.getType().equals(type)) { return paymentType; } } return null; //or you can throw exception } 枚举没有准备好使用此方法。 您或者需要使用确切的字段名称: Pay

How do I use enums together with command line arguments?

This question already has an answer here: Lookup Java enum by string value 23 answers Try: public static void main(String[] args) { try { App argArg = App.valueOf(args[0]); ENV argENV = ENV.valueOf(args[1]); } catch(IllegalArgumentException e) { printHelp(); System.exit(1); } ... } In printHelp() you can list all possible values with: StringB

如何将命令行参数与枚举一起使用?

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 尝试: public static void main(String[] args) { try { App argArg = App.valueOf(args[0]); ENV argENV = ENV.valueOf(args[1]); } catch(IllegalArgumentException e) { printHelp(); System.exit(1); } ... } 在printHelp()你可以列出所有可能的值: StringBuffer appParamHelp = new StringBuffer(

how to get the ENUM from the string value

This question already has an answer here: Lookup Java enum by string value 23 answers public enum Signal{ ... public static Signal byValue(String value) { Singal[] signales = Signal.getEnumConstants(); for (Signal s:signals) { if (s.getValue().equals(value) { return s; } } } }

如何从字符串值中获取ENUM

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 public enum Signal{ ... public static Signal byValue(String value) { Singal[] signales = Signal.getEnumConstants(); for (Signal s:signals) { if (s.getValue().equals(value) { return s; } } } }

Take string and compare to multiple enum types all at once

This question already has an answer here: Lookup Java enum by string value 23 answers 您可以将输入转换为枚举System.out.print("Please enter your photo's file type. It must be: JPG, GIF, PNG, BMP, or OTHER"); boolean typeInput = kb.nextLine(); inputMatches = true; try{ FileType fileType = FileType.valueOf(inputString.toUpperCase().trim()); }catch (IllegalArgumentException e) { inputMatc

采取字符串并一次比较多个枚举类型

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 您可以将输入转换为枚举System.out.print("Please enter your photo's file type. It must be: JPG, GIF, PNG, BMP, or OTHER"); boolean typeInput = kb.nextLine(); inputMatches = true; try{ FileType fileType = FileType.valueOf(inputString.toUpperCase().trim()); }catch (IllegalArgumentException e) { inputMatches = false; }

Setting an enum from user input

This question already has an answer here: Lookup Java enum by string value 23 answers Your problem is that you call valueOf(...) but you discard the ContactType object that is returned by this method call.... ie, you never assign the returned object to a variable. First get rid of your unnecessary wrapper by changing this: public class ContactType { public enum contactType {

从用户输入设置枚举

这个问题在这里已经有了答案: 通过字符串值查找Java枚举23个答案 你的问题是你调用valueOf(...)但是你放弃了这个方法调用返回的ContactType对象....也就是说,你永远不会把返回的对象赋值给一个变量。 首先通过改变这个来摆脱你不必要的包装: public class ContactType { public enum contactType { Family, Church, Friend, BusninessColleague, ServicePerson,