当前位置: 首页>>代码示例>>Java>>正文


Java Security类代码示例

本文整理汇总了Java中play.mvc.Security的典型用法代码示例。如果您正苦于以下问题:Java Security类的具体用法?Java Security怎么用?Java Security使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Security类属于play.mvc包,在下文中一共展示了Security类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: flowLineage

import play.mvc.Security; //导入依赖的package包/类
@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));
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:17,代码来源:Application.java

示例2: loadTree

import play.mvc.Security; //导入依赖的package包/类
@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));
    }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:22,代码来源:Application.java

示例3: getUserInfo

import play.mvc.Security; //导入依赖的package包/类
@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());
}
 
开发者ID:shuza,项目名称:Simple-RestFull-API,代码行数:22,代码来源:UserController.java

示例4: setUserDefinedName

import play.mvc.Security; //导入依赖的package包/类
@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();
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:27,代码来源:DevicesController.java

示例5: customPost

import play.mvc.Security; //导入依赖的package包/类
@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);
    });
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:21,代码来源:CustomAssistanceProxy.java

示例6: list

import play.mvc.Security; //导入依赖的package包/类
@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);
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:17,代码来源:AssistanceController.java

示例7: upload

import play.mvc.Security; //导入依赖的package包/类
@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);
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:19,代码来源:SensorDataController.java

示例8: postDeleteUser

import play.mvc.Security; //导入依赖的package包/类
/**
 * 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(""));
}
 
开发者ID:PlayWithMagic,项目名称:PlayWithMagic.org,代码行数:29,代码来源:Application.java

示例9: deleteMagician

import play.mvc.Security; //导入依赖的package包/类
/**
 * 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)));
  }
}
 
开发者ID:PlayWithMagic,项目名称:PlayWithMagic.org,代码行数:25,代码来源:Application.java

示例10: editRoutine

import play.mvc.Security; //导入依赖的package包/类
/**
 * 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)));
}
 
开发者ID:PlayWithMagic,项目名称:PlayWithMagic.org,代码行数:24,代码来源:Application.java

示例11: editSet

import play.mvc.Security; //导入依赖的package包/类
/**
 * 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));
  }
}
 
开发者ID:PlayWithMagic,项目名称:PlayWithMagic.org,代码行数:26,代码来源:Application.java

示例12: editMaterial

import play.mvc.Security; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:PlayWithMagic,项目名称:PlayWithMagic.org,代码行数:32,代码来源:Application.java

示例13: deleteMaterial

import play.mvc.Security; //导入依赖的package包/类
/**
 * 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)));
}
 
开发者ID:PlayWithMagic,项目名称:PlayWithMagic.org,代码行数:31,代码来源:Application.java

示例14: call

import play.mvc.Security; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:judgels-deprecated,项目名称:judgels-jophiel,代码行数:25,代码来源:AuthenticatedAction.java

示例15: call

import play.mvc.Security; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:judgels,项目名称:raguel,代码行数:25,代码来源:AuthenticatedAction.java


注:本文中的play.mvc.Security类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。