首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSO2标识服务器以编程方式创建引发“非法访问尝试”警告的应用程序

WSO2标识服务器以编程方式创建引发“非法访问尝试”警告的应用程序
EN

Stack Overflow用户
提问于 2016-04-26 09:26:08
回答 1查看 290关注 0票数 0

我正在开发一个Java,它将通过调用WSO2标识服务器在OAuthAdminService中创建一个应用程序。经过深入研究,我发现registerOAuthApplicationData()方法是在IS中创建应用程序的方法。在调用该方法之前,我已经通过AuthenticationAdminStub类型的login()方法对管理用户进行了身份验证。即使在这样的身份验证之后,registerOAuthApplicationData()方法也会使IS控制台打印出来

2016-04-26 13:08:52,577警告{org.wso2.carbon.server.admin.module.handler.AuthenticationHandler} -非法访问尝试在2016-04-26 13:08:52,0577从IP地址127.0.0.1同时试图验证对服务OAuthAdminService的访问

并且应用程序不会在is数据库中创建。

我尝试过的代码如下

代码语言:javascript
复制
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;
import org.wso2.carbon.authenticator.proxy.AuthenticationAdminStub;
import org.wso2.carbon.identity.oauth.OAuthAdminServicePortTypeProxy;
import org.wso2.carbon.identity.oauth.dto.xsd.OAuthConsumerAppDTO;

    public class IdentityClientOne {    


            private final static String SERVER_URL = "https://localhost:9443/services/";
            private final static String APP_ID = "myapp";

            /**
             * @param args
             */
            public static void main(String[] args) {

                AuthenticationAdminStub authstub = null;
                ConfigurationContext configContext = null;

                System.setProperty("javax.net.ssl.trustStore", "wso2carbon.jks");
                System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");

                try {
                    configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                            "repo", "repo/conf/client.axis2.xml");
                    authstub = new AuthenticationAdminStub(configContext, SERVER_URL
                            + "AuthenticationAdmin");

                    // Authenticates as a user having rights to add users.
                    if (authstub.login("admin", "admin", APP_ID)) {
                        System.out.println("admin authenticated");


                        OAuthConsumerAppDTO consumerApp = new OAuthConsumerAppDTO("Oauth-2.0",
                                "sample_app",
                                "",
                                "authorization_code implicit password client_credentials refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm","","","");


                        OAuthAdminServicePortTypeProxy OAuthAdminProxy = new OAuthAdminServicePortTypeProxy();
                        OAuthAdminProxy.registerOAuthApplicationData(consumerApp);

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

    }

请帮助做什么应该做的对吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-26 12:07:33

您必须通过经过验证的会话访问存根。

你能在下面试试吗。

代码语言:javascript
复制
public class Test {
    private final static String SERVER_URL = "https://localhost:9443/services/";

    public static void main(String[] args) throws RemoteException, OAuthAdminServiceException {

        OAuthAdminServiceStub stub = new OAuthAdminServiceStub(null, SERVER_URL + "OAuthAdminService");

        ServiceClient client = stub._getServiceClient();
        authenticate(client);

        OAuthConsumerAppDTO consumerAppDTO = new OAuthConsumerAppDTO();
        consumerAppDTO.setApplicationName("sample-app");
        consumerAppDTO.setCallbackUrl("http://localhost:8080/playground2/oauth2client");
        consumerAppDTO.setOAuthVersion("OAuth-2.0");
        consumerAppDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token "
                                     + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm");

        stub.registerOAuthApplicationData(consumerAppDTO);
    }

    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);
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36860726

复制
相关文章

相似问题

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