congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
UnauthorizedException
Code IndexAdd Tabnine to your IDE (free)

How to use
UnauthorizedException
in
co.cask.cdap.security.spi.authorization

Best Java code snippets using co.cask.cdap.security.spi.authorization.UnauthorizedException (Showing top 20 results out of 315)

origin: stackoverflow.com

throw new UnauthorizedException("Authorization Required");
origin: cdapio/cdap

@Override
public void enforce(EntityId entity, Principal principal, Set<Action> actions) throws Exception {
 if (!isSecurityAuthorizationEnabled()) {
  return;
 }
 Set<Action> disallowed = EnumSet.noneOf(Action.class);
 UnauthorizedException unauthorizedException = new UnauthorizedException(principal, entity);
 for (Action action : actions) {
  try {
   enforce(entity, principal, action);
  } catch (UnauthorizedException e) {
   disallowed.add(action);
   unauthorizedException.addSuppressed(e);
  }
 }
 if (!disallowed.isEmpty()) {
  throw new UnauthorizedException(principal, disallowed, entity, unauthorizedException);
 }
}
origin: co.cask.cdap/cdap-app-fabric

             "the same artifact occur simultaneously. Please try again.");
} catch (UnauthorizedException e) {
 responder.sendString(HttpResponseStatus.FORBIDDEN, e.getMessage());
} catch (ConflictException e) {
 responder.sendString(HttpResponseStatus.CONFLICT, e.getMessage());
origin: cdapio/cdap

/************************************************ GET ************************************************************/
@GET
@Path("metadata/{dataset}")
public void getMetadata(HttpServiceRequest request, HttpServiceResponder responder,
            @PathParam("dataset") String dataset) {
 Map<MetadataScope, Metadata> metadata = null;
 try {
  metadata = getContext().getMetadata(MetadataEntity.ofDataset(getContext().getNamespace(), dataset));
 } catch (Exception e) {
  if (e.getCause() instanceof UnauthorizedException) {
   responder.sendStatus(((UnauthorizedException) e.getCause()).getStatusCode());
  } else if (e.getCause() instanceof UnauthenticatedException) {
   responder.sendStatus(((UnauthenticatedException) e.getCause()).getStatusCode());
  } else if (e.getCause() instanceof BadRequestException) {
   responder.sendStatus(((BadRequestException) e.getCause()).getStatusCode());
  } else {
   responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR.code());
  }
 }
 responder.sendJson(HttpResponseStatus.OK.code(), metadata);
}
origin: cdapio/cdap

             "the same artifact occur simultaneously. Please try again.");
} catch (UnauthorizedException e) {
 responder.sendString(HttpResponseStatus.FORBIDDEN, e.getMessage());
} catch (ConflictException e) {
 responder.sendString(HttpResponseStatus.CONFLICT, e.getMessage());
origin: stackoverflow.com

User auth) throws UnauthorizedException {
       if (auth!=null){
         ...
         return event
       } else throw new UnauthorizedException("Please authenticate first.");
     }
 public Event getEvent(@Named("eventID") Long eventID, User auth) throws UnauthorizedException {
       if (auth != null) {
         ...
         return event;
       } else throw new UnauthorizedException("Please authenticate first.");
     }
origin: cdapio/cdap

 responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
} catch (UnauthorizedException e) {
 responder.sendString(HttpResponseStatus.FORBIDDEN, e.getMessage());
} catch (Exception e) {
 LOG.error("Error while writing artifact {}-{}-{}", namespaceId, artifactName, artifactVersion, e);
origin: stackoverflow.com

 @ApiMethod(name = "insertRecord", path = "insert_record", httpMethod = HttpMethod.POST)
  public Record insertRecord(User user,  Record record)

    // check if google user is authenticated
    throws UnauthorizedException {
    if (user == null) {
      throw new UnauthorizedException("Authorization required");
    }

    // user is authenticated... do some stuff!
}
origin: co.cask.cdap/cdap-app-fabric

 responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
} catch (UnauthorizedException e) {
 responder.sendString(HttpResponseStatus.FORBIDDEN, e.getMessage());
} catch (Exception e) {
 LOG.error("Error while writing artifact {}-{}-{}", namespaceId, artifactName, artifactVersion, e);
origin: stackoverflow.com

@ApiMethod(name = "test", path = "myApi/test",
    scopes = {Constants.EMAIL_SCOPE},
     clientIds = {Constants.WEB_CLIENT_ID, 
          Constants.ANDROID_CLIENT_ID, 
          com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID},
          audiences = {Constants.ANDROID_AUDIENCE})
public User test(User user) throws UnauthorizedException    {
  if (user == null) throw new UnauthorizedException("User not valid!");   
  return user;
}
origin: co.cask.cdap/cdap-app-fabric

 responder.sendString(HttpResponseStatus.CONFLICT, e.getMessage());
} catch (UnauthorizedException e) {
 responder.sendString(HttpResponseStatus.FORBIDDEN, e.getMessage());
} catch (InvalidArtifactException e) {
 responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
origin: stackoverflow.com

 public void apiMethod(User user) {
 if (user == null) {
  throw new UnauthorizedException();
 }
 ...
}
origin: cdapio/cdap

 responder.sendString(HttpResponseStatus.CONFLICT, e.getMessage());
} catch (UnauthorizedException e) {
 responder.sendString(HttpResponseStatus.FORBIDDEN, e.getMessage());
} catch (InvalidArtifactException e) {
 responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
origin: stackoverflow.com

public Collection<Campagne> getCampagnes(@Named("NumPortable")String NumPortable, User user) throws  UnauthorizedException {
   if (user == null) throw new UnauthorizedException("User is Not Valid");
  return CampagneCRUD.getInstance().findCampagne(NumPortable);
  }
origin: stackoverflow.com

public Collection<Campagne> getCampagnes(@Named("NumPortable")String NumPortable, User user) throws  UnauthorizedException {
   if (user == null) throw new UnauthorizedException("User is Not Valid");
  return CampagneCRUD.getInstance().findCampagne(NumPortable);
  }
origin: stackoverflow.com

public Collection<Campagne> getCampagnes(@Named("NumPortable")String NumPortable, User user) throws  UnauthorizedException {
   if (user == null) throw new UnauthorizedException("User is Not Valid");
  return CampagneCRUD.getInstance().findCampagne(NumPortable);
  }
origin: stackoverflow.com

 @PUT
@Path("{id: [A-Fa-f0-9]+}")
@Consumes(MediaType.APPLICATION_JSON)
public T update(@Context HttpServletRequest request, final T item, @PathParam("id") final String id)
{
 final Post post = getPostbyId(id);
 if (!post.allowedToUpdate(request.getUserPrincipal())
 {
  throw new UnauthorizedException();
 }
 // Authorized, carry on
}
origin: stackoverflow.com

 public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
  if (handler instanceof HandlerMethod) {
    HandlerMethod method = (HandlerMethod)handler;
    if (method.getMethodAnnotation(IpRestricted.class)!=null) {
      if (!request.getRemoteAddr().equals("192.168.1.1")) {
        throw new UnauthorizedException("Ip not authorized");
      }
    }
  }
  [....]
}
origin: cdapio/cdap

/**
 * Checks if one entity is visible to the principal
 *
 * @param entityId entity id to be checked
 * @param authorizationEnforcer enforcer to make the authorization check
 * @param principal the principal to be checked
 * @throws UnauthorizedException if the principal does not have any privilege in the action set on the entity
 */
public static void ensureAccess(EntityId entityId, AuthorizationEnforcer authorizationEnforcer,
                Principal principal) throws Exception {
 if (authorizationEnforcer.isVisible(Collections.singleton(entityId), principal).isEmpty()) {
  throw new UnauthorizedException(principal, entityId);
 }
}
origin: caskdata/cdap

@Override
public void enforce(EntityId entity, Principal principal, Action action) throws Exception {
 if (!allowedActions.contains(action)) {
  throw new UnauthorizedException("Not allow to perform " + action + " " + entity + " by " + principal);
 }
}
co.cask.cdap.security.spi.authorizationUnauthorizedException

Javadoc

Exception thrown when Authentication is successful, but a Principal is not authorized to perform an Action on an EntityId.

Most used methods

  • <init>
  • addSuppressed
  • getMessage
  • getStatusCode

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • setScale (BigDecimal)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now