Java 类play.mvc.Security 实例源码

项目:premier-wherehows    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result flowLineage(String application, String project, String flow)
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    String type = "azkaban";
    if (StringUtils.isNotBlank(application) && (application.toLowerCase().indexOf("appworx") != -1))
    {
        type = "appworx";

    }
    return ok(lineage.render(username, type, 0, application.replace(" ", "."), project, flow));
}
项目:wherehowsX    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result flowLineage(String application, String project, String flow)
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    String type = "azkaban";
    if (StringUtils.isNotBlank(application) && (application.toLowerCase().indexOf("appworx") != -1))
    {
        type = "appworx";

    }
    return ok(lineage.render(username, type, 0, application.replace(" ", "."), project, flow));
}
项目:wherehowsX    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result loadTree(String key)
{
    if (StringUtils.isNotBlank(key) && key.equalsIgnoreCase("flows")) {
        return ok(FlowsDAO.getFlowApplicationNodes());
    }
    // switch here..
    boolean isFiltered = false;
    if (isFiltered) {
        if (StringUtils.isNotBlank(key)) {
            String username = session("user");
            if (username != null) {
                String treeName = Play.application().configuration().getString(key + TREE_NAME_SUBFIX);
                return ok(UserDAO.getUserGroupFileTree(username, treeName));
            }
        }
        return ok(Json.toJson(""));
    } else {
        return ok(Tree.loadTreeJsonNode(key + TREE_NAME_SUBFIX));
    }
}
项目:Simple-RestFull-API    文件:UserController.java   
@Security.Authenticated(AuthService.class)
public static Result getUserInfo() {
    UserModel model = userParser.parseUser(request());
    JsonObject result = new JsonObject();
    if (model != null) {
        model = UserDao.getInstance().getUserInfo(model.getEmail());
        if (model != null) {
            result.add(ResponseConstant.PARAMS_RESPONSE_DATA, model.toJson());
            result.add(ResponseConstant.PARAMS_RESPONSE_CODE, ResponseConstant.RESPONSE_CODE_SUCCESS);
            result.add(ResponseConstant.PARAMS_RESPONSE_MESSAGE, "User found");
        } else {
            result.add(ResponseConstant.PARAMS_RESPONSE_CODE, ResponseConstant.RESPONSE_CODE_FAILED);
            result.add(ResponseConstant.PARAMS_RESPONSE_MESSAGE, "No user found with " + model.getEmail());
        }
    } else {
        result.add(ResponseConstant.PARAMS_RESPONSE_CODE, ResponseConstant.RESPONSE_CODE_FAILED);
        result.add(ResponseConstant.PARAMS_RESPONSE_MESSAGE, "Email and password required");
    }

    return ok(result.toString());
}
项目:assistance-platform-server    文件:DevicesController.java   
@Security.Authenticated(UserAuthenticator.class)
public Result setUserDefinedName() {
    long userId = getUserIdForRequest();

    JsonNode jsonRequest = request().body().asJson();

    long deviceId = -1L;

    try {
        deviceId = getDeviceId(userId, jsonRequest);
    } catch (APIErrorException e) {
        return badRequestJson(e.getError());
    }

    String userDefinedName = jsonRequest.path("user_defined_name").asText();

    if (userDefinedName.length() > 30) {
        userDefinedName = userDefinedName.substring(0, 30);
    }

    if (!DevicePersistency.setUserDefinedName(deviceId, userDefinedName)) {
        return internalServerErrorJson(AssistanceAPIErrors.unknownInternalServerError);
    }

    return ok();
}
项目:assistance-platform-server    文件:CustomAssistanceProxy.java   
@Security.Authenticated(UserAuthenticator.class)
public Promise<Result> customPost(String moduleId, String path) {
    return custom(moduleId, path, (r) -> {
        RequestBody body = request().body();

        String postBody = null;

        if (body.asText() != null) {
            postBody = body.asText();
        } else if (body.asJson() != null) {
            r.setContentType("application/json");
            postBody = body.asJson().toString();
        } else if (body.asXml() != null) {
            r.setContentType("application/xml");
            postBody = body.asXml().toString();
        }

        return r.post(postBody);
    });
}
项目:assistance-platform-server    文件:AssistanceController.java   
@Security.Authenticated(UserAuthenticator.class)
public Result list(String language) {

    JsonNode result = Cache
            .getOrElse(
                    "moduleList" + language,
                    () -> {
                        ActiveAssistanceModule[] assiModules = ActiveAssistanceModulePersistency
                                .list(language);

                        JsonNode json = Json.toJson(assiModules);
                        return json;
                    }, 3600);

    return ok(result);
}
项目:assistance-platform-server    文件:SensorDataController.java   
@Security.Authenticated(UserAuthenticator.class)
public Result upload() {
    long start = System.currentTimeMillis();
    JsonNode postData = request().body().asJson();

    APIError result = handleSensorData(postData, getUserIdForRequest());

    if (result != null) {
        return badRequestJson(result);
    }

    long processingTime = System.currentTimeMillis() - start;

    Map<String, Object> r = new HashMap<>();
    r.put("processingTime", processingTime);

    return ok(r);
}
项目:PlayWithMagic.org    文件:Application.java   
/**
 * Posts an authenticated delete user request.
 *
 * @return The Index page, logged out.
 */
@Security.Authenticated(Secured.class)
public static Result postDeleteUser() {
  Form<DeleteUserFormData> deleteUserFormData = Form.form(DeleteUserFormData.class).bindFromRequest();
  //DeleteUserFormData formData = deleteUserFormData.get();
  if (deleteUserFormData.hasErrors()) {
    for (String key : deleteUserFormData.errors().keySet()) {
      List<ValidationError> currentError = deleteUserFormData.errors().get(key);
      for (play.data.validation.ValidationError error : currentError) {
        if (!error.message().equals("")) {
          flash(key, error.message());
        }
      }
    }

    //Magician magician = Magician.getMagician(formData.id);
    return badRequest(DeleteUser.render("deleteMagician", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()),
        deleteUserFormData, Secured.getUserInfo(ctx())));
  }
  DeleteUserFormData formData = deleteUserFormData.get();
  Magician.deleteMagician(formData.id);
  session().clear();
  return redirect(routes.Application.index(""));
}
项目:PlayWithMagic.org    文件:Application.java   
/**
 * Direct a user to the Delete User page with the ID of the magician to be deleted.
 *
 * @param id The ID of the Magician to delete.
 * @return An HTTP OK message along with the HTML content for the DeleteUser confirmation page.
 */
@Security.Authenticated(Secured.class)
public static Result deleteMagician(long id) {
  if (id == 0) {
    // Can't delete empty user ID.
    return redirect(routes.Application.index(""));
  }
  else if (id != Secured.getUserInfo(ctx()).getId()) {
    // Prevent users from deleting someone else's account.
    return redirect(routes.Application.index(""));
  }
  else {
    DeleteUserFormData deleteUserFormData = new DeleteUserFormData(Magician.getMagician(id));

    Form<DeleteUserFormData> formWithDeleteData = Form.form(DeleteUserFormData.class).fill(deleteUserFormData);
    return ok(DeleteUser.render("deleteMagician", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()),
        formWithDeleteData, Magician.getMagician(id)));
  }
}
项目:PlayWithMagic.org    文件:Application.java   
/**
 * Show the EditRoutine page.  If routineId is 0, then bind the page/form with a new Routine.  Otherwise,
 * bind with an existing Routine.
 *
 * @param routineId The ID of the routine to edit (or 0 if it's a new routine).
 * @return An HTTP OK message along with the HTML content for the EditRoutine page.
 */
@Security.Authenticated(Secured.class)
public static Result editRoutine(long routineId) {
  RoutineFormData routineFormData;

  if (routineId == 0) {
    routineFormData = new RoutineFormData();
  }
  else {
    routineFormData = new RoutineFormData(Routine.getRoutine(routineId));
  }

  Form<RoutineFormData> formWithRoutineData = Form.form(RoutineFormData.class).fill(routineFormData);

  return ok(EditRoutine.render("editRoutine", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()),
      formWithRoutineData, Routine.getMaterials(routineId)));
}
项目:PlayWithMagic.org    文件:Application.java   
/**
 * Renders the editSet page with a form to add a new Set if the ID is 0.  Otherwise, update an existing
 * Set based on the passed in ID number.
 *
 * @param id The ID of the Set to edit (or 0 if it's a new routine).
 * @return An HTTP OK message along with the HTML content for the EditSet page.
 */
@Security.Authenticated(Secured.class)
public static Result editSet(long id) {
  SetFormData setFormData = (id == 0) ? new SetFormData() : new SetFormData(Set.getSet(id));

  Form<SetFormData> formData = Form.form(SetFormData.class).fill(setFormData);

  if (id != 0) {
    Set thisSet = Set.getSet(id);
    return ok(EditSet.render("editSet", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()), formData,
        Routine.getActiveRoutines(), Routine.getListOfIds(thisSet.getRoutines())));
  }
  else {
    List<Long> emptyListOfRoutinesInSet = new ArrayList<Long>();

    return ok(EditSet.render("editSet", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()), formData,
        Routine.getActiveRoutines(), emptyListOfRoutinesInSet));
  }
}
项目:PlayWithMagic.org    文件:Application.java   
/**
 * Show the EditMaterial page to update an item.  First, process the Routine page, deal with any errors and update
 * the database.  Finally, show the EditMaterial page.
 *
 * @param materialId The ID of the Material you want to edit.
 * @return An HTTP page EditMaterial if all is well or EditRoutine if there's an error on that page.
 */
@Security.Authenticated(Secured.class)
public static Result editMaterial(Long materialId) {
  Form<RoutineFormData> formWithRoutineData = Form.form(RoutineFormData.class).bindFromRequest();

  Logger.debug("editMaterial Raw Routine Form Data");
  Logger.debug("  routineId = [" + formWithRoutineData.field("id").value() + "]");
  Logger.debug("  name = [" + formWithRoutineData.field("name").value() + "]");
  Logger.debug("  materialID = [" + materialId + "]");

  long routineId = new Long(formWithRoutineData.field("id").value()).longValue();

  if (formWithRoutineData.hasErrors()) {
    Logger.error("HTTP Form Error in editMaterial");

    return badRequest(EditRoutine.render("editRoutine", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()),
        formWithRoutineData, Routine.getMaterials(routineId)));
  }

  RoutineFormData data = formWithRoutineData.get();
  Routine routine = Routine.saveRoutineFromForm(data);
  routineId = routine.getId();

  return editMaterialDirect(materialId);
}
项目:PlayWithMagic.org    文件:Application.java   
/**
 * Delete a Material item and redisplay the EditRoutine page.  First, process the Routine page and deal with any
 * errors.  Update the database, then delete the Material item and finally redisplay EditRoutine.
 *
 * @param materialId The ID of the Material to delete.
 * @return An HTTP EditMaterial page.
 */
@Security.Authenticated(Secured.class)
public static Result deleteMaterial(Long materialId) {
  Form<RoutineFormData> formWithRoutineData = Form.form(RoutineFormData.class).bindFromRequest();
  long routineId = new Long(formWithRoutineData.field("id").value()).longValue();

  if (formWithRoutineData.hasErrors()) {
    Logger.error("HTTP Form Error in deleteMaterial");

    return badRequest(EditRoutine.render("editRoutine", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()),
        formWithRoutineData, Routine.getMaterials(routineId)));
  }

  RoutineFormData routineFormData = formWithRoutineData.get();
  Routine routine = Routine.saveRoutineFromForm(routineFormData);
  routineId = routine.getId();

  // End of processing Routine page.  Start of processing material.

  Material.getMaterial(materialId).delete();

  return ok(EditRoutine.render("editRoutine", Secured.isLoggedIn(ctx()), Secured.getUserInfo(ctx()),
      formWithRoutineData, Routine.getMaterials(routineId)));
}
项目:judgels-jophiel    文件:AuthenticatedAction.java   
@Override
public F.Promise<Result> call(Http.Context context) throws Throwable {
    try {
        for (Class<? extends Security.Authenticator> authenticatorClass : this.configuration.value()) {
            Security.Authenticator var2 = (Security.Authenticator) authenticatorClass.newInstance();
            String var3 = var2.getUsername(context);
            if (var3 == null) {
                Result var12 = var2.onUnauthorized(context);
                return F.Promise.pure(var12);
            } else {
                try {
                    context.request().setUsername(var3);
                } finally {
                    context.request().setUsername((String) null);
                }
            }
        }
        return this.delegate.call(context);
    } catch (RuntimeException var10) {
        throw var10;
    } catch (Throwable var11) {
        throw new RuntimeException(var11);
    }
}
项目:raguel    文件:AuthenticatedAction.java   
@Override
public F.Promise<Result> call(Http.Context context) throws Throwable {
    try {
        for (Class<? extends Security.Authenticator> authenticatorClass : this.configuration.value()) {
            Security.Authenticator var2 = (Security.Authenticator) authenticatorClass.newInstance();
            String var3 = var2.getUsername(context);
            if (var3 == null) {
                Result var12 = var2.onUnauthorized(context);
                return F.Promise.pure(var12);
            } else {
                try {
                    context.request().setUsername(var3);
                } finally {
                    context.request().setUsername(null);
                }
            }
        }
        return this.delegate.call(context);
    } catch (RuntimeException var10) {
        throw var10;
    } catch (Throwable var11) {
        throw new RuntimeException(var11);
    }
}
项目:audiencemanager-api-sample-app    文件:Application.java   
/** Creates a new blog post. */
@Security.Authenticated(Secured.class)
public static Result newPost() {
    Form<BlogPost> filledForm = postForm.bindFromRequest();
    Form<TagContainer> filledTagForm = tagContainerForm.bindFromRequest();
    if (filledForm.hasErrors()) {
        return badRequest(views.html.create_post.render(filledForm,
                filledTagForm));
    } else {
        List<Tag> tags = getTags(filledTagForm.get().commaSeparatedTags);
        BlogPost blogPost = filledForm.get();
        blogPost.tags = tags;
        blogPost.published = new Date();
        blogPost.author = getLoggedInUser();
        BlogPost.create(blogPost);

        return redirect(routes.Application.getPost(blogPost.id));
    }
}
项目:audiencemanager-api-sample-app    文件:Application.java   
/** Creates a new comment on the blog post. */
@Security.Authenticated(Secured.class)
public static Result newComment(Long id) {
    Form<Comment> filledForm = commentForm.bindFromRequest();
    BlogPost post = BlogPost.find.byId(id);

    if (filledForm.hasErrors()) {
        return badRequest(views.html.single_post.render(
                BlogPost.find.byId(id), Comment.all(), filledForm,
                getLoggedInUser()));
    } else {
        Comment toCreate = filledForm.get();
        toCreate.blogPost = post;
        toCreate.published = new Date();
        toCreate.author = getLoggedInUser();
        Comment.create(toCreate);
        return redirect(routes.Application.getPost(id));
    }
}
项目:uriel    文件:AuthenticatedAction.java   
@Override
public F.Promise<Result> call(Http.Context context) throws Throwable {
    try {
        for (Class<? extends Security.Authenticator> authenticatorClass : this.configuration.value()) {
            Security.Authenticator var2 = (Security.Authenticator) authenticatorClass.newInstance();
            String var3 = var2.getUsername(context);
            if (var3 == null) {
                Result var12 = var2.onUnauthorized(context);
                return F.Promise.pure(var12);
            } else {
                try {
                    context.request().setUsername(var3);
                } finally {
                    context.request().setUsername(null);
                }
            }
        }
        return this.delegate.call(context);
    } catch (RuntimeException var10) {
        throw var10;
    } catch (Throwable var11) {
        throw new RuntimeException(var11);
    }
}
项目:w3act    文件:TargetController.java   
@Security.Authenticated(SecuredController.class)
public static Result uploadExcel() {
    MultipartFormData body = request().body().asMultipartFormData();
    FilePart picture = body.getFile("excelFile");
    if(picture != null) {
        String fileName = picture.getFilename();
        String contentType = picture.getContentType();
        File file = picture.getFile();
        Logger.info("Uploaded " + fileName);
        try {
            excelParser(file);
            flash("success", "File " + fileName + " uploaded");
        }
        catch(Throwable e) {
            flash("error", "File " + fileName + " parse errors:");
            flash("error_log", e.getMessage());
            e.printStackTrace();
        }
        return redirect(routes.TargetController.upload());
    }
    else {
        Logger.info("Upload failed ");
        flash("error", "Missing file");
        return redirect(routes.TargetController.upload());
    }
}
项目:w3act    文件:LicenseController.java   
@Security.Authenticated(SecuredController.class)
  public static Result view(Long id) {
    License license = License.findById(id);
Logger.info("License: "+license);
    if (license != null) {
        if (request().accepts("text/html")) {
            User user = User.findByEmail(request().username());
            CrawlPermission cp = new CrawlPermission();
            cp.contactPerson = new ContactPerson();
            cp.setLicense(license);
            cp.target = new Target();
            return ok(ukwalicence.render(cp, false));
        } else {
            return ok(Json.toJson(license));
        }
    } else {
        return notFound("There is no License with ID "+id);
    }
  }
项目:w3act    文件:LicenseController.java   
/**
    * This method enables searching for given URL and redirection in order to add new entry
    * if required.
    * @return
    */
@Security.Authenticated(SecuredController.class)
   public static Result filter() {
    Result res = null;
    Logger.debug("LicenseController.filter()");
       String search = getFormParam(Const.SEARCH);
       String name = getFormParam(Const.NAME);

       List<License> licenses = processFilterLicences(name);

       Logger.debug("search: " + search + ", name: " + name);
       if (search != null) {
           res = ok(
                licences.render(
                       "Licences", User.findByEmail(request().username()), licenses, name
                   )
               );
       }
       return res;
   }
项目:w3act    文件:CollectionController.java   
@Security.Authenticated(SecuredController.class)
public static Result view(Long id) {
    User user = User.findByEmail(request().username());
    Collection collection = Collection.findById(id);
    if( collection != null ) {
        Logger.debug("id::::" + id+ " parent:::: " + collection.parent);
        if (request().accepts("text/html")) {
            Logger.info("Rendering collection: "+collection);
            return ok(view.render(collection, user));
        } else {
            return ok(Json.toJson(collection));
        }
    } else {
        return notFound("There is no Collection with ID "+id);
    }
}
项目:WorkshopManager    文件:Administration.java   
/**
 * This action redirect on the users administration view
 *
 * @return the users administration view
 */
@Security.Authenticated(Secured.class)
public static Result adminUsers( int page ) {

    if (!Secured.isMemberOf(Roles.ADMIN)) {
        return forbidden();
    }

    List<User> users = User.find.orderBy("firstName asc").findList();
    int userPerPage = Integer.parseInt(Application.conf("user.per.page"));

    // Compute the number of page
    int modulo =  users.size() % userPerPage;
    int pageNumWithoutRest =  (int) Math.floor(users.size() / userPerPage);
    int pageNum = modulo == 0 ? pageNumWithoutRest : pageNumWithoutRest + 1; // if the modulo is not 0, we will need one page more for the remaining users

    // Compute the subList
    int lastIndex =  page + 1 == pageNum ?  users.size() : userPerPage * (page + 1); // for the last page, the sublist is maybe not full, so we end it with the users.size()
    List<User> subList = users.subList(userPerPage * page, lastIndex);

    return ok( views.html.admin.adminUsers.render( Messages.get("admin.users.title"), subList , page, pageNum ) );
}
项目:WorkshopManager    文件:Administration.java   
@Security.Authenticated(Secured.class)
public static Result saveType( long idType ) {

    if (!Secured.isMemberOf(Roles.ADMIN)) {
        return forbidden();
    }

    Form<Type> filledForm = play.data.Form.form(Type.class).bindFromRequest();

    if (filledForm.hasErrors()) {
        return badRequest(views.html.admin.formType.render(filledForm, idType));
    }

    Type newType = filledForm.get();
    if ( idType == 0l ) {
        Ebean.save( newType );
    }
    else {
        newType.id = idType;
        Ebean.update( newType );
    }

    List<Type> types = Type.find.all();

    return ok( views.html.admin.adminTypes.render("", types));
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
    * Return the event planning form for modification of a already planned event
    *
 * @param idWorkshop event id
 * @return the planWorkshop page
 */
@Transactional
   @Security.Authenticated(Secured.class)
public static Result modifyPlannedWorkshop(Long idWorkshop, Long idSession) {

       if (!Secured.isMemberOf(Roles.ADMIN)) {
           return forbidden();
       }

       WorkshopSession      session     = WorkshopSession.find.byId( idSession );

    Form<WorkshopSession> workshopSessionForm;
    if (session != null) {
        workshopSessionForm = play.data.Form.form(WorkshopSession.class).fill( session );
    } else {
        workshopSessionForm = play.data.Form.form(WorkshopSession.class);
    }

    return ok( planWorkshop.render(workshopSessionForm, idWorkshop, idSession) );
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
 * Allows to add a proposal Speaker to the speaker List for a selected workshop
 * 
 * @param id workshop id
 * @return the welcome page
 */
@Transactional
@Security.Authenticated(Secured.class)
public static Result addSpeaker( Long id ) {

    // We get the Workshop
    Workshop    currentWorkshop     =   Workshop.find.byId(id);

    if ( currentWorkshop.speakers.size() < Play.application().configuration().getInt( "speaker.limit" )) {
        // Get the connected User
        User        user                =   Secured.getUser();

        // It's a Set, so no duplicate
        currentWorkshop.speakers.add( user );

        // We save the new Workshop
        Ebean.update(currentWorkshop);
    }
    else {
        return ok ( error.render( Messages.get("error.speaker.limit.reached")) );
    }

    return redirect(routes.Application.newWorkshops() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
 * Allows to remove a proposal Speaker to the speaker List for a selected workshop
 * 
 * @param id workshop id
 * @return the welcome page
 */
@Transactional
@Security.Authenticated(Secured.class)
public static Result removeSpeaker( Long id ) {
    // We get the Workshop
    Workshop    currentWorkshop     =   Workshop.find.byId(id);

    // Get the connected User
    User        user                =   Secured.getUser();

    // It's a Set, so no duplicate
    currentWorkshop.speakers.remove( user );

    // We save the new Workshop
    Ebean.save(currentWorkshop);

    return redirect(routes.Application.newWorkshops() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
    * Allows to add a participant to the potential participants List for a selected session
    * 
    * @param id workshop id
    * @return the welcome page
    */
   @Transactional
   @Security.Authenticated(Secured.class)
   public static Result addParticipant( Long id ) {
    // We get the Workshop
    WorkshopSession     currentSession      =   WorkshopSession.find.byId(id);

       // Get the connected User
       User             user                =   Secured.getUser();

       // It's a Set, so no duplicate
       if ( (currentSession.limitePlace == 0  || currentSession.limitePlace != 0 && currentSession.participants.size() < currentSession.limitePlace) && notInOtherSession( currentSession ) ) {
        currentSession.participants.add( user );
       }
       else {
        return ok ( error.render( Messages.get("error.participants.limit.reached")) );
       }

       // We save the new Workshop
       Ebean.save(currentSession);

       return redirect(routes.Application.welcome() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
 * Allows to remove a participant to the potential participants List for a selected session
 * 
 * @param id workshop id
 * @return the welcome page
 */
@Transactional
@Security.Authenticated(Secured.class)
public static Result removeParticipant( Long id ) {
    // We get the Workshop
    WorkshopSession     currentSession      =   WorkshopSession.find.byId(id);

    // Get the connected User
    User                user                =   Secured.getUser();

    // It's a Set, so no duplicate
    currentSession.participants.remove( user );

    // We save the new Workshop
    Ebean.save(currentSession);

    return redirect(routes.Application.welcome() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
    * Allows to add a participant to the potential participants List for a selected workshop
    * 
    * @param id workshop id
    * @return the welcome page
    */
   @Transactional
   @Security.Authenticated(Secured.class)
   public static Result addPotentialParticipant( Long id ) {
    // We get the Workshop
       Workshop currentWorkshop     =   Workshop.find.byId(id);

       // Get the connected User
       User     user                =   Secured.getUser();

       // It's a Set, so no duplicate
       currentWorkshop.potentialParticipants.add( user );

       // We save the new Workshop
       Ebean.save(currentWorkshop);

       return redirect(routes.Application.newWorkshops() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
 * Allows to remove a participant to the potential participants List for a selected workshop
 * 
 * @param id workshop id
 * @return the welcome page
 */
@Transactional
@Security.Authenticated(Secured.class)
public static Result removePotentialParticipant( Long id ) {
    // We get the Workshop
    Workshop    currentWorkshop     =   Workshop.find.byId(id);

    // Get the connected User
    User        user                =   Secured.getUser();

    // It's a Set, so no duplicate
    currentWorkshop.potentialParticipants.remove( user );

    // We save the new Workshop
    Ebean.save(currentWorkshop);

    return redirect(routes.Application.newWorkshops() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
    * Allows to add a participant to the potential participants List for a selected workshop
    * 
    * @param id workshop id
    * @return the welcome page
    */
   @Transactional
   @Security.Authenticated(Secured.class)
   public static Result addInterrestedParticipant( Long id ) {
    // We get the Workshop
       Workshop currentWorkshop     =   Workshop.find.byId(id);

       // Get the connected User
       User     user                =   Secured.getUser();

       // It's a Set, so no duplicate
       currentWorkshop.potentialParticipants.add( user );

       // We save the new Workshop
       Ebean.save(currentWorkshop);

       return redirect(routes.Application.workshops() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
 * Allows to remove a participant to the potential participants List for a selected workshop
 * 
 * @param id workshop id
 * @return the welcome page
 */
@Transactional
@Security.Authenticated(Secured.class)
public static Result removeInterrestedParticipant( Long id ) {
    // We get the Workshop
    Workshop    currentWorkshop     =   Workshop.find.byId(id);

    // Get the connected User
    User        user                =   Secured.getUser();

    // It's a Set, so no duplicate
    currentWorkshop.potentialParticipants.remove( user );

    // We save the new Workshop
    Ebean.save(currentWorkshop);

    return redirect(routes.Application.workshops() + "#" + id);
}
项目:WorkshopManager    文件:WorkshopController.java   
/**
    * Prepare the form to add resources
    * 
 * @param id the workshop ID
 * @return the resources form view
 */
   @Transactional
   @Security.Authenticated(Secured.class)
   public static Result addWorkshopRessources(Long id) {
    Workshop    ws          =   Workshop.find.byId(id);

       if (!Secured.isMemberOf(Roles.ADMIN) && !UsersUtils.isWorkshopAuthor(ws) && !UsersUtils.isOneWorkshopSpeaker(ws)) {
           return forbidden();
       }

    Ressources  ressources  =   ws.workshopRessources;

    // if we already set resources, we want to fill the form with our old data
    Form<Ressources> resourcesForm = null;
    if ( ressources != null ) {
        resourcesForm       =   play.data.Form.form(Ressources.class).fill(ressources);
    }
    else {
        resourcesForm       =   play.data.Form.form(Ressources.class);
    }

    return ok( addRessources.render(resourcesForm, id) );
}
项目:premier-wherehows    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result index()
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    //You cann generate the Csrf token such as String csrfToken = SecurityPlugin.getInstance().getCsrfToken();
    String csrfToken = "";
    return ok(index.render(username, csrfToken));
}
项目:premier-wherehows    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result lineage()
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    return ok(lineage.render(username, "chains", 0, null, null, null));
}
项目:premier-wherehows    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result datasetLineage(int id)
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    return ok(lineage.render(username, "dataset", id, null, null, null));
}
项目:premier-wherehows    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result metricLineage(int id)
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    return ok(lineage.render(username, "metric", id, null, null, null));
}
项目:wherehowsX    文件:Application.java   
@Security.Authenticated(Secured.class)
public static Result index()
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    //You cann generate the Csrf token such as String csrfToken = SecurityPlugin.getInstance().getCsrfToken();
    String csrfToken = "";
    return ok(index.render(username, csrfToken));
}