To develop an invite external users handler, you must create a Java class that implements the com.adobe.edc.server.spi.ersp.InvitedUserProvider interface. This class contains a method named invitedUser, which the Rights Management service invokes when email addresses are submitted using the Add Invited Users page accessible through LiveCycle Administration Console. (See Testing the invite external users handler.)The invitedUser method accepts a java.util.List instance, which contains string-typed email addresses that are submitted from the Add Invited Users page. The invitedUser method returns an array of InvitedUserProviderResult objects, which is generally a mapping of email addresses to User objects (do not return null).Note: In addition to demonstrating how to create an invite external users handler, this section also uses the LiveCycle ES API.The implementation of the invite external users handler contains a user-defined method named createLocalPrincipalAccount. This method accepts a string value that specifies an email address as a parameter value. The createLocalPrincipalAccount method assumes the pre-existence of a local domain called EDC_EXTERNAL_REGISTERED. You can configure this domain name to be anything you wish; however, for a production application, you may want to integrate with an enterprise domain.The createUsers method iterates over every email address and creates a corresponding User object (a local user in the EDC_EXTERNAL_REGISTERED domain). Finally, the doEmails method is called. This method is intentionally left as a stub in the sample. In a production implementation, it would contain application logic to send invitation email messages to the newly-created users. It is left in the sample to demonstrate the application logic flow of a real application.The following invite external users handler implementation accepts email addresses that are submitted from the Add Invited Users page accessible through LiveCycle Administration Console.package com.adobe.livecycle.samples.inviteexternalusers.provider;import com.adobe.edc.server.spi.ersp.*;import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;import com.adobe.idp.um.api.*;import com.adobe.idp.um.api.infomodel.*;import com.adobe.idp.um.api.impl.UMBaseLibrary;import com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class InviteExternalUsersSample implements InvitedUserProvider{private ServiceClientFactory _factory = null;private User createLocalPrincipalAccount(String email_address) throws Exception{String ret = null;// Assume the local domain already exists!String domain = “EDC_EXTERNAL_REGISTERED”;List aliases = new ArrayList();aliases.add( email_address );User local_user = UMBaseLibrary.createUser( email_address, domain, email_address );local_user.setCommonName( email_address );local_user.setEmail( email_address );local_user.setEmailAliases( aliases );// You may wish to disable the local user until, for example, his registration is processed by a confirmation link//local_user.setDisabled( true );DirectoryManager directory_manager = new DirectoryManagerServiceClient( _factory );String ret_oid = directory_manager.createLocalUser( local_user, null );if( ret_oid == null ){throw new Exception( “FAILED TO CREATE PRINCIPAL FOR EMAIL ADDRESS: “ + email_address );}return local_user;}protected User[] createUsers( List emails ) throws Exception{ArrayList ret_users = new ArrayList();_factory = ServiceClientFactory.createInstance();Iterator iter = emails.iterator();while( iter.hasNext() ){String current_email = (String)iter.next();ret_users.add( createLocalPrincipalAccount( current_email ) );}return (User[])ret_users.toArray( new User[0] );}protected void doInvitations(List emails){// Here you may choose to send the users who were created an invitation email// This step is completely optional, depending on your requirements.}public InvitedUserProviderResult[] invitedUser(List emails){// This sample demonstrates the workflow for inviting a user via emailtry{User[] principals = createUsers(emails);InvitedUserProviderResult[] result = new InvitedUserProviderResult[principals.length];for( int i = 0; i < principals.length; i++ ){result[i] = new InvitedUserProviderResult();result[i].setEmail( (String)emails.get( i ) );result[i].setUser( principals[i] );}doInvitations(emails);System.out.println( “SUCCESSFULLY INVITED “ + result.length + “ USERS” );return result;}catch( Exception e ){System.out.println( “FAILED TO INVITE USERS FOR INVITE USERS SAMPLE” );e.printStackTrace();return new InvitedUserProviderResult[0];}}}
| Programming with LiveCycle ES (LiveDocs) |
| Adobe LiveCycle ES Update 1 |
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000912_2.html