首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LDAP java在Liberty服务器上的单点登录

LDAP java在Liberty服务器上的单点登录
EN

Stack Overflow用户
提问于 2017-09-04 18:37:49
回答 3查看 1.5K关注 0票数 6

我想用Java在Websphere-Liberty服务器上实现单点登录。我想使用LDAP对用户进行身份验证。

我搜索了很多,但找不到确切的例子。我也检查了堆栈溢出的每个可用示例。但没那么走运。

如果能提供同样的演示或示例代码,那就太好了。

提前谢谢。

更新:在waffle的帮助下,我实现了同样的功能。但是华夫乐不能在Linux/Unix上工作。。。有谁能帮帮我吗?

EN

回答 3

Stack Overflow用户

发布于 2017-11-03 22:04:30

waffle不支持*nix。您可以在支持Krb5LoginModule的情况下使用JASS (仅限JavaSE8),它允许您缓存操作系统票证。

票数 4
EN

Stack Overflow用户

发布于 2017-09-25 17:37:01

如果您使用的是LDAP,则可以像Basic一样通过身份验证。如果您知道用户名和密码,请在头部Authorization后面加上值Basic base64_token。

base64令牌是一个使用用户名和密码进行base64编码的字符串,格式为用户名:密码。理想情况下,这应该是可行的。如果它不起作用,请告诉我。在这种情况下,我们可以使用SPNEGO探索选项。

JAVA中LDAP的代码:

代码语言:javascript
复制
public class Main
{
  public static void main(String[] args)
  {
    //Replace username and password with your username and password
    token = Base64.getEncoder().encodeToString((username + ":" + password).getBytes())
    conn = (HttpURLConnection) endpoint.openConnection();

    // Set the necessary header fields, which in this case is Basic
    conn.addRequestProperty("Authorization", "Basic " + token);

   //Continue to do what you want to do after this. This should authenticate 
  // you to the server
  }
}
票数 1
EN

Stack Overflow用户

发布于 2017-10-26 12:57:04

特别适用于windows。单点登录可以通过使用waffle来完成。

对于Ldap身份验证,您可以使用spring mvc转到简单的java类,代码行如下:

代码语言:javascript
复制
    String username = login.getUsername();// "ancb";
    String password = login.getPassword();// "*****";
    String base = "OU=******,DC=InfoDir,DC=DEV,DC=****";
    String dn = "CN=" + username + "," + base;
    String ldapURL = "ldaps://****.systems.**.****:3269";

    // Setup environment for authenticating
    Hashtable<String, String> environment = new Hashtable<String, String>();
    environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    environment.put(Context.PROVIDER_URL, ldapURL);
    environment.put(Context.SECURITY_AUTHENTICATION, "simple");
    environment.put(Context.SECURITY_PRINCIPAL, dn);
    environment.put(Context.SECURITY_CREDENTIALS, password);

    String dynamicLdapaccount = "(CN="+ username +")" ;

        DirContext authContext = new InitialDirContext(environment);

对于单点登录:

您需要在服务器级别设置Kerberos和Spnego配置。对于liberty服务器,它的server.xml需要修改。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46035255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档