Example usage for org.apache.wicket.authroles.authorization.strategies.role Roles hasAnyRole

List of usage examples for org.apache.wicket.authroles.authorization.strategies.role Roles hasAnyRole

Introduction

In this page you can find the example usage for org.apache.wicket.authroles.authorization.strategies.role Roles hasAnyRole.

Prototype

public boolean hasAnyRole(Roles roles) 

Source Link

Document

Whether this roles object contains any of the provided roles.

Usage

From source file:com.barchart.kerberos.server.ui.User.java

License:Apache License

/**
 * Whether this user has any of the given roles.
 * /* www .  ja va2s  .c om*/
 * @param roles
 *            set of roles
 * @return whether this user has any of the given roles
 */
public boolean hasRole(final Roles roles) {
    return roles.hasAnyRole(roles);
}

From source file:com.olegchir.flussonic_userlinks.auth.ComponentAuth.java

License:Apache License

public static Component protect(Panel panel) {
    Roles roles = AuthChecker.extractRoles();
    boolean authorized = true;

    Class clazz = panel.getClass();
    AuthorizeViewContentOnlyFor classAnnotation = (AuthorizeViewContentOnlyFor) clazz
            .getAnnotation(AuthorizeViewContentOnlyFor.class);
    if (classAnnotation != null) {
        authorized = roles.hasAnyRole(new Roles(classAnnotation.value()));
    }/*from w  w  w .  jav  a 2  s .c o m*/

    return authorized ? panel : new ULEmptyPanel(panel.getId());
}

From source file:com.olegchir.flussonic_userlinks.wicket.SecurityResolver.SecurityResolver.java

License:Apache License

@Override
public Component resolve(final MarkupContainer container, final MarkupStream markupStream,
        final ComponentTag tag) {
    // It must be <wicket:...>
    if (tag instanceof WicketTag) {
        final WicketTag wicketTag = (WicketTag) tag;

        // It must be <wicket:security...>
        if (TAGNAME_SECURITY.equalsIgnoreCase(tag.getName())) {
            boolean authorized = true;
            String rolesInOneString = StringUtils.trimToNull(wicketTag.getAttribute("onlyroles"));
            if (null != rolesInOneString) {
                Roles roles = AuthChecker.extractRoles();
                authorized = roles.hasAnyRole(new Roles(rolesInOneString));
            }//from  w  w w.j a  va 2 s  .  c  o  m

            String id = wicketTag.getId() + container.getPage().getAutoIndex();

            Component result = new TransparentWebMarkupContainer(id);
            if (!authorized) {
                result.setVisible(false);
            }

            return result;
        }
    }

    // We were not able to handle the componentId
    return null;
}

From source file:cz.muni.fi.pa165.languageschoolweb.security.UserRolesAuthorizer.java

License:Apache License

/**
 * @see org.apache.wicket.authorization.strategies.role.IRoleCheckingStrategy#hasAnyRole(Roles)
 *//*w  w w . ja v a  2 s. c o  m*/
@Override
public boolean hasAnyRole(Roles roles) {
    SpringAuthenticatedWebSession session = (SpringAuthenticatedWebSession) AuthenticatedWebSession.get();

    Roles loggedRoles = session.getLoggedRoles();
    return loggedRoles.hasAnyRole(roles);
}