2012-09-20 31 views
2

我使用alfresco-community-4.0.e,OpenCMIS和primefaces作爲用戶界面來構建Web應用程序。通過OpenCMIS或java API在戶外創建用戶

我需要以編程方式在戶外創建用戶。我試圖創建一個用戶使用下面的代碼:

Blockquote 
if (!personService.personExists("tuser1")) { 
     personService.createPerson(createDefaultProperties("tuser1", "Test", "User1", "[email protected]", "password")); 
     if (logger.isDebugEnabled()) logger.debug("Created tuser1 person"); 
    } 

    if (!personService.personExists("tuser1")) { 
     personService.createPerson(createDefaultProperties("tuser1", "Test", "User1", "[email protected]", "password")); 
     if (logger.isDebugEnabled()) logger.debug("Created tuser1 person"); 
    } 

Blockquote 

但我面臨的身份驗證問題。

我做了一個用於引發openCMIS的露天認證的類,它適用於創建我的自定義內容和其他一些自定義動作。

任何想法爲什麼它現在正在創建用戶或任何其他代碼來編程建立用戶?

+0

如何在露天執行該代碼?你使用自定義的網頁腳本還是什麼? – skuro

回答

3

你的代碼幾乎在那裏,但缺少一條關鍵線。除了創建人,你還需要爲他們創造

相關認證你可能要像

if (this.authenticationService.authenticationExists(userName) == false) 
{ 
    this.authenticationService.createAuthentication(userName, password.toCharArray()); 

    PropertyMap ppOne = new PropertyMap(4); 
    ppOne.put(ContentModel.PROP_USERNAME, userName); 
    ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName"); 
    ppOne.put(ContentModel.PROP_LASTNAME, "lastName"); 
    ppOne.put(ContentModel.PROP_EMAIL, userName+"@example.com"); 
    ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); 

    this.personService.createPerson(ppOne); 
}   
相關問題