本文整理汇总了Java中org.apache.wicket.authorization.IAuthorizationStrategy类的典型用法代码示例。如果您正苦于以下问题:Java IAuthorizationStrategy类的具体用法?Java IAuthorizationStrategy怎么用?Java IAuthorizationStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAuthorizationStrategy类属于org.apache.wicket.authorization包,在下文中一共展示了IAuthorizationStrategy类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAuthorizationStrategy
import org.apache.wicket.authorization.IAuthorizationStrategy; //导入依赖的package包/类
/**
* Initializes the authorization strategy for the web application. Pages,
* which implement the {@link AuthenticatedWebPage} interface, are only
* accessible for authenticated users.
*/
private void setAuthorizationStrategy() {
this.getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() {
@Override
public boolean isActionAuthorized(final Component component, final Action action) {
// authorize everything
return true;
}
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) {
// Check if the new Page requires authentication
// (implements the marker interface)
if (AuthenticatedWebPage.class.isAssignableFrom(componentClass)) {
// Is user signed in?
if (((AuthenticatedSession) Session.get()).isSignedIn()) {
// okay to proceed
return true;
}
// Intercept the request, but remember the target
// for later.
// Invoke Component.continueToOriginalDestination()
// after successful logon to
// continue with the target remembered.
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
// okay to proceed
return true;
}
});
}
示例2: getAuthorizationStrategy
import org.apache.wicket.authorization.IAuthorizationStrategy; //导入依赖的package包/类
public CompoundAuthorizationStrategy getAuthorizationStrategy() {
IAuthorizationStrategy authorizationStrategy = getSecuritySettings().getAuthorizationStrategy();
if (!(authorizationStrategy instanceof CompoundAuthorizationStrategy)) {
throw new IllegalStateException(
"Unexpected authorization strategy: " + authorizationStrategy.getClass());
}
return (CompoundAuthorizationStrategy) authorizationStrategy;
}
示例3: addSecurityAuthorization
import org.apache.wicket.authorization.IAuthorizationStrategy; //导入依赖的package包/类
protected void addSecurityAuthorization() {
Class<? extends Page> signInPageClass = LoginPage.class;
if (CasUtil.isCasUsed()) {
signInPageClass = CasLoginPage.class;
}
IAuthorizationStrategy authStrategy = new SimplePageAuthorizationStrategy(SecurePage.class, signInPageClass) {
@Override
protected boolean isAuthorized() {
boolean b = NextServerSession.get().isSignedIn();
if (!b) {
if (CasUtil.isCasUsed()) {
LOG.debug("Checking if context contains CAS authentication");
b = NextServerSession.get().checkForSignIn();
if (!b) {
String serviceUrl = CasUtil.getServiceProperties().getService();
String loginUrl = CasUtil.getLoginUrl();
LOG.debug("cas authentication: service URL: " + serviceUrl);
String redirectUrl = loginUrl + "?service=" + serviceUrl;
LOG.debug("attempting to redirect to: " + redirectUrl);
throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl));
}
}
}
return b;
}
};
getSecuritySettings().setAuthorizationStrategy(authStrategy);
}
示例4: getAuthorizationStrategy
import org.apache.wicket.authorization.IAuthorizationStrategy; //导入依赖的package包/类
protected IAuthorizationStrategy getAuthorizationStrategy() {
return Application.get().getSecuritySettings().getAuthorizationStrategy();
}
示例5: getAuthorizationStrategy
import org.apache.wicket.authorization.IAuthorizationStrategy; //导入依赖的package包/类
@Override
public IAuthorizationStrategy getAuthorizationStrategy() {
return new OntopolyAuthorizationStrategy();
}