Package org.eurekastreams.commons.exceptions

Examples of org.eurekastreams.commons.exceptions.AuthorizationException


            }
        }

        if (!found && streamId != 0)
        {
            throw new AuthorizationException(inActionContext.getPrincipal().getAccountId()
                    + " cannot modify stream " + streamId);
        }
    }
View Full Code Here


        try
        {
            SecurityContext securityCtx = SecurityContextHolder.getContext();
            if (securityCtx == null)
            {
                throw new AuthorizationException("No security context available.");
            }

            Authentication auth = securityCtx.getAuthentication();
            if (auth == null)
            {
                return null;
            }

            Object obj = auth.getPrincipal();
            if (obj instanceof UserDetails)
            {
                UserDetails user = (UserDetails) obj;
                ExtendedUserDetails extUser = (ExtendedUserDetails) user;
                return new DefaultPrincipal(extUser.getUsername(), extUser.getPerson().getOpenSocialId(), extUser
                        .getPerson().getId());
            }
            else
            {
                return null;
            }
        }
        catch (Exception ex)
        {
            logger.error("Error occurred populating Principal object for current request.", ex);
            if (exceptionOnError)
            {
                throw new AuthorizationException("Error occurred populating Principal object for current request.");
            }
            else
            {
                return null;
            }
View Full Code Here

            // anyone can post to resource stream.
            break;
        default:
            logger.error("Error occurred Performing authorization to post an Activity to stream, unsupported"
                    + "destination stream type.");
            throw new AuthorizationException("Unsupported Destination Stream Type.");

        }
    }
View Full Code Here

        PersonModelView currentPerson = getPersonModelViewByAccountIdMapper.execute(inActivityDTO
                .getDestinationStream().getUniqueIdentifier());

        if (currentPerson == null)
        {
            throw new AuthorizationException("Cannot locate current person.  The activity destination stream id is "
                    + inActivityDTO.getDestinationStream().getUniqueIdentifier());
        }

        boolean isActorTheStreamOwner = inPrincipal.getAccountId().equalsIgnoreCase(
                inActivityDTO.getDestinationStream().getUniqueIdentifier());

        // Test if the user is the owner of the stream being posted to or the stream
        // has been authorized for this type of interaction.
        if (isActorTheStreamOwner || currentPerson.isStreamPostable())
        {
            return;
        }

        throw new AuthorizationException("Current user does not have access rights to post this activity.");
    }
View Full Code Here

            {
                return;
            }
            else
            {
                throw new AuthorizationException("Group is public but the poster is not a "
                        + "coordinator and the group is configured to not allow stream posts.");
            }
        }

        // The group is private, continue forward testing private group authorization.

        if (isUserCoordinator)
        {
            // user is a coordinator
            return;
        }

        if (groupFollowersDAO.execute(currentDomainGroup.getEntityId()).contains(inPrincipal.getId())
                && currentDomainGroup.isStreamPostable())
        {
            // user is a follower
            return;
        }

        throw new AuthorizationException("Current user does not have access rights to post this activity.");
    }
View Full Code Here

            if (!group.isPublic())
            {
                Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId());
                if (!groupsUserCanAccess.contains(group.getId()))
                {
                    throw new AuthorizationException(inActionContext.getPrincipal().getAccountId()
                            + " cannot access popular hashtags for group with short name " + group.getShortName());
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.commons.exceptions.AuthorizationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.