Java 野蝇之路

Java 野蝇之路,java,authentication,wildfly,wildfly-8,jaas,Java,Authentication,Wildfly,Wildfly 8,Jaas,我想通过WildFly(8.2.0)在JAVA应用程序中使用JAAS身份验证 我尝试了几种方法和配置……但在登录(LoginContext)时仍然出现错误 我已经开始配置standalone.xml(WildFly): 使用JAAS身份验证创建了一个新的安全领域“TPRealm”: <security-realm name="TPRealm"> <authentication> <jaas name="TPLogin"/>

我想通过WildFly(8.2.0)在JAVA应用程序中使用JAAS身份验证

我尝试了几种方法和配置……但在登录(LoginContext)时仍然出现错误

我已经开始配置standalone.xml(WildFly):

  • 使用JAAS身份验证创建了一个新的安全领域“TPRealm”:

    <security-realm name="TPRealm">
         <authentication>
             <jaas name="TPLogin"/>
         </authentication>
    </security-realm>
    
    在“newlogincontext(…)”中,我得到以下错误

    javax.security.auth.login.LoginException: No LoginModules configured for TPRealm
    
    我经常读到,需要一个配置文件(jaas.config):

    我已将此文件添加到System.Properties

    System.setProperty("java.security.auth.login.config", jaasConfig)  //jaasConfig = path to file
    
    有了它,我可以编译“new LoginContext(…)”,但在LoginContext.login()的下一行编译失败:

    我还观看了wildfly的日志,希望在运行代码时记录任何内容,但没有记录任何内容

    在Java应用程序中,我还添加了以下属性:

    Properties ejbProps = new Properties();
    ejbProps.put("endpoint.name", "client-endpoint");
    ejbProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
    ejbProps.put("remote.connections", "default");
    ejbProps.put("remote.connection.default.host", "localhost");
    ejbProps.put("remote.connection.default.port", "8080");                                                  
    ejbProps.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
    
    EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(ejbProps);
    ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
    EJBClientContext.setSelector(selector);
    
    Properties ejbProps=新属性();
    ejbProps.put(“endpoint.name”,“client endpoint”);
    ejbProps.put(“remote.connectionprovider.create.options.org.xnio.options.SSL_ENABLED”,“false”);
    ejbProps.put(“remote.connections”、“default”);
    ejbProps.put(“remote.connection.default.host”、“localhost”);
    ejbProps.put(“remote.connection.default.port”,“8080”);
    ejbProps.put(“remote.connection.default.connect.options.org.xnio.options.SASL_POLICY_NOANONYMOUS”、“false”);
    EJBClientConfiguration cc=新属性basedejbclientconfiguration(ejbProps);
    ContextSelector=new ConfigBasedEJBClientContextSelector(cc);
    EJBClientContext.setSelector(选择器);
    
    我需要设置更多属性吗? 我应该注意别的事情吗


    如果有人能帮助我,我将非常高兴。

    您的web.xml中有什么内容?
    javax.security.auth.login.LoginException: No LoginModules configured for TPRealm
    
    TPRealm {
          org.jboss.security.auth.spi.TPLogin required;  // I dont know, what exactly have to stay here
    }
    
    System.setProperty("java.security.auth.login.config", jaasConfig)  //jaasConfig = path to file
    
    javax.security.auth.login.LoginException: unable to find LoginModule class: org.jboss.security.auth.spi.TPLogin
    
    Properties ejbProps = new Properties();
    ejbProps.put("endpoint.name", "client-endpoint");
    ejbProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
    ejbProps.put("remote.connections", "default");
    ejbProps.put("remote.connection.default.host", "localhost");
    ejbProps.put("remote.connection.default.port", "8080");                                                  
    ejbProps.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
    
    EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(ejbProps);
    ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
    EJBClientContext.setSelector(selector);