有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

wcf。Net SecureString在Java中的应用

我正在尝试在客户站点上使用第三方身份验证web服务。web服务是用XML编写的。Net并接受SecureString作为密码类型

AuthResult Login(string username, SecureString passkey)

我的应用程序是用Java编写的,Java中没有可使用的SecureString兼容类型:(当我生成axis代理时,它会生成一个没有SecureString成员的存根,因此我无法对服务进行身份验证调用

public class SecureString  implements java.io.Serializable {
    public SecureString() {
        ...
    }
}

我正在努力,但我不是很有希望

有谁能帮我解决这个互操作性问题吗?我正在寻找一种将secureString类型的参数从Java应用程序代码发送到的方法。网络服务


共 (3) 个答案

  1. # 1 楼答案

    经过更多的研究,我可以说。SecureString的网络类型不可互操作。我已向服务提供者发出请求,要求编写一个以char[]为参数的服务

  2. # 2 楼答案

    没错。SecureString不是可序列化类型。由于SecureString依赖于DPAPI,而DPAPI本身依赖于本地机器属性来构造它的加密密钥/向量,所以它永远不会跨机器进行

    API发布时带有SecureString类型参数的事实显示了其设计中的一个重要缺陷。任何远程客户端都不可能提交该参数

  3. # 3 楼答案

    ... My app is written in Java and there is no compatible type for SecureString in Java

    ... Can anyone help me with how to overcome this interoperability issue?

    正如您所知,Java中没有SecureString

    在Java中,应该使用char[]并在使用完材料后覆盖它。来自Java加密扩展(JCE)参考指南中的Using Password-Based Encryption

    It would seem logical to collect and store the password in an object of type java.lang.String. However, here's the caveat: Objects of type String are immutable, i.e., there are no methods defined that allow you to change (overwrite) or zero out the contents of a String after usage. This feature makes String objects unsuitable for storing security sensitive information such as user passwords. You should always collect and store security sensitive information in a char array instead.

    因此,您的SecureString将有一个私有的char[],并且您将在销毁时将数组归零。我相信。Net的SecureString在不使用时屏蔽字符串(我不相信它是真正的加密,但我可能错了)。因此,您还需要提供一个掩码函数