Examples of NotAuthorizedException


Examples of javax.ws.rs.NotAuthorizedException

       
        Form form = readFormData(message);   
        String assertionType = form.getData().getFirst(Constants.CLIENT_AUTH_ASSERTION_TYPE);
        String decodedAssertionType = assertionType != null ? HttpUtils.urlDecode(assertionType) : null;
        if (decodedAssertionType == null || !Constants.CLIENT_AUTH_SAML2_BEARER.equals(decodedAssertionType)) {
            throw new NotAuthorizedException(errorResponse());
        }
        String assertion = form.getData().getFirst(Constants.CLIENT_AUTH_ASSERTION_PARAM);
       
        Element token = readToken(message, assertion);        
        String clientId = form.getData().getFirst(OAuthConstants.CLIENT_ID);
        validateToken(message, token, clientId);
       
       
        form.getData().remove(OAuthConstants.CLIENT_ID);
        form.getData().remove(Constants.CLIENT_AUTH_ASSERTION_PARAM);
        form.getData().remove(Constants.CLIENT_AUTH_ASSERTION_TYPE);
       
        // restore input stream
        try {
            FormUtils.restoreForm(provider, form, message);
        } catch (Exception ex) {
            throw new NotAuthorizedException(errorResponse());
        }
        return null;
    }
View Full Code Here

Examples of javax.ws.rs.NotAuthorizedException

   
    private Form readFormData(Message message) {
        try {
            return FormUtils.readForm(provider, message);
        } catch (Exception ex) {
            throw new NotAuthorizedException(errorResponse());   
        }
    }
View Full Code Here

Examples of javax.ws.rs.NotAuthorizedException

        }
    }
   
    protected Element readToken(Message message, String assertion) {
        if (assertion == null) {
            throw new NotAuthorizedException(errorResponse());
        }
        try {
            byte[] deflatedToken = Base64UrlUtility.decode(assertion);
            InputStream is = new ByteArrayInputStream(deflatedToken);
            return readToken(message, is);
        } catch (Base64Exception ex) {
            throw new NotAuthorizedException(errorResponse());
        }        
    }
View Full Code Here

Examples of org.fenixedu.academic.service.services.exceptions.NotAuthorizedException

    @Atomic
    public static Boolean run(Person person) throws NotAuthorizedException {
        /* start chain */
        Person requester = AccessControl.getPerson();
        if ((requester == null) || !requester.hasRole(RoleType.DEPARTMENT_CREDITS_MANAGER)) {
            throw new NotAuthorizedException();
        }
        if (person.getTeacher() != null) {
            final Person requesterPerson = requester;
            Department teacherDepartment = person.getTeacher().getDepartment();
            Collection departmentsWithAccessGranted = requesterPerson.getManageableDepartmentCreditsSet();
            if (!departmentsWithAccessGranted.contains(teacherDepartment)) {
                throw new NotAuthorizedException();
            }
        }
        /* end chain */
        return true;
    }
View Full Code Here

Examples of org.gatein.management.api.exceptions.NotAuthorizedException

public abstract class SecureOperationHandler implements OperationHandler {
    @Override
    public final void execute(OperationContext operationContext, ResultHandler resultHandler) throws ResourceNotFoundException, OperationException {
        // Secure all operations for MOP Management extension to /platform/administrators group.
        if (!operationContext.getExternalContext().isUserInRole("administrators")) {
            throw new NotAuthorizedException(operationContext.getUser(), operationContext.getOperationName());
        }

        doExecute(operationContext, resultHandler);
    }
View Full Code Here

Examples of org.gatein.management.api.exceptions.NotAuthorizedException

      }

      // Make sure user is authorized to invoke operation
      if (!isAuthorized(operationContext.getExternalContext(), managedRole, owner.managedRole))
      {
         throw new NotAuthorizedException(operationContext.getUser(), operationContext.getOperationName());
      }

      invokeBefore(operationContext);
      try
      {
View Full Code Here

Examples of org.mule.common.security.oauth.exception.NotAuthorizedException

    @Override
    public final void hasBeenAuthorized(OAuth2Adapter adapter) throws NotAuthorizedException
    {
        if (adapter.getAccessToken() == null)
        {
            throw new NotAuthorizedException(
                "This connector has not yet been authorized, please authorize by calling \"authorize\".");
        }
    }
View Full Code Here

Examples of org.odata4j.exceptions.NotAuthorizedException

  }

  public static void checkAccess(DatastoreService datastore, Entity e, AccessType accessType) {
    UserService userService = UserServiceFactory.getUserService();
    if (!userService.isUserLoggedIn()) {
      throw new NotAuthorizedException();
    }
    if (e == null) {
      return;
    }
    if (userService.isUserAdmin()) {
      return;
    }

    // Check read access by kind
    if (accessType == AccessType.READ) {
      Query q = new Query(KIND_ACCESS_CONTROL_KIND);
      Filter filter = new FilterPredicate("Kind", FilterOperator.EQUAL, e.getKind());
      q.setFilter(filter);
      Entity kac = datastore.prepare(q).asSingleEntity();
      if (kac != null) {
        Long access = (Long) kac.getProperty("Access");
        if (access.equals(UserGroup.USER.groupId)) {
          return;
        }
      }
    }
    // Check write access by entity
    else if (accessType == AccessType.WRITE) {
      Query q = new Query(ENTITY_ACCESS_CONTROL_KIND);
      Filter filter = new FilterPredicate("Entity", FilterOperator.EQUAL, e);
      q.setFilter(filter);
      Entity eac = datastore.prepare(q).asSingleEntity();

      User owner = (User) eac.getProperty("owner");
      if (owner.compareTo(userService.getCurrentUser()) == 0) {
        return;
      }
    }
    throw new NotAuthorizedException();
  }
View Full Code Here

Examples of org.springframework.social.NotAuthorizedException

        return null;
    }
 
  private void handleFoursquareError(int code, String errorType, String message) {
    if(errorType.equals("invalid_auth")) {
      throw new NotAuthorizedException(message);
    } else if(errorType.equals("param_error")) {
      throw new ParamErrorException(code, errorType, message);
    } else if(errorType.equals("endpoint_error")) {
      throw new ResourceNotFoundException(message);
    } else if(errorType.equals("not_authorized")) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.