本文整理汇总了Java中org.apache.wicket.authroles.authorization.strategies.role.Roles类的典型用法代码示例。如果您正苦于以下问题:Java Roles类的具体用法?Java Roles怎么用?Java Roles使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Roles类属于org.apache.wicket.authroles.authorization.strategies.role包,在下文中一共展示了Roles类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInstantiationAuthorized
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
if (componentClass == CmsPage.class) {
RequestCycle requestCycle = RequestCycle.get();
String pageId = requestCycle.getRequest().getQueryParameters().getParameterValue("pageId").toString("");
PageRoleTable pageRoleTable = Tables.PAGE_ROLE.as("pageRoleTable");
RoleTable roleTable = Tables.ROLE.as("roleTable");
DSLContext context = Spring.getBean(DSLContext.class);
List<String> roles = context.select(roleTable.NAME).from(roleTable).innerJoin(pageRoleTable).on(roleTable.ROLE_ID.eq(pageRoleTable.ROLE_ID)).where(pageRoleTable.PAGE_ID.eq(pageId)).fetchInto(String.class);
Roles r = new Roles();
if (roles != null && !roles.isEmpty()) {
r.addAll(roles);
}
return hasAny(r);
} else {
return super.isInstantiationAuthorized(componentClass);
}
}
示例2: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
Roles ret = new Roles();
if(isSignedIn())
{
Set<? extends OSecurityRole> roles = getUser().getRoles();
for (OSecurityRole oRole : roles) {
ret.add(oRole.getName());
OSecurityRole parent = oRole.getParentRole();
while(parent!=null && !ret.contains(parent.getName()))
{
ret.add(parent.getName());
parent = parent.getParentRole();
}
}
}
return ret;
}
示例3: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
Roles roles = new Roles();
//todo - used for wicket auth roles...
MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
if (principal == null) {
return roles;
}
for (Authorization authz : principal.getAuthorities()) {
roles.addAll(authz.getAction());
}
return roles;
}
示例4: isAuthorized
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
public static boolean isAuthorized(Collection<String> actions) {
if (actions == null || actions.isEmpty()) {
return true;
}
Roles roles = new Roles(AuthorizationConstants.AUTZ_ALL_URL);
roles.add(AuthorizationConstants.AUTZ_GUI_ALL_URL);
roles.add(AuthorizationConstants.AUTZ_GUI_ALL_DEPRECATED_URL);
roles.addAll(actions);
if (((AuthenticatedWebApplication) AuthenticatedWebApplication.get()).hasAnyRole(roles)) {
return true;
}
return false;
}
示例5: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
if (getUserDetails() != null) {
return new Roles(getUserDetails().getPermissions().stream().map(sp -> sp.getSingularId()).collect(Collectors.toList()).toArray(new String[0]));
}
return new Roles();
}
示例6: authenticate
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
protected boolean authenticate(String username, String password) {
try {
User user = new User(username, Roles.USER);
this.xmppService = new XmppService(user.getUri(), password);
this.intercloudService = new IntercloudService(this.xmppService);
this.user = user;
return true;
} catch (Exception e) {
logger.error("Cannot connect to xmpp server. jid: {}", username, e);
return false;
}
}
示例7: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
if (isSignedIn() && user != null) {
return user.getRoles();
}
return null;
}
示例8: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
/**
* Returns the current user roles.
*
* @return current user roles
*/
@Override
public Roles getRoles() {
if (!rolesInitialized) {
Collection<? extends GrantedAuthority> authorities = authenticationService.getAuthorities();
for (GrantedAuthority authority : authorities) {
roles.add(authority.getAuthority());
}
rolesInitialized = true;
}
return roles;
}
示例9: signOutWithoutCleaningUpRedirectUrl
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
/**
* @deprecated Only useful when using OWSI-Core's redirection mechanism, which is deprecated.
*
* @see {@link #registerRedirectUrl(String)} for information about alternative mechanisms.
*/
@Deprecated
public void signOutWithoutCleaningUpRedirectUrl() {
userModel.setObject(null);
roles = new Roles();
rolesInitialized = false;
permissions = Lists.newArrayList();
permissionsInitialized = false;
authenticationService.signOut();
super.signOut();
}
示例10: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
if (rights.isEmpty()) {
isSignedIn();
}
Roles r = new Roles();
for (Right right : rights) {
r.add(right.name());
}
return r;
}
示例11: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles()
{
Roles roles = new Roles();
if (isSignedIn()) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
for (GrantedAuthority authority : authentication.getAuthorities()) {
roles.add(authority.getAuthority());
}
}
return roles;
}
示例12: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
Roles roles = new Roles();
if (isSignedIn()) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
for (GrantedAuthority authority : authentication.getAuthorities()) {
roles.add(authority.getAuthority());
}
}
return roles;
}
示例13: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
Roles roles = new Roles();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication !=null) {
for (GrantedAuthority authority : authentication.getAuthorities()) {
roles.add(authority.getAuthority());
}
} else {
logger.warn("Authentication from SecurityContextHolder is null. No role affected.");
}
return roles;
}
示例14: getRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
@Override
public Roles getRoles() {
if (useAuthentication) {
return super.getRoles();
} else {
if (getPaasUser() != null) {
return new Roles(getPaasUser().getPaasUserRole().name());
}
else {
return new Roles("ROLE_USER");
}
}
}
示例15: setWicketRoles
import org.apache.wicket.authroles.authorization.strategies.role.Roles; //导入依赖的package包/类
private void setWicketRoles(Authentication authentication) {
Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
String[] authorityRoles = new String[authorities.size()];
int i = 0;
for (GrantedAuthority authority : authorities) {
String role = authority.getAuthority();
authorityRoles[i] = role;
i++;
}
roles = new Roles(authorityRoles);
}