2013-08-20 69 views
0

我的筆記本上運行了一個nexus oss實例。我想要做的是,我將發送一個userlogintoken發送給此連接oss的請求,並從nexus oss插件獲取userlogintoken,然後對照在另一個框中運行的teamforge(我的應用程序名稱)對其進行身份驗證。由於logintoken對遠程服務器的身份驗證

在nexus oss他們使用shiro。所以我也會在我的nexus插件中使用shiro,它會對teamforge進行身份驗證。我不知道從哪裏開始。我可以舉一些可以單獨運行的例子,它可以完成上述任務,以便我可以從那裏開始移動。

所以要求基本上是我需要給服務器url和userlogintoken shiro並且必須使用提供的logintoken提供的服務器url進行身份驗證。

我引用了很多搜索這種shiro示例的地方,因爲我對shiro非常陌生,但是我沒有找到可以通過遠程服務器url進行身份驗證的示例(在我的情況下是teamforge url)。是從用戶名,ini文件中存儲的密碼或數據庫中進行身份驗證的示例,但未找到適用於我的用例的示例。

有人能指導我嗎?

回答

1

嘗試實現自己的org.apache.shiro.realm.AuthorizingRealm你可以把它通過Shiro.ini配置很容易。您必須創建與ini文件中的屬性具有相同名稱的公共getter/setter。

您需要實施protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)方法。他們被稱爲currentUser.login(token)

Shiro.ini

customRealm= me.harish.shiro.realm.CustomRealm 
customRealm.url = http://teamforge.com/?loginme 
customRealm.apiKey = ABCD 
customRealm.apiSecret = magic1 

securityManager.realms= $customRealm 

一些有用的鏈接:

https://www.google.sk/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#fp=5cd33cfa2e98ac64&q=custom%20realm%20shiro

http://shiro.apache.org/realm.html