1

I try to add new user through WSO2 IS API, but the most recent example of use is:
WSO2 Identity Server managing users and roles through API

It works, but when I try to execute method for adding new user it breaks.

Is there more actual examples anywhere?

There is my method:

public void addUser()  throws Exception{
    String serviceEndPoint;
    UserAdminStub adminStub;

    serviceEndPoint = serverUrl + "UserAdmin";
    adminStub = new UserAdminStub(configContext, serviceEndPoint);
    ServiceClient client = adminStub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setProperty(HTTPConstants.COOKIE_STRING, authCookie);

    Map<String, String> claims = new HashMap<String, String>();
    ClaimValue[] claimValues = new ClaimValue[2];
    ClaimValue claimValue1 = new ClaimValue();
    claimValue1.setClaimURI("http://wso2.org/claims/givenname");
    claimValue1.setValue("John");
    claimValues[0] = claimValue1;

    adminStub.addUser("sso", "sso123", null, claimValues, "default");
}

There is stack trace:

org.apache.axis2.AxisFault: unknown
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.RobustOutOnlyAxisOperation$RobustOutOnlyOperationClient.handleResponse(RobustOutOnlyAxisOperation.java:91)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.wso2.carbon.user.mgt.stub.UserAdminStub.addUser(UserAdminStub.java:1298)
at org.wso2.carbon.user.mgt.sample.UserAdminClient.addUser(UserAdminClient.java:125)
at org.wso2.carbon.user.mgt.sample.SampleUserRoleMgtClient.main(SampleUserRoleMgtClient.java:111)

And there is log from IS server:

java.lang.NullPointerException
    at org.wso2.carbon.user.mgt.UserRealmProxy.addUser(UserRealmProxy.java:255)
    at org.wso2.carbon.user.mgt.UserAdmin.addUser(UserAdmin.java:107)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
4

2 回答 2

2

所以,我在 IS 源代码中找到了最新的示例,尝试了它并且它有效 =)

http://svn.wso2.org/repos/wso2/carbon/platform/tags/4.0.5/products/is/4.0.0/modules/samples/

于 2013-03-07T05:33:40.730 回答
0

好像您的 UseradminStub 似乎没有经过身份验证您按照以下方式进行操作。

 userAdminStub = new UserAdminStub(endPoint);
 AuthenticateStub.authenticateStub(sessionCookie, userAdminStub);

谢谢你,达沙那。

于 2013-02-21T11:45:23.413 回答