Example usage for javax.xml.ws Service addPort

List of usage examples for javax.xml.ws Service addPort

Introduction

In this page you can find the example usage for javax.xml.ws Service addPort.

Prototype

public void addPort(QName portName, String bindingId, String endpointAddress) 

Source Link

Document

Creates a new port for the service.

Usage

From source file:org.jboss.wsf.test.JBossWSTestHelper.java

private static Object getImplementationObject() {
    Service service = Service.create(new QName("dummyService"));
    Object obj = service.getHandlerResolver();
    if (obj == null) {
        service.addPort(new QName("dummyPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://dummy-address");
        obj = service.createDispatch(new QName("dummyPort"), Source.class, Mode.PAYLOAD);
    }//from  w ww .j av  a  2 s  .co m
    return obj;
}

From source file:org.openiam.provision.service.ProvisionServiceImpl.java

public ProvisionUserResponse addUser(ProvisionUser provUser) {
    Organization org = null;/*ww  w. j ava  2  s.c  o  m*/
    Map<String, ManagedSysAttributes> managedSysMap = new HashMap<String, ManagedSysAttributes>();

    ScriptIntegration se = null;
    String secDomain = null;
    String password = null;

    Login primaryLogin = null;

    Map<String, Object> bindingMap = new HashMap<String, Object>();

    password = PasswordGenerator.generatePassword(10);

    try {
        se = ScriptFactory.createModule(this.scriptEngine);
    } catch (Exception e) {
        e.printStackTrace();
    }

    bindingMap.put("context", ac);

    String gmSysKey = (String) se.execute(bindingMap, "provision/globalManagerSyskey.groovy");

    //TODO: Add policies to validate the request
    //TODO: Add policies to enhance the request

    // add the gmsyskey attribute

    UserAttribute uAttr = new UserAttribute();
    uAttr.setName("GM_SYSKEY");
    uAttr.setValue(gmSysKey);
    provUser.getUserAttributes().put("GM_SYSKEY", uAttr);

    log.info("addUser called.");

    log.info("Creating user in openiam repository");
    // create a user in the openiam repository
    User user = provUser.getUser();

    log.info("User alternate in addUser=" + user.getAlternateContactId());

    // temp hack
    if (user.getCompanyId() != null) {
        org = orgManager.getOrganization(user.getCompanyId());
    }
    List<Login> principalList = provUser.getPrincipalList();

    if (principalList == null) {
        principalList = new ArrayList<Login>();
    }

    bindingMap.put("sysId", "1");
    bindingMap.put("user", user);
    bindingMap.put("org", org);
    bindingMap.put("password", password);
    if (principalList.get(0) != null) {
        primaryLogin = principalList.get(0);
        log.info("primary login=" + primaryLogin);
        bindingMap.put("lg", primaryLogin);
        secDomain = primaryLogin.getId().getDomainId();
    }

    /* -- Temp hack -- */
    String networxId = (String) se.execute(bindingMap, "provision/networxId.groovy");
    String globalManagerId = (String) se.execute(bindingMap, "provision/globalManagerId.groovy");

    /*   LoginId networkLgId = new LoginId(secDomain, networxId, "1" );
       Login networxLg = new Login();
       networxLg.setId(networkLgId);
       networxLg.setPassword(password);
       networxLg.setStatus("ACTIVE");
       principalList.add(networxLg);
            
       LoginId gmLgId = new LoginId(secDomain, globalManagerId, "2" );
       Login gmLg = new Login();
       gmLg.setId(gmLgId);
       gmLg.setStatus("ACTIVE");
       principalList.add(gmLg);
    */
    //

    User newUser = userMgr.addUser(user);
    if (newUser == null || newUser.getUserId() == null) {
        ProvisionUserResponse resp = new ProvisionUserResponse();
        resp.setStatus(ResponseStatus.FAILURE);
    }

    log.info("User created in openiam repository");

    Supervisor supervisor = provUser.getSupervisor();
    if (supervisor != null && supervisor.getSupervisor() != null) {
        supervisor.setEmployee(user);
        userMgr.addSupervisor(supervisor);
        log.info("created user supervisor");
    }

    log.info("Associated a user to a group");
    List<Group> groupList = provUser.getMemberOfGroups();
    log.info("Group list = " + groupList);
    if (groupList != null) {
        for (Group g : groupList) {
            // check if the group id is valid
            if (g.getGrpId() == null) {
                ProvisionUserResponse resp = new ProvisionUserResponse();
                resp.setStatus(ResponseStatus.FAILURE);
                resp.setErrorCode(ResponseCode.GROUP_ID_NULL);
                return resp;
            }
            if (groupManager.getGroup(g.getGrpId()) == null) {
                if (g.getGrpId() == null) {
                    ProvisionUserResponse resp = new ProvisionUserResponse();
                    resp.setStatus(ResponseStatus.FAILURE);
                    resp.setErrorCode(ResponseCode.GROUP_ID_NULL);
                    return resp;
                }
            }
            groupManager.addUserToGroup(g.getGrpId(), newUser.getUserId());
        }
    }

    log.info("Associating users to a role");
    List<Role> roleList = provUser.getMemberOfRoles();
    log.info("Role list = " + roleList);
    if (roleList != null && roleList.size() > 0) {
        for (Role r : roleList) {
            // check if the roleId is valid
            if (r.getId().getServiceId() == null || r.getId().getRoleId() == null) {
                ProvisionUserResponse resp = new ProvisionUserResponse();
                resp.setStatus(ResponseStatus.FAILURE);
                resp.setErrorCode(ResponseCode.ROLE_ID_NULL);
                return resp;
            }
            if (roleDataService.getRole(r.getId().getServiceId(), r.getId().getRoleId()) == null) {
                ProvisionUserResponse resp = new ProvisionUserResponse();
                resp.setStatus(ResponseStatus.FAILURE);
                resp.setErrorCode(ResponseCode.ROLE_ID_INVALID);
                return resp;
            }
            roleDataService.addUserToRole(r.getId().getServiceId(), r.getId().getRoleId(), newUser.getUserId());
        }
    }

    // determine if this is role based, rule base or static list for provisioning the apps
    // for now, assume that its role based.
    log.info("default provisioning model=" + defaultProvisioningModel);

    log.info("create user identities");

    // temp hack - tack on the network identity

    //ManagedSysAttributes sysAttribute = null;

    /* Start with 1 role first and build from there. */
    if (roleList != null && roleList.size() > 0) {
        List<Resource> roleResource = getResourcesForRole(roleList);
        // collect all the resources that belong to a managed system execute their policies
        if (roleResource != null) {
            log.info("List of resources for roles = " + roleResource.size());
            // for each resource, get the list of polices and execute them.
            for (Resource res : roleResource) {

                if (res.getName().equalsIgnoreCase("GLOBAL MANAGER")) {
                    LoginId gmLgId = new LoginId(secDomain, globalManagerId, "2");
                    Login gmLg = new Login();
                    gmLg.setId(gmLgId);
                    gmLg.setStatus("ACTIVE");
                    principalList.add(gmLg);

                }
                if (res.getName().equalsIgnoreCase("NETWORX")) {
                    LoginId networkLgId = new LoginId(secDomain, networxId, "1");
                    Login networxLg = new Login();
                    networxLg.setId(networkLgId);
                    networxLg.setPassword(password);
                    networxLg.setStatus("ACTIVE");
                    principalList.add(networxLg);
                }

            }

        }

    }

    // persist the list of identities in the openiam repository
    log.info("Persisting identity count=" + principalList.size());
    if (principalList != null) {
        for (Login lg : principalList) {
            Login newLg = new Login();
            LoginId newLgId = new LoginId();

            newLgId = lg.getId();
            newLg.setId(newLgId);
            newLg.setUserId(newUser.getUserId());
            newLg.setFirstTimeLogin(1);
            newLg.setStatus("ACTIVE");

            String pswd = lg.getPassword();
            if (pswd != null) {
                try {
                    newLg.setPassword(loginManager.encryptPassword(pswd));
                } catch (EncryptionException e) {
                    ProvisionUserResponse resp = new ProvisionUserResponse();
                    resp.setStatus(ResponseStatus.FAILURE);
                    resp.setErrorCode(ResponseCode.FAIL_ENCRYPTION);
                    return resp;
                }
            }

            //lg.setUserId(newUser.getUserId());
            //lg.setFirstTimeLogin(1);
            //lg.setStatus("ACTIVE");

            //log.info("--Principal=" + lg);
            loginManager.addLogin(newLg);

            log.info("--added identity:" + lg.getId());
        }
    }

    log.info("Creating user in managed systems..");
    //TODO add the capability to get the list of applications if a role is specified
    //TODO - if the configuration on the form is based on rules, then process that to get the list of apps
    //TODO - get the list of apps from the user.
    String requestId = null;

    List<Login> appList = provUser.getPrincipalList();
    boolean syncCalled = false;
    if (principalList != null) {
        log.info("principal list size=" + principalList.size());
        for (Login lg : principalList) {
            log.info("Login object=" + lg);
            if (!lg.getId().getManagedSysId().equals("0") && !syncCalled) {
                log.info("Login managedsys is =" + lg.getId().getManagedSysId());
                // get the managed system for the identity - ignore the managed system id that is linked to openiam's repository
                //ManagedSys managedSys = managedSysService.getManagedSys(lg.getId().getManagedSysId());
                ManagedSys managedSys = managedSysService.getManagedSys("1");
                log.info("Managedsys object= " + managedSys);
                if (managedSys != null) {
                    log.info("Managed sys found for managedSysId=" + lg.getId());

                    // collection of attributes that were determined earlier
                    ManagedSysAttributes sysAttribute = managedSysMap.get(managedSys.getManagedSysId());

                    ProvisionConnector connector = connectorService.getConnector(managedSys.getConnectorId());
                    log.info("Connector found for " + connector.getConnectorId());
                    if (connector != null) {

                        //Service service = Service.create(QName.valueOf("http://localhost:8080/idm-connector-ws/ExampleConnectorService"));
                        Service service = Service.create(QName.valueOf(connector.getServiceUrl()));

                        service.addPort(new QName(connector.getServiceNameSpace(), connector.getServicePort()),
                                SOAPBinding.SOAP11HTTP_BINDING, connector.getServiceUrl());

                        ConnectorService port = service.getPort(
                                new QName(connector.getServiceNameSpace(), connector.getServicePort()),
                                ConnectorService.class);

                        log.info("connector service client " + port);

                        AddRequestType addReqType = new AddRequestType();
                        PSOIdentifierType idType = new PSOIdentifierType(lg.getId().getLogin(), null, "target");
                        addReqType.setPsoID(idType);
                        requestId = "R" + System.currentTimeMillis();
                        addReqType.setRequestID(requestId);
                        addReqType.setTargetID(lg.getId().getManagedSysId());

                        ExtensibleUser extUser = null;

                        //TODO - Move to use groovy script based on attribute policies so that this is dynamic.
                        try {
                            extUser = UserAttributeHelper.newUser(provUser);
                        } catch (Exception e) {
                            e.printStackTrace();
                            log.error(e);
                        }
                        //   ExtensibleUser extUser = sysAttribute.getExtUser();
                        //   log.info("Ext user being sent to connector = " + extUser);

                        //addReqType.getData().getAny().add(sysAttribute.getExtUser());
                        addReqType.getData().getAny().add(extUser);
                        port.add(addReqType);
                        syncCalled = true;

                    }

                } else {
                    log.debug("Managed sys not found for managedSysId=" + lg.getId().getManagedSysId());
                }
            }
            // get the connector

        }

    }

    auditHelper.addLog("NEW USER", provUser.getSecurityDomain(), primaryLogin.getId().getLogin(), "IDM SERVICE",
            provUser.getCreatedBy(), "0", "USER", newUser.getUserId(), null, "SUCCESS", null, "USER_STATUS",
            provUser.getUser().getStatus().toString(), requestId, null, null, null);

    /*   String action,String domainId, String principal, 
       String srcSystem, String userId, String targetSystem, String objectType,  String objectId, String objectName,
       String actionStatus, String linkedLogId, String attrName, String attrValue,
       String requestId, String reason
    */

    ProvisionUserResponse resp = new ProvisionUserResponse();
    resp.setStatus(ResponseStatus.SUCCESS);
    provUser.setUserId(newUser.getUserId());
    resp.setUser(provUser);
    return resp;

}

From source file:org.openiam.provision.service.ProvisionServiceImpl.java

public ProvisionUserResponse modifyUser(ProvisionUser provUser) {
    log.info("modifyUser called.");

    List<String> inactiveResourceList = new ArrayList<String>();

    //TODO: Add policies to validate the request
    //TODO: Add policies to enhance the request

    // get the current user object - update it with the new values and then save it
    User origUser = userMgr.getUserWithDependent(provUser.getUserId(), true);

    if (origUser == null || origUser.getUserId() == null) {
        ProvisionUserResponse resp = new ProvisionUserResponse();
        resp.setStatus(ResponseStatus.FAILURE);
        return resp;
    }//from w  w  w .j  a v  a 2s .  c  o m

    // origUser2 is used for comparison purposes in the sync process
    //User currentUser2 = userMgr.getUserWithDependent(provUser.getUserId(), true);
    User currentUser2 = UserAttributeHelper.cloneUser(origUser);

    List<Role> curRoleList = roleDataService.getUserRolesAsFlatList(provUser.getUserId());
    List<Group> curGroupList = this.groupManager.getUserInGroupsAsFlatList(provUser.getUserId());

    log.info("** 1) Deptcd in Orig=" + currentUser2.getDeptCd());

    User newUser = provUser.getUser();

    log.info("** 1a) Deptcd in Orig=" + currentUser2.getDeptCd());
    log.info("** Deptcd in new=" + newUser.getDeptCd());

    updateUserObject(origUser, newUser);

    log.info("Modifying user in openiam repository");

    String requestId = "R" + System.currentTimeMillis();

    userMgr.updateUserWithDependent(origUser, true);

    // get the primary identity
    Login primaryLg = loginManager.getPrimaryIdentity(origUser.getUserId());
    String primaryId = null;
    if (primaryLg != null) {
        primaryId = primaryLg.getId().getLogin();
    }
    log.info("Primary id=" + primaryId);

    log.info("logging primary modify user");
    String logId = auditHelper
            .addLog("MODIFY USER", provUser.getSecurityDomain(), primaryId, "IDM SERVICE",
                    provUser.getUser().getLastUpdatedBy(), "0", "USER", provUser.getUserId(), null, "SUCCESS",
                    null, "USER_STATUS", provUser.getUser().getStatus().toString(), requestId, null, null, null)
            .getLogId();

    updateGroupAssociation(origUser.getUserId(), provUser.getMemberOfGroups(), logId, requestId,
            provUser.getUser().getLastUpdatedBy(), primaryId);

    updateRoleAssociation(origUser.getUserId(), provUser.getMemberOfRoles(), logId, requestId,
            provUser.getUser().getLastUpdatedBy(), primaryId);

    updateSupervisor(newUser, provUser.getSupervisor());

    // update the identities
    List<Login> tempPrincipalList = provUser.getPrincipalList();
    log.info("pricipallist = " + tempPrincipalList);
    if (tempPrincipalList != null && tempPrincipalList.size() > 0) {
        updatePrincipals(newUser, provUser.getPrincipalList());
    }

    // temp hack
    List<Login> curPrincipalList = loginManager.getLoginByUser(origUser.getUserId());

    Login primaryLogin = null;
    String secDomain = null;
    for (Login lg : curPrincipalList) {
        if (lg.getId().getManagedSysId().equalsIgnoreCase("0")) {
            primaryLogin = lg;
            secDomain = primaryLogin.getId().getDomainId();
            //rolePrincipalList.add(lg);
        }
        // build the active-inactive list of resources
        if (lg.getStatus() != null && lg.getStatus().equalsIgnoreCase("INACTIVE")) {
            inactiveResourceList.add(lg.getId().getManagedSysId());
        }
    }

    List<Login> principalList = provUser.getPrincipalList();
    String password = PasswordGenerator.generatePassword(10);

    ScriptIntegration se = null;
    Organization org = null;
    if (origUser.getCompanyId() != null) {
        org = orgManager.getOrganization(origUser.getCompanyId());
    }

    Map<String, Object> bindingMap = new HashMap<String, Object>();
    bindingMap.put("context", ac);
    bindingMap.put("sysId", "1");
    bindingMap.put("user", newUser);
    bindingMap.put("org", org);
    bindingMap.put("password", password);
    bindingMap.put("lg", primaryLogin);

    try {
        se = ScriptFactory.createModule(this.scriptEngine);
    } catch (Exception e) {
        e.printStackTrace();
    }

    String networxId = (String) se.execute(bindingMap, "provision/networxId.groovy");
    String globalManagerId = (String) se.execute(bindingMap, "provision/globalManagerId.groovy");
    String gmSysKey = (String) se.execute(bindingMap, "provision/globalManagerSyskey.groovy");

    /* -- Temp hack -- */
    //

    // send message to the connectors.

    log.info("User created in openiam repository");

    List<Role> activeRoleList = this.roleDataService.getUserRolesAsFlatList(origUser.getUserId()); // provUser.getActiveMemberOfRoles();

    showRoles(activeRoleList);

    //List<Role> roleList = provUser.getMemberOfRoles();
    List<Login> rolePrincipalList = new ArrayList<Login>();

    if (activeRoleList != null && activeRoleList.size() > 0) {
        log.info("Active role List= " + activeRoleList.size());

        List<Resource> roleResource = getResourcesForRole(activeRoleList);

        // collect all the resources that belong to a managed system execute their policies
        if (roleResource != null) {
            log.info("**** List of resources for roles = " + roleResource.size());
            // for each resource, get the list of polices and execute them.
            for (Resource res : roleResource) {
                // CHECK IF this resource is in the rolePrincipal list
                // if it is make sure that its active
                // if its not there, the add it.
                log.info("Checking resource id = " + res.getResourceId());
                log.info("Role principal list size = " + rolePrincipalList.size());
                boolean found = false;
                for (Login l : curPrincipalList) {
                    log.info("checking identity: " + l.getId() + " " + l.getId().getManagedSysId());
                    if (l.getId().getManagedSysId().equalsIgnoreCase(res.getResourceId())) {
                        // found
                        log.info("-Match for resource found. Setting status to active.");
                        l.setPasswordChangeCount(0);
                        l.setAuthFailCount(0);
                        l.setStatus("ACTIVE");
                        found = true;
                        rolePrincipalList.add(l);
                        // remove from the inactive list
                        log.info("Res made active....=" + l.getId().getManagedSysId());
                        log.info("InactiveResoruceList size=" + inactiveResourceList);

                        inactiveResourceList = removeFromInactiveResList(l.getId().getManagedSysId(),
                                inactiveResourceList);

                        log.info("InactiveResoruceList after update size=" + inactiveResourceList);
                    }
                }
                if (!found) {
                    log.info("-Match for resource not found. added identity for " + res.getName());
                    if (res.getName().equalsIgnoreCase("GLOBAL MANAGER")) {
                        LoginId gmLgId = new LoginId(secDomain, globalManagerId, "2");
                        Login gmLg = new Login();
                        gmLg.setId(gmLgId);
                        gmLg.setPasswordChangeCount(0);
                        gmLg.setAuthFailCount(0);
                        gmLg.setStatus("ACTIVE");
                        rolePrincipalList.add(gmLg);

                        log.info("GM made active....");
                        log.info("InactiveResoruceList size=" + inactiveResourceList);

                        inactiveResourceList = removeFromInactiveResList(gmLg.getId().getManagedSysId(),
                                inactiveResourceList);

                        auditHelper.addLog("MODIFY USER", provUser.getSecurityDomain(), primaryId,
                                "IDM SERVICE", provUser.getUser().getLastUpdatedBy(), "0", "USER",
                                provUser.getUserId(), null, "SUCCESS", logId, "NEW IDENTITY", res.getName(),
                                requestId, null, null, null);

                    }
                    if (res.getName().equalsIgnoreCase("NETWORX")) {
                        LoginId networkLgId = new LoginId(secDomain, networxId, "1");
                        Login networxLg = new Login();
                        networxLg.setId(networkLgId);
                        networxLg.setPassword(password);
                        networxLg.setPasswordChangeCount(0);
                        networxLg.setAuthFailCount(0);
                        networxLg.setStatus("ACTIVE");
                        rolePrincipalList.add(networxLg);
                        auditHelper.addLog("MODIFY USER", provUser.getSecurityDomain(), primaryId,
                                "IDM SERVICE", provUser.getUser().getLastUpdatedBy(), "0", "USER",
                                provUser.getUserId(), null, "SUCCESS", logId, "NEW IDENTITY", res.getName(),
                                requestId, null, null, null);
                    }
                }
            }
        }
    }

    // determine if there are modifications to be made to the list of identities

    if (curPrincipalList != null) {
        for (Login lg : curPrincipalList) {
            if (lg.getId().getManagedSysId().equalsIgnoreCase("0")) {
                rolePrincipalList.add(lg);
            }
        }
        // IF A VALUE IS IN THE CURRENT LIST, BUT NOT in the rolelist, then delete it
        log.info("Searching the curent principal list...");
        for (Login curLg : curPrincipalList) {
            log.info("cur lg sysid = " + curLg.getId().getManagedSysId());
            boolean found = false;
            for (Login roleLg : rolePrincipalList) {
                if (roleLg.getId().getManagedSysId().equalsIgnoreCase(curLg.getId().getManagedSysId())) {
                    found = true;
                }
            }
            if (!found) {
                curLg.setOperation(AttributeOperationEnum.DELETE);
                curLg.setStatus("INACTIVE");
                rolePrincipalList.add(curLg);

                auditHelper.addLog("MODIFY USER", provUser.getSecurityDomain(), primaryId, "IDM SERVICE",
                        provUser.getUser().getLastUpdatedBy(), "0", "USER", provUser.getUserId(), null,
                        "SUCCESS", logId, "DISABLE IDENTITY", curLg.getId().getLogin(), requestId, null, null,
                        null);
            }
        }

    }

    log.info("** A) Deptcd in Orig=" + currentUser2.getDeptCd());

    // IF A VALUE IS IN THE CURRENT LIST, BUT NOT in the rolelist, then delete it

    // if a role is define

    if (activeRoleList != null) {
        log.info("-- updatePrincipals will be called.");
        updatePrincipals(newUser, rolePrincipalList);
    }
    log.info("--Check the status of this request.");
    // if the status has been set to TERMINATE - THEN SET THE IDENTITIES TO INACTIVE
    if (isTerminate(newUser)) {
        log.info("--Status has been changed to terminate.");
        for (Login lg : rolePrincipalList) {
            lg.setStatus("INACTIVE");
            log.info("Updating status for login=" + lg.getId());
            loginManager.updateLogin(lg);

        }
    } else {
        log.info("-- Status is not TERMINATE.");
        for (Login lg : rolePrincipalList) {
            if (lg.getId().getManagedSysId().equalsIgnoreCase("0")) {
                lg.setStatus("ACTIVE");
                lg.setPasswordChangeCount(0);
                lg.setAuthFailCount(0);
                log.info("Updating status TO ACTIVE for login=" + lg.getId());
                loginManager.updateLogin(lg);
            }

        }
    }

    // pass 2 - check the current list with the role list

    provUser.setPrincipalList(rolePrincipalList);

    log.info("ROLE principal list (Before SPML block) = " + rolePrincipalList);

    //  show inactive list
    log.info("---- show inactivelist ----");
    for (String s : inactiveResourceList) {
        log.info("Inactive resource: " + s);
    }
    //

    //List<Login> principalList = provUser.getPrincipalList();
    if (rolePrincipalList != null) {
        log.info("Role based principal list size=" + rolePrincipalList.size());
        for (Login lg : rolePrincipalList) {
            log.info("Login object=" + lg);
            if (!lg.getId().getManagedSysId().equals("0") &&
            //lg.getStatus().equalsIgnoreCase("ACTIVE") ) {
                    !onInactiveList(lg.getId().getManagedSysId(), inactiveResourceList)) {
                //lg.getStatus().equalsIgnoreCase("ACTIVE")) {
                log.info("Login managedsys is =" + lg.getId().getManagedSysId());
                // get the managed system for the identity - ignore the managed system id that is linked to openiam's repository
                ManagedSys managedSys = managedSysService.getManagedSys(lg.getId().getManagedSysId());
                log.info("Managedsys object= " + managedSys);
                // CHECK IF WE HAVE A NETWORX ID. IF WE DO, THEN LEAVE IT ALONE.
                // IF WE DONT, THEN HARD CODE THE CALL.
                if (!networx(rolePrincipalList)) {
                    managedSys = managedSysService.getManagedSys("1");
                    log.info("Get the connector =" + managedSys);
                }

                if (managedSys != null) {
                    log.info("Managed sys found for managedSysId=" + lg.getId());

                    // collection of attributes that were determined earlier
                    //ManagedSysAttributes sysAttribute =  managedSysMap.get(managedSys.getManagedSysId());

                    ProvisionConnector connector = connectorService.getConnector(managedSys.getConnectorId());
                    log.info("Connector found for " + connector.getConnectorId());
                    if (connector != null) {

                        //Service service = Service.create(QName.valueOf("http://localhost:8080/idm-connector-ws/ExampleConnectorService"));
                        Service service = Service.create(QName.valueOf(connector.getServiceUrl()));

                        service.addPort(new QName(connector.getServiceNameSpace(), connector.getServicePort()),
                                SOAPBinding.SOAP11HTTP_BINDING, connector.getServiceUrl());

                        ConnectorService port = service.getPort(
                                new QName(connector.getServiceNameSpace(), connector.getServicePort()),
                                ConnectorService.class);

                        log.info("connector service client " + port);

                        ModifyRequestType modReqType = new ModifyRequestType();
                        PSOIdentifierType idType = new PSOIdentifierType(lg.getId().getLogin(), null, "target");
                        idType.setTargetID(lg.getId().getManagedSysId());
                        modReqType.setPsoID(idType);
                        modReqType.setRequestID(requestId);

                        ExtensibleUser extUser = null;

                        //TODO - Move to use groovy script based on attribute policies so that this is dynamic.

                        // check if we have the syskey in this
                        UserAttribute gmAtt = currentUser2.getAttribute("GM_SYSKEY");
                        log.info("gmAtt=" + gmAtt.getValue());

                        log.info("** b) Deptcd in Orig=" + currentUser2.getDeptCd());

                        try {
                            extUser = UserAttributeHelper.modifyUser(currentUser2, curRoleList, curGroupList,
                                    provUser);

                        } catch (Exception e) {
                            e.printStackTrace();
                            log.error(e);
                        }
                        //   ExtensibleUser extUser = sysAttribute.getExtUser();
                        //   log.info("Ext user being sent to connector = " + extUser);

                        log.info("Ext user attributes=" + extUser.getAttributes().size());

                        ModificationType mod = new ModificationType();
                        mod.getData().getAny().add(extUser);

                        List<ModificationType> modTypeList = modReqType.getModification();
                        modTypeList.add(mod);

                        port.modify(modReqType);

                        //addReqType.getData().getAny().add(sysAttribute.getExtUser());
                        //port.add(addReqType);

                    }

                } else {
                    log.debug("Managed sys not found for managedSysId=" + lg.getId().getManagedSysId());
                }
            }
            // get the connector

        }

    }

    ProvisionUserResponse resp = new ProvisionUserResponse();
    resp.setStatus(ResponseStatus.SUCCESS);
    return resp;

}

From source file:org.openiam.provision.service.RemoteConnectorAdapter.java

private ConnectorService getService(ProvisionConnector connector) {
    try {/*ww  w  . j  a v a 2  s . com*/

        QName SERVICE_NAME = new QName(connector.getServiceUrl());
        QName PORT_NAME = new QName(connector.getServiceNameSpace(), connector.getServicePort());

        Service service = Service.create(SERVICE_NAME);
        service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, connector.getServiceUrl());

        ConnectorService port = service.getPort(
                new QName(connector.getServiceNameSpace(), connector.getServicePort()), ConnectorService.class);
        return port;

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

}

From source file:org.opennaas.extensions.bod.autobahn.protocol.AutobahnProtocolSession.java

private <T> T createSoapService(String uri, QName serviceName, QName portName, Class<T> clazz)
        throws ProtocolException {
    /*/*from w  w w. ja va2 s  . c om*/
     * The JAXWS SPI uses the context class loader to locate an implementation. We therefore make sure the context class loader is set to our
     * class loader.
     */
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    try {
        thread.setContextClassLoader(getClass().getClassLoader());
        Service service = Service.create(serviceName);
        service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, uri);
        return service.getPort(portName, clazz);
    } catch (WebServiceException e) {
        throw new ProtocolException("Failed to create Autobahn session: " + e.getMessage(), e);
    } finally {
        thread.setContextClassLoader(oldLoader);
    }
}

From source file:org.wso2.carbon.connector.rm.ReliableMessage.java

/**
 * This method used to create dispatcher
 *
 * @param inputParams input parameters.//from w  w  w. j  a v  a 2 s  .co  m
 * @return Dispatch source dispatcher
 * @throws ConnectException
 */
private Dispatch<Source> createDispatch(RMParameters inputParams, MessageContext messageContext)
        throws ConnectException {
    String portName = inputParams.getPortName();
    String serviceName = inputParams.getServiceName();
    String nameSpace = inputParams.getNamespace();

    QName serviceQName = new QName(nameSpace, serviceName);
    QName portQName = new QName(nameSpace, portName);
    Service service = Service.create(serviceQName);

    if (service == null) {
        String message = "Service instance cannot initialize";
        log.error(message);
        throw new ConnectException(message);
    }

    if (RMConstants.SOAP_V_11.equals(inputParams.getSoapVersion())) {
        service.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, inputParams.getEndpoint());
    } else {
        service.addPort(portQName, SOAPBinding.SOAP12HTTP_BINDING, inputParams.getEndpoint());
    }

    Dispatch<Source> sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);
    if (messageContext.getSoapAction() != null && !messageContext.getSoapAction().isEmpty()) {
        sourceDispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
                messageContext.getSoapAction());
    }
    return sourceDispatch;
}