List of usage examples for org.apache.wicket.authroles.authorization.strategies.role Roles Roles
public Roles(final Collection<String> roles)
From source file:com.adamjan.AuthorizedSession.java
License:Open Source License
@Override public Roles getRoles() { //base on saved information return user roles //getAttribute("token") return new Roles(new String[] { SystemRoles.ADMIN, SystemRoles.USER } /*, and other roles*/); }
From source file:com.apachecon.memories.session.MemoriesWebSession.java
License:Apache License
@Override public boolean authenticate(String username, String password) { if (username.trim().length() == 0 || password.trim().length() == 0) { warn("Provide user and password"); return false; }// w w w . j a va 2 s .c om if (users.getProperty(username) != null) { if (users.getProperty(username).equals(MD5Util.encode(password))) { roles = new Roles("admin"); return true; } warn("Wrong username or password"); } return false; }
From source file:com.barchart.kerberos.server.security.zMyAuthenticatedWebSession.java
License:Apache License
/** * @see org.apache.wicket.authentication.AuthenticatedWebSession#getRoles() *//*w w w . ja va 2s . c o m*/ @Override public Roles getRoles() { if (isSignedIn()) { // If the user is signed in, they have these roles return new Roles(Roles.ADMIN); } return null; }
From source file:com.barchart.kerberos.server.ui.User.java
License:Apache License
/** * Construct.//from w w w .ja va2 s .c o m * * @param uri * the unique user id * @param roles * a comma seperated list of roles (e.g. USER,ADMIN) */ public User(final String uri, final String roles) { if (uri == null) { throw new IllegalArgumentException("uid must be not null"); } if (roles == null) { throw new IllegalArgumentException("roles must be not null"); } this.uri = uri; this.roles = new Roles(roles); }
From source file:com.cubeia.backoffice.web.BackofficeAuthSession.java
License:Open Source License
@Override public boolean authenticate(String userName, String password) { AuthenticationManager authManager = ((BackofficeApplication) getApplication()).getAuthenticationManager(); if (!authManager.authenticate(userName, password)) { log.debug("authentication failure: {}/{}", userName, password); return false; } else {/*from www . j a v a 2 s . co m*/ this.userName = userName; Set<BackofficeRole> rolesForUser = authManager.getRolesForUser(userName); ArrayList<String> rolesList = new ArrayList<String>(); for (BackofficeRole r : rolesForUser) { rolesList.add(r.name()); } roles = new Roles(rolesList.toArray(new String[0])); return true; } }
From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java
License:Apache License
public static boolean isAuthorized(Collection<String> actions) { if (actions == null || actions.isEmpty()) { return true; }/*from ww w . j a v a 2s .c o m*/ 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; }
From source file:com.evolveum.midpoint.web.util.WebMiscUtil.java
License:Apache License
public static boolean isAuthorized(String... action) { if (action == null) { return true; }// w w w . j a v a2s . co m List<String> actions = Arrays.asList(action); Roles roles = new Roles(AuthorizationConstants.AUTZ_ALL_URL); roles.addAll(actions); if (((AuthenticatedWebApplication) AuthenticatedWebApplication.get()).hasAnyRole(roles)) { return true; } return false; }
From source file:com.francetelecom.clara.cloud.presentation.utils.PaasTestSession.java
License:Apache License
@Override public Roles getRoles() { if (useAuthentication) { return super.getRoles(); } else {//from w w w. ja va 2s.com if (getPaasUser() != null) { return new Roles(getPaasUser().getPaasUserRole().name()); } else { return new Roles("ROLE_USER"); } } }
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())); }// www. ja va 2 s . com 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 ww w . j a v a 2s.c om 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; }