NdsBeisEsb/src/main/java/com/northgateps/nds/beis/esb/registration/RetrieveRegisteredDetailsLdapComponent.java
/**
     * Retrieve registered user details from Ldap
     * 
     * @throws NdsBusinessException
     */
Retrieve registered user details from Ldap


Retrieve registered user details from Ldap
@Override
    protected void doProcess(RetrieveRegisteredDetailsNdsRequest request, DirectoryAccessConnection directoryConnection,
            NdsSoapRequestAdapterExchangeProxy ndsExchange, DirectoryConnectionConfig directoryConnectionConfigImpl)
                    throws NdsApplicationException, NdsBusinessException, DirectoryException {
        String ldapAttributeForename = configurationManager.getString("attribute.forename");
        String ldapAttributeSurname = configurationManager.getString("attribute.surname");
        String ldapAttributeHomePhone = configurationManager.getString("attribute.homePhone");
        String ldapAttributeEmail = configurationManager.getString("attribute.email");
        String ldapAttributeStreetLineOne = configurationManager.getString("attribute.street");
        String ldapAttributeStreetLineTwo = configurationManager.getString("attribute.street2");
        String ldapAttributeTown = configurationManager.getString("attribute.town");
        String ldapAttributeCounty = configurationManager.getString("attribute.county");
        String ldapAttributePostcode = configurationManager.getString("attribute.postalCode");
        String ldapAttributeUprn = configurationManager.getString("attribute.uprn");
        String ldapAttributeOrgname = configurationManager.getString("attribute.organisationName");
        String ldapAttributeCountry = configurationManager.getString("attribute.country");
        String ldapAttributeUid = configurationManager.getString("attribute.userid");
        BeisRegistrationDetails beisRegistrationDetails = new BeisRegistrationDetails();
        beisRegistrationDetails.setAccountDetails(new BeisAccountDetails());
        beisRegistrationDetails.setUserDetails(new BeisUserDetails());
        try {
            String userDn = getUserDn(configurationManager, request.getUsername(), request.getTenant());
            Map<String, String> attributes = getUserManager().userAttributes(directoryConnection, userDn);
            beisRegistrationDetails.getAccountDetails().getOrganisationNameDetail().setOrgName(
                    attributes.get(ldapAttributeOrgname));
            beisRegistrationDetails.getAccountDetails().getPersonNameDetail().setFirstname(
                    attributes.get(ldapAttributeForename));
            beisRegistrationDetails.getAccountDetails().getPersonNameDetail().setSurname(
                    attributes.get(ldapAttributeSurname));
            beisRegistrationDetails.getAccountDetails().setTelNumber(attributes.get(ldapAttributeHomePhone));
            beisRegistrationDetails.getUserDetails().setEmail(attributes.get(ldapAttributeEmail));
            beisRegistrationDetails.getUserDetails().setUsername(attributes.get(ldapAttributeUid));
            BeisAddressDetail addressDetails = new BeisAddressDetail();
            addressDetails.setLine(new ArrayList<String>());
            addressDetails.getLine().add(attributes.get(ldapAttributeStreetLineOne));
            addressDetails.getLine().add(attributes.get(ldapAttributeStreetLineTwo));
            addressDetails.setTown(attributes.get(ldapAttributeTown));
            addressDetails.setCounty(attributes.get(ldapAttributeCounty));
            addressDetails.setPostcode(attributes.get(ldapAttributePostcode));
            addressDetails.setCountry(attributes.get(ldapAttributeCountry));
            addressDetails.setUprn(attributes.get(ldapAttributeUprn));
            beisRegistrationDetails.setContactAddress(addressDetails);
            RetrieveRegisteredDetailsNdsResponse response = new RetrieveRegisteredDetailsNdsResponse();
            response.setBeisRegistrationDetails(beisRegistrationDetails);
            ndsExchange.setResponseMessageBody(response);
        } catch (DirectoryMissingAttributeValueException e) {
            throw new NdsDirectoryException("Unable to find attribute");
        } catch (DirectoryException e) {
            throw new NdsDirectoryException(e.getMessage(), e);
        }
    }
@ Override protected void doProcess ( RetrieveRegisteredDetailsNdsRequest request , DirectoryAccessConnection directoryConnection , NdsSoapRequestAdapterExchangeProxy ndsExchange , DirectoryConnectionConfig directoryConnectionConfigImpl ) throws NdsApplicationException , NdsBusinessException , DirectoryException { String ldapAttributeForename = configurationManager . getString ( "attribute.forename" ) ; String ldapAttributeSurname = configurationManager . getString ( "attribute.surname" ) ; String ldapAttributeHomePhone = configurationManager . getString ( "attribute.homePhone" ) ; String ldapAttributeEmail = configurationManager . getString ( "attribute.email" ) ; String ldapAttributeStreetLineOne = configurationManager . getString ( "attribute.street" ) ; String ldapAttributeStreetLineTwo = configurationManager . getString ( "attribute.street2" ) ; String ldapAttributeTown = configurationManager . getString ( "attribute.town" ) ; String ldapAttributeCounty = configurationManager . getString ( "attribute.county" ) ; String ldapAttributePostcode = configurationManager . getString ( "attribute.postalCode" ) ; String ldapAttributeUprn = configurationManager . getString ( "attribute.uprn" ) ; String ldapAttributeOrgname = configurationManager . getString ( "attribute.organisationName" ) ; String ldapAttributeCountry = configurationManager . getString ( "attribute.country" ) ; String ldapAttributeUid = configurationManager . getString ( "attribute.userid" ) ; BeisRegistrationDetails beisRegistrationDetails = new BeisRegistrationDetails ( ) ; beisRegistrationDetails . setAccountDetails ( new BeisAccountDetails ( ) ) ; beisRegistrationDetails . setUserDetails ( new BeisUserDetails ( ) ) ; try { String userDn = getUserDn ( configurationManager , request . getUsername ( ) , request . getTenant ( ) ) ; Map < String , String > attributes = getUserManager ( ) . userAttributes ( directoryConnection , userDn ) ; beisRegistrationDetails . getAccountDetails ( ) . getOrganisationNameDetail ( ) . setOrgName ( attributes . get ( ldapAttributeOrgname ) ) ; beisRegistrationDetails . getAccountDetails ( ) . getPersonNameDetail ( ) . setFirstname ( attributes . get ( ldapAttributeForename ) ) ; beisRegistrationDetails . getAccountDetails ( ) . getPersonNameDetail ( ) . setSurname ( attributes . get ( ldapAttributeSurname ) ) ; beisRegistrationDetails . getAccountDetails ( ) . setTelNumber ( attributes . get ( ldapAttributeHomePhone ) ) ; beisRegistrationDetails . getUserDetails ( ) . setEmail ( attributes . get ( ldapAttributeEmail ) ) ; beisRegistrationDetails . getUserDetails ( ) . setUsername ( attributes . get ( ldapAttributeUid ) ) ; BeisAddressDetail addressDetails = new BeisAddressDetail ( ) ; addressDetails . setLine ( new ArrayList < String > ( ) ) ; addressDetails . getLine ( ) . add ( attributes . get ( ldapAttributeStreetLineOne ) ) ; addressDetails . getLine ( ) . add ( attributes . get ( ldapAttributeStreetLineTwo ) ) ; addressDetails . setTown ( attributes . get ( ldapAttributeTown ) ) ; addressDetails . setCounty ( attributes . get ( ldapAttributeCounty ) ) ; addressDetails . setPostcode ( attributes . get ( ldapAttributePostcode ) ) ; addressDetails . setCountry ( attributes . get ( ldapAttributeCountry ) ) ; addressDetails . setUprn ( attributes . get ( ldapAttributeUprn ) ) ; beisRegistrationDetails . setContactAddress ( addressDetails ) ; RetrieveRegisteredDetailsNdsResponse response = new RetrieveRegisteredDetailsNdsResponse ( ) ; response . setBeisRegistrationDetails ( beisRegistrationDetails ) ; ndsExchange . setResponseMessageBody ( response ) ; } catch ( DirectoryMissingAttributeValueException e ) { throw new NdsDirectoryException ( "Unable to find attribute" ) ; } catch ( DirectoryException e ) { throw new NdsDirectoryException ( e . getMessage ( ) , e ) ; } }
Retrieve registered user details from Ldap
Retrieve registered user details from Ldap