2016-05-24 6 views
0

Ich versuche, einen Dienstanbieter in WSO2 Identity Server über Java-Programm zu erstellen. Der Codeblock, der einen Service Provider erstellt, lautet wie folgt.302 Fehler beim Erstellen des Dienstanbieters in WSO2 Identity Server

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;  
    } 

Beim Ausführen des Programms erhalte ich die folgende Fehlermeldung auf folgende Codezeile

IAMStub.createApplication zurückverfolgt (serviceprovider);

vollständige Spur

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) 

Was geht hier vor? Bitte hilf mir.

+0

Gibt es ein Fehlerprotokoll im WSO2-Backend? –

+0

Kein Fehler im IS-Backend. –

Antwort

1

In Identity Server 5.1.0 funktioniert die Operation "createApplication" ohne Probleme. Können Sie bitte den vollständigen Beispielquellcode und die Implementierung von Authenticate.authenticate posten? Protokollieren Sie die Werte von "oauthApp.getAppName()". Der folgende Code funktioniert für mich.

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); 
} 
0

@Gayan Ich habe gerade versucht, den Code, jetzt bin ich nicht die alten Fehler 302 erhalten, aber in der Client-Java-Konsole

org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorizedjava.lang.NullPointerException 
     at com.wipro.identity.wso2.IdentityServerAdapter.IdentityServerRest$2.handle(IdentityServerRest.java:60) 
     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) 

auch folgende INFO und Warnen Sie die folgende Störung zu erhalten sind immer auf der WSO2 gedruckt IS Console

[2016-05-25 16:16:52,724] INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} - '[email protected] [-1234]' logged in at [2016-05-25 16:16:52,724+05 
30] 
[2016-05-25 16:16:52,755] WARN {org.wso2.carbon.server.admin.module.handler.AuthenticationHandler} - Illegal access attempt at [2016-05-25 16:16:52,0755] from IP ad 
dress 127.0.0.1 while trying to authenticate access to service IdentityApplicationManagementService 

das ist mein altes authenticate() -Methode

public static void authenticate(ServiceClient client) { 
     Options option = client.getOptions(); 
     HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); 
     auth.setUsername("admin"); 
     auth.setPassword("admin"); 
     auth.setPreemptiveAuthentication(true); 
     option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth); 
     option.setManageSession(true); 
    } 

Ich habe gründlich den Inhalt des OAuthAppDetails-Objekts überprüft und es ist perfekt.

+0

können Sie den Wert von "authCookie" einfach ausdrucken? – Gayan

+0

seine Null .... !!!!!!! –

+0

Definieren Sie einfach authCookie Variable in der Spitze. Überprüfen Sie auch den Wert von (String) authstub._getServiceClient(). GetServiceContext(). GetProperty ( HTTPConstants.COOKIE_STRING) – Gayan

Verwandte Themen