我想要一個遠程系統爲我們的CQ5執行用戶認證。我猜測道路上的AuthenticationHandler是一個方向。如果是這樣,AuthenticationHandler如何工作。而且,在CQ5中,我是如何實現一個Custom AuthenticationHandler的?我如何才能使它成爲一個OSGi包(或片段包)並將其安裝到CQ5中?執行CQ5中的自定義認證處理程序
如果可能的話,一些代碼示例與OSGi清單表示讚賞。
我想要一個遠程系統爲我們的CQ5執行用戶認證。我猜測道路上的AuthenticationHandler是一個方向。如果是這樣,AuthenticationHandler如何工作。而且,在CQ5中,我是如何實現一個Custom AuthenticationHandler的?我如何才能使它成爲一個OSGi包(或片段包)並將其安裝到CQ5中?執行CQ5中的自定義認證處理程序
如果可能的話,一些代碼示例與OSGi清單表示讚賞。
你可以找到Sling AuthenticationHandler如何工作的說明here。你也可以看看Sling FormAuthenticationHandler來源爲例。您可以在maven-bundle-plugin的配置下看到該項目的POM file中OSGi配置的詳細信息。
如果您只需檢查密碼或同步用戶帳戶,則可以使用custom CQ5 LoginModule。
我會通過查看兔崽子AbstractLoginModule http://jackrabbit.apache.org/api/2.4/org/apache/jackrabbit/core/security/authentication/AbstractLoginModule.html
開始我的例子,是寫一個定製的解決方案/片段捆綁的,但它有很多件。我們正在實施Gigya(社交網絡登錄)的內容。
我們有一些其他類實現MyAbstractLoginModule。如果您需要,我可以深入挖掘並獲得更多示例。希望這可以讓你開始走上正確的道路。
public abstract class MyAbstractLoginModule extends AbstractLoginModule {
static private final Logger logger = LoggerFactory.getLogger(MyAbstractLoginModule.class);
protected Session session;
protected UserManager userManager;
protected ValueFactory valueFactory;
protected long tokenExpiration = 7200000L;
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
if (options.containsKey("tokenExpiration")) {
try {
this.tokenExpiration = Long.parseLong(options.get("tokenExpiration").toString());
logger.debug("- Token expiration -> '" + this.tokenExpiration + "'");
} catch (NumberFormatException e) {
logger.warn("Unabled to parse token expiration: ", e);
}
}
super.initialize(subject, callbackHandler, sharedState, options);
}
/**
* Initiates the login module
*
* @param ch
* @param ses
* @param map
* @throws LoginException
*/
@Override
protected void doInit(CallbackHandler ch, Session ses, Map map) throws LoginException {
logger.trace("doInit");
SessionImpl session = (SessionImpl) ses;
try {
this.session = session;
this.userManager = session.getUserManager();
this.valueFactory = session.getValueFactory();
} catch (RepositoryException e) {
throw new LoginException("Unable to retrieve principal editor: " + e.toString());
}
}
/**
* Impersonates users
*
* @param prncpl
* @param c
* @return
* @throws RepositoryException
* @throws LoginException
*/
@Override
protected boolean impersonate(Principal prncpl, Credentials c) throws RepositoryException, LoginException {
Authorizable authrz = this.userManager.getAuthorizable(principal);
if ((authrz == null) || (authrz.isGroup())) {
return false;
}
Subject impersSubject = getImpersonatorSubject(credentials);
User user = (User) authrz;
if (user.getImpersonation().allows(impersSubject)) {
return true;
}
throw new FailedLoginException("attempt to impersonate denied for " + principal.getName());
}
@Override
protected boolean isPreAuthenticated(Credentials creds) {
return false;
}
}
@Woodifer,請你幫我[這裏] [1]? [1]:http://stackoverflow.com/questions/22978803/doubts-on-3rd-party-authentication – 2014-04-13 04:39:43
可以請你幫我在這裏:HTTP://stackoverflow.com/questions/22978803 /疑慮上,第三方認證 – 2014-04-13 04:47:36