使用 OData 安全服务

发布于 2024-09-28 10:56:07 字数 222 浏览 4 评论 0原文

我想生成 OData 安全服务的实体类和服务类。 在 OData Java 扩展页面中,我需要使用 org.restlet.ext.odata.Generator 类来获取 uri 和输出目录参数。 但是,如果我的 OData 服务受到保护,则生成器实例无法在没有服务用户名和密码的情况下生成服务类。 我没有找到任何方法将用户名和密码传递给生成器类。

我收到 401 HTTP 响应代码。

请帮忙。

I want to generate entity classes and Service class of OData secured service.
In OData Java extension page it is written that I need to use org.restlet.ext.odata.Generator class that should get uri and output directory parameters.
But if my OData service is secured the generator instance is not able to generate service classes without username and password of the service.
I did not find any way to pass username and password to generator class.

I get 401 HTTP response code.

Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不甘平庸 2024-10-05 10:56:07

在 org.restlet.ext.odata.Generator 类的 main 方法中,
以下代码将清除 setCredentials() 方法中设置的凭据详细信息。

Service service = new Service(dataServiceUri);
if(service.getMetadata() == null)
{
  errorMessage = "Cannot retrieve the metadata.";
}

请提供此问题的解决方案,因为我目前无法为我的休息服务生成类,因为该服务是使用用户密码保护的。

我尝试使用以下代码来生成我的安全服务 uri 的代码:

import org.restlet.ext.odata.Generator;
import org.restlet.ext.odata.Service;
import org.restlet.data.ChallengeResponse;
import org.restlet.data.ChallengeScheme;

public class ODataRestletGenerator extends Service {

    public ODataRestletGenerator(String serviceUri) {
        super(serviceUri);
    }

    public static final String APPLICATION_URI = "http://ldcigkd.xxx.yyy.corp:50033/xxx/opu/sdata/IWCNT/CUSTOMER/";

    public static void main(String[] args) {

        // Add the client authentication to the call
        ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
        ChallengeResponse credentials = new ChallengeResponse(scheme, "user", "pwd");       
        new ODataRestletGenerator(APPLICATION_URI).setauth(credentials);

        String[] arguments = { APPLICATION_URI, "/customer/src" };
        Generator.main(arguments);
    }

    private void setauth(ChallengeResponse credentials) {

        super.setCredentials(credentials);
    }

}

In the org.restlet.ext.odata.Generator class, in the method main,
The following code would clear the credential details set in the setCredentials() method.

Service service = new Service(dataServiceUri);
if(service.getMetadata() == null)
{
  errorMessage = "Cannot retrieve the metadata.";
}

Kindly provide a solution for this issue as I am currently unable to generate the classes for my rest service as the service is secured with an user password.

I tried the following code to generate the code for my secured service uri:

import org.restlet.ext.odata.Generator;
import org.restlet.ext.odata.Service;
import org.restlet.data.ChallengeResponse;
import org.restlet.data.ChallengeScheme;

public class ODataRestletGenerator extends Service {

    public ODataRestletGenerator(String serviceUri) {
        super(serviceUri);
    }

    public static final String APPLICATION_URI = "http://ldcigkd.xxx.yyy.corp:50033/xxx/opu/sdata/IWCNT/CUSTOMER/";

    public static void main(String[] args) {

        // Add the client authentication to the call
        ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
        ChallengeResponse credentials = new ChallengeResponse(scheme, "user", "pwd");       
        new ODataRestletGenerator(APPLICATION_URI).setauth(credentials);

        String[] arguments = { APPLICATION_URI, "/customer/src" };
        Generator.main(arguments);
    }

    private void setauth(ChallengeResponse credentials) {

        super.setCredentials(credentials);
    }

}
我早已燃尽 2024-10-05 10:56:07

在 OData 扩展生成的 org.restlet.ext.odata.Service 子类中,您可以调用 setCredentials() 并传递 ChallengeResponse 实例,包括方案(BASIC?)、登录名(标识符)和密码(秘密)。

In the org.restlet.ext.odata.Service subclass that is generated by OData extension, you can call setCredentials() and pass an instance of ChallengeResponse including scheme (BASIC?), login (identifier) and password (secret).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文