@Override public boolean hasRole(User user, String role) { Authorization authorization = m_useradmin.getAuthorization(user); return authorization.hasRole(role); }
public static CompositeData encodeAuthorization(Authorization authorization) throws Exception { if(authorization==null) return null; Object[] itemValues = new Object[2]; String[] itemNames = CompositeDataItemNames.AUTHORIZATION; itemValues[0] = authorization.getName(); itemValues[1] = authorization.getRoles(); return new CompositeDataSupport( OSGiTypes.AUTHORIZATION, itemNames, itemValues); } public static CompositeData encodeLogEntry(LogEntry entry)
String[] roleNames = authorization.getRoles();
public String getName() { return auth.getName(); } }
String[] uaRoles = authorization.getRoles(); Roles wicketRoles = new Roles(); wicketRoles.addAll(Arrays.asList(uaRoles));
@Override public void valueUnbound(HttpSessionBindingEvent arg0) { String id = ses.getId(); logger.info("Session binding event: unbound {}", id); accMngr.logout(auth.getName()); }
@Override public boolean isUserInRole(String role) { Authorization authorization = (Authorization) getAttribute(HttpContext.AUTHORIZATION); if (authorization != null) { return authorization.hasRole(role); } return super.isUserInRole(role); }
public String[] getImpliedRoles(String username) throws Exception { try { Role role = ac.getUserAdmin().getRole(username); if (role.getType() == Role.USER && role instanceof User) { return ac.getUserAdmin().getAuthorization((User) role) .getRoles(); } else return null; } catch (NullPointerException npe) { ac.debug("UserAdmin not available. "); return null; } }
@Override public boolean isUserInRole(String role) { Authorization authorization = (Authorization) getAttribute(HttpContext.AUTHORIZATION); if (authorization != null) { return authorization.hasRole(role); } return super.isUserInRole(role); }
@Override public Group getGroup(User user) { Authorization auth = m_useradmin.getAuthorization(user); String[] roles = auth.getRoles(); if (roles != null) { for (String role : roles) { Role result = m_useradmin.getRole(role); if (result.getType() == Role.GROUP) { Group group = (Group) result; Role[] members = group.getMembers(); if (members != null) { for (Role r : members) { if (r.getType() == Role.USER && r.getName().equals(user.getName())) { return group; } } } } } } return null; }
@Override public boolean isAllAppsPermitted(String user) { User usr = (User) usrAdmin.getRole(user); if (usr == null) return false; Authorization auth = usrAdmin.getAuthorization(usr); return auth.hasRole(ALLAPPS); }
@Override public boolean isNoAppPermitted(String user) { User usr = (User) usrAdmin.getRole(user); if (usr == null) return false; Authorization auth = usrAdmin.getAuthorization(usr); return auth.hasRole(NOAPPS); }
/** * Developers can override this method. * * For example, if a developer has a modeled or otherwise controlled access to the UserAdmin service, it is possible * to provide specialized access here. * * @param role the name of the action to test for authorization * * @return {@code true} if the currently logged in user is authorized to perform the action described in the "role" * parameter, {@code false} otherwise */ public boolean isAuthorized(String role) { // This is totally hackish. // The only way to avoid this is to use something other than // AuthenticatedWebSession. As it stands, we are trying to force // a use case on AuthenticatedWebSession that it was not intended for. final PaxWicketAuthentication paxWicketAuth = (PaxWicketAuthentication) AuthenticatedWebSession.get(); final String loginName = paxWicketAuth.getLoggedInUser(); final User user = getUser(userAdmin, loginName); if (null == user) { return false; } final Authorization auth = userAdmin.getAuthorization(user); return auth.hasRole(role); }
int count = 0; for (String role : new String[] { "viewArtifact", "viewFeature", "viewDistribution", "viewTarget" }) { if (auth.hasRole(role)) { count++; if (auth.hasRole("viewArtifact")) { m_grid.addComponent(artifactsPanelWrapper, count, 2); m_grid.addComponent(m_artifactToolbar, count, 1); m_featureToolbar = createFeatureToolbar(); if (auth.hasRole("viewFeature")) { m_grid.addComponent(m_featuresPanel, count, 2); m_grid.addComponent(m_featureToolbar, count, 1); m_distributionToolbar = createDistributionToolbar(); if (auth.hasRole("viewDistribution")) { m_grid.addComponent(m_distributionsPanel, count, 2); m_grid.addComponent(m_distributionToolbar, count, 1); m_targetToolbar = createTargetToolbar(); if (auth.hasRole("viewTarget")) { m_grid.addComponent(m_targetsPanel, count, 2); m_grid.addComponent(m_targetToolbar, count, 1);