简体   繁体   English

302在WSO2 Identity Server中创建服务提供程序时出错

[英]302 Error while creating service provider in WSO2 Identity Server

I am trying to create a service provider in WSO2 Identity Server through Java program. 我正在尝试通过Java程序在WSO2 Identity Server中创建服务提供者。 The code block creating a service provider goes as follows. 创建服务提供者的代码块如下。

public static OAuthKeySecret createOAuthServiceProvider(OAuthAppDetails oauthApp, String authType) {
        OAuthKeySecret oauthKeySecret = new OAuthKeySecret();
        try {               
            IdentityApplicationManagementServiceStub IAMStub = new IdentityApplicationManagementServiceStub(
                    null, oauthApp.getSERVER_URL() + "IdentityApplicationManagementService");               
            ServiceClient IAMClient = IAMStub._getServiceClient();              
            Authenticate.authenticate(IAMClient);               
            ServiceProvider serviceProvider = new ServiceProvider();
            serviceProvider.setApplicationName(oauthApp.getAppName());
            serviceProvider.setDescription(oauthApp.getAppDescription());
            IAMStub.createApplication(serviceProvider);                 
            System.out.println("Service Provider created");    
        } catch (Exception e) {
            e.printStackTrace();
        }
        return oauthKeySecret;    
    }

When running the program I am getting the following error traced back to following line of code 运行程序时,我将以下错误追溯到以下代码行

IAMStub.createApplication(serviceProvider); IAMStub.createApplication(serviceProvider);

Complete trace 完整的追踪

org.apache.axis2.AxisFault: Transport error: 302 Error: Found
        at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:311)
        at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194)
        at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
        at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
        at org.wso2.carbon.identity.application.mgt.stub.IdentityApplicationManagementServiceStub.createApplication(IdentityApplicationManagement
ServiceStub.java:601)
        at com.xxxxx.identity.wso2.IdentityServerAdapter.IDManagementClient.createOAuthServiceProvider(IDManagementClient.java:52)
        at com.xxxxx.identity.wso2.IdentityServerAdapter.IdentityServerRest$1.handle(IdentityServerRest.java:37)
        at com.xxxxx.identity.wso2.IdentityServerAdapter.IdentityServerRest$1.handle(IdentityServerRest.java:19)
        at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:138)
        at spark.webserver.JettyHandler.doHandle(JettyHandler.java:54)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:179)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:451)
        at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:252)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:266)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
        at java.lang.Thread.run(Unknown Source)

Whats going on here? 这里发生了什么? Please help me. 请帮我。

In Identity Server 5.1.0, "createApplication" operation works without any issue. 在Identity Server 5.1.0中,“ createApplication”操作可以正常工作。 Can you please post the full sample source code and Implementation of Authenticate.authenticate? 您能否发布完整的示例源代码和Authenticate.authenticate的实现? Log the values of "oauthApp.getAppName()". 记录“ oauthApp.getAppName()”的值。 Below code works for me. 下面的代码对我有用。

try {
            String authCookie = null;
            ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
            AuthenticationAdminStub authstub = new AuthenticationAdminStub(ctx, "https://localhost:9443/services`enter code here`/AuthenticationAdmin");
            ServiceClient client = authstub._getServiceClient();
            Options options = client.getOptions();`enter code here`
            options.setManageSession(true);
            options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authCookie);
            //set trust store properties required in SSL communication.
            System.setProperty("javax.net.ssl.trustStore", RemoteUMSampleConstants.TRUST_STORE_PATH);
            System.setProperty("javax.net.ssl.trustStorePassword", RemoteUMSampleConstants.TRUST_STORE_PASSWORD);
            authstub.login("admin", "admin", "localhost");
            authCookie = (String) authstub._getServiceClient().getServiceContext().getProperty(
                    HTTPConstants.COOKIE_STRING);


            IdentityApplicationManagementServiceStub stub = new IdentityApplicationManagementServiceStub(
                    "https://localhost:9443/services/IdentityApplicationManagementService");
            ServiceClient e = stub._getServiceClient();
            Options option = e.getOptions();
            option.setManageSession(true);
            option.setProperty("Cookie", authCookie);

            ServiceProvider serviceProvider = new ServiceProvider();
            serviceProvider.setApplicationName("testName");
            serviceProvider.setDescription("testDescription");

            stub.createApplication(serviceProvider);
}catch (Exception e){
            System.out.print(e);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM