WSO2IS通过API添加用户

时间:2015-06-21 06:12:30

标签: wso2is

我尝试使用wso2is API(RemoteUserStoreManagerService?wsdl)来创建新用户。我可以删除用户,登录但我无法添加用户。有一个异常添加新用户:org.apache.axis2.AxisFault:尝试调用服务方法addUser时发生异常 我设置了有效的密码符合密码策略。  Heare是我的代码:

 AuthenticationAdminStub authstub = new AuthenticationAdminStub();
            String cookie = null;
            String auid = ConfigUtil.getProperty(ConfigUtil.MOM_ADMINID_INFO);
            String apassword = ConfigUtil.getProperty(ConfigUtil.MOM_ADMINPASS_INFO);
            Login login = new Login();
            login.setUsername(auid);
            login.setPassword(apassword);
            login.setRemoteAddress(APP_ID);
            LoginResponse res = authstub.login(login);
            //realm.
            if (res.get_return())
                cookie = (String) authstub._getServiceClient().getServiceContext().getProperty(
                        HTTPConstants.COOKIE_STRING);

            RemoteUserStoreManagerServiceStub realm = new RemoteUserStoreManagerServiceStub();
            ServiceClient serviceClient = realm._getServiceClient();
            Options option = serviceClient.getOptions();
            option.setManageSession(true);
            option.setProperty(HTTPConstants.COOKIE_STRING, cookie);
            IsExistingUser user = new IsExistingUser();
            user.setUserName(username);
            IsExistingUserResponse resEx = realm.isExistingUser(user);
            if (resEx.get_return()) {
                DeleteUser duser = new DeleteUser();
                duser.setUserName(username);
                realm.deleteUser(duser);
            }
            RemoteUserStoreManagerServiceStub.AddUser aUser = new RemoteUserStoreManagerServiceStub.AddUser();
            aUser.setUserName(username);
            RemoteUserStoreManagerServiceStub.ClaimValue[] claim = new RemoteUserStoreManagerServiceStub.ClaimValue[1];
            claim[0] = new RemoteUserStoreManagerServiceStub.ClaimValue();
            claim[0].setClaimURI("http://wso2.org/claims/businessphone");
            claim[0].setValue("0112842302");
            aUser.setClaims(claim);
            aUser.setCredential(password);
            aUser.setRoleList(new String[]{APP_ID, null});
            realm.addUser(aUser);

我通过axis2 ant生成代码生成存根java代码,并将轴代码添加到我的项目中。 谁能帮我。感谢。

0 个答案:

没有答案