/** * {@inheritDoc} * * @see org.opencastproject.security.api.UserProvider#getOrganization() */ @Override public String getOrganization() { return organization.getId(); }
/** * {@inheritDoc} * * @see org.opencastproject.security.api.UserProvider#getOrganization() */ @Override public String getOrganization() { return organization.getId(); }
/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (!(obj instanceof Organization)) return false; return ((Organization) obj).getId().equals(id); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Organization)) return false; return ((Organization) obj).getId().equals(id); }
/** * {@inheritDoc} * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, * javax.servlet.FilterChain) */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Make sure we have an organization Organization org = securityService.getOrganization(); if (org == null) { ((HttpServletResponse) response).sendError(HttpServletResponse.SC_NOT_FOUND); return; } // Get a hold of the security filter for that organization Filter filter = orgSecurityFilters.get(org.getId()); if (filter == null) { ((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN); return; } filter.doFilter(request, response, chain); } }
private void refresh() { final long now = System.currentTimeMillis(); if (now - lastRefresh > refreshInterval) { byId.clear(); byHost.clear(); for (Organization org : persistence.getOrganizations()) { byId.put(org.getId(), org); // (host, port) for (Map.Entry<String, Integer> server : org.getServers().entrySet()) { byHost.put(tuple(server.getKey(), server.getValue()), org); } } lastRefresh = now; } } }
public SecurityContext(SecurityService sec, Organization org, User user) { if (ne(org, user.getOrganization())) { throw new IllegalArgumentException("User is not a member of organization " + org.getId()); } this.sec = sec; this.user = user; this.org = org; }
@GET @Path("config.json") @Produces(MediaType.APPLICATION_JSON) @RestQuery(name = "configJson", description = "Paella configuration", reponses = { @RestResponse(description = "Returns the paella configuration", responseCode = HttpServletResponse.SC_OK) }, returnDescription = "") public String getMyInfo() throws IOException { // Add the current user's organizational information Organization org = securityService.getOrganization(); File configFile = new File(PathSupport.concat(new String[] { paellaConfigFolder, org.getId(), "config.json" })); return FileUtils.readFileToString(configFile, "UTF-8"); } }
/** * Adds the organization to the list of organizations. * * @param organization * the organization */ public void addOrganization(Organization organization) { boolean contains = persistence.containsOrganization(organization.getId()); if (contains) throw new IllegalStateException("Can not add an organization with id '" + organization.getId() + "' since an organization with that identifier has already been registered"); persistence.storeOrganization(organization); cache.invalidate(); fireOrganizationRegistered(organization); }
this.roles = new HashSet<JaxbRole>(); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!");
/** * Constructs a user with the specified username, password, provider and roles. * * @param username * the username * @param password * the password * @param organization * the organization * @param provider * the provider * @param manageable * whether the user is manageable * @param roles * the roles */ public JpaUser(String username, String password, JpaOrganization organization, String provider, boolean manageable, Set<JpaRole> roles) { this(username, password, organization, null, null, provider, manageable); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!"); } this.roles = roles; }
/** * Constructs a user with the specified username, name, email, login mechanism, last login date, organization and * roles. * * @param username * the username * @param name * the name * @param email * the email address * @param loginMechanism * the login mechanism * @param lastLogin * the last login date * @param organization * the organization * @param roles * the roles */ public JpaUserReference(String username, String name, String email, String loginMechanism, Date lastLogin, JpaOrganization organization, Set<JpaRole> roles) { this(username, name, email, loginMechanism, lastLogin, organization); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!"); } this.roles = roles; }
/** * Constructs a user with the specified username, password, name, email, provider and roles. * * @param username * the username * @param password * the password * @param organization * the organization * @param name * the name * @param email * the email * @param provider * the provider * @param manageable * whether the user is manageable * @param roles * the roles */ public JpaUser(String username, String password, JpaOrganization organization, String name, String email, String provider, boolean manageable, Set<JpaRole> roles) { this(username, password, organization, name, email, provider, manageable); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!"); } this.roles = roles; }
public JpaJob(User currentUser, Organization organization, ServiceRegistrationJpaImpl creatingService, String operation, List<String> arguments, String payload, boolean dispatchable, float load) { this.creator = currentUser.getUsername(); this.organization = organization.getId(); this.creatorServiceRegistration = creatingService; this.jobType = creatingService.getServiceType(); this.operation = operation; this.arguments = arguments; this.payload = payload; this.dispatchable = dispatchable; this.jobLoad = load; this.status = Status.INSTANTIATED.ordinal(); }
@Override public boolean accepts(String baseUrl) { // Don't accept URLs without an organization context // (for example from the ServiceRegistry JobProducerHeartbeat) if (securityService.getOrganization() == null) return false; String orgId = securityService.getOrganization().getId(); try { new URI(baseUrl); KeyEntry keyEntry = getKeyEntry(baseUrl); return ((keyEntry != null) && (StringUtils.equals(keyEntry.getOrganization(), ANY_ORGANIZATION) || StringUtils.equals(keyEntry.getOrganization(), orgId))); } catch (URISyntaxException e) { getLogger().debug("Unable to support url {} because", baseUrl, e); return false; } }
/** * Get the URI for a static file resource depending on whether to get it direct from Opencast or from a webserver. * * @param uuid * The unique identifier for the static file. * @return The URL for the static file resource. * @throws NotFoundException * if the resource couldn't been found */ public URI getStaticFileURL(String uuid) throws NotFoundException { if (useWebserver && webserverURL.isSome()) { return URI.create(UrlSupport.concat(webserverURL.get(), securityService.getOrganization().getId(), uuid, staticFileService.getFileName(uuid))); } else { return URI.create(UrlSupport.concat(serverUrl, STATICFILES_URL_PATH, uuid)); } }
tx = em.getTransaction(); tx.begin(); JpaOrganization organizationEntity = getOrganizationEntity(org.getId(), em); if (organizationEntity == null) { JpaOrganization organization = new JpaOrganization(org.getId(), org.getName(), org.getServers(), org.getAdminRole(), org.getAnonymousRole(), org.getProperties()); em.persist(organization);
/** * Constructs an organization from an organization * * @param org * the organization */ public static JaxbOrganization fromOrganization(Organization org) { if (org instanceof JaxbOrganization) return (JaxbOrganization) org; return new JaxbOrganization(org.getId(), org.getName(), org.getServers(), org.getAdminRole(), org.getAnonymousRole(), org.getProperties()); }
final Organization organization = securityService.getOrganization(); if (organization != null) { httpUriRequest.setHeader(SecurityConstants.ORGANIZATION_HEADER, organization.getId()); final User currentUser = securityService.getUser(); if (currentUser != null) {
if (securityService != null) { job.setCreator(securityService.getUser().getUsername()); job.setOrganization(securityService.getOrganization().getId());