本文整理汇总了Java中javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic类的典型用法代码示例。如果您正苦于以下问题:Java EmptyRoleSemantic类的具体用法?Java EmptyRoleSemantic怎么用?Java EmptyRoleSemantic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmptyRoleSemantic类属于javax.servlet.annotation.ServletSecurity包,在下文中一共展示了EmptyRoleSemantic类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: viewUser
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
@RequestMapping ( value = "/{userId}/view", method = RequestMethod.GET )
@HttpConstraint ( value = EmptyRoleSemantic.PERMIT )
public ModelAndView viewUser ( @PathVariable ( "userId" ) final String userId, final HttpServletRequest request )
{
final boolean you = isYou ( userId, request );
if ( !you && !request.isUserInRole ( "ADMIN" ) )
{
return CommonController.createAccessDenied ();
}
final DatabaseUserInformation user = this.storage.getUserDetails ( userId );
if ( user == null || user.getDetails ( DatabaseDetails.class ) == null )
{
return CommonController.createNotFound ( "user", userId );
}
final ModelAndView model = new ModelAndView ( "user/view" );
model.put ( "user", user );
model.put ( "you", you );
return model;
}
开发者ID:eclipse,项目名称:packagedrone,代码行数:24,代码来源:UserController.java
示例2: viewUser
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
@RequestMapping ( value = "/{userId}/view", method = RequestMethod.GET )
@HttpConstraint ( value = EmptyRoleSemantic.PERMIT )
public ModelAndView viewUser ( @PathVariable ( "userId" ) final String userId, final HttpServletRequest request)
{
final boolean you = isYou ( userId, request );
if ( !you && !request.isUserInRole ( "ADMIN" ) )
{
return CommonController.createAccessDenied ();
}
final DatabaseUserInformation user = this.storage.getUserDetails ( userId );
if ( user == null || user.getDetails ( DatabaseDetails.class ) == null )
{
return CommonController.createNotFound ( "user", userId );
}
final ModelAndView model = new ModelAndView ( "user/view" );
model.put ( "user", user );
model.put ( "you", you );
return model;
}
开发者ID:ctron,项目名称:package-drone,代码行数:24,代码来源:UserController.java
示例3: createConstraint
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
private static SecurityConstraint createConstraint(
HttpConstraintElement element, String urlPattern, boolean alwaysCreate) {
SecurityConstraint constraint = new SecurityConstraint();
SecurityCollection collection = new SecurityCollection();
boolean create = alwaysCreate;
if (element.getTransportGuarantee() !=
ServletSecurity.TransportGuarantee.NONE) {
constraint.setUserConstraint(element.getTransportGuarantee().name());
create = true;
}
if (element.getRolesAllowed().length > 0) {
String[] roles = element.getRolesAllowed();
for (String role : roles) {
constraint.addAuthRole(role);
}
create = true;
}
if (element.getEmptyRoleSemantic() != EmptyRoleSemantic.PERMIT) {
constraint.setAuthConstraint(true);
create = true;
}
if (create) {
collection.addPattern(urlPattern);
constraint.addCollection(collection);
return constraint;
}
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:33,代码来源:SecurityConstraint.java
示例4: HttpConstraintElement
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
/**
* Default constraint is permit with no transport guarantee.
*/
public HttpConstraintElement() {
// Default constructor
this.emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
this.transportGuarantee = TransportGuarantee.NONE;
this.rolesAllowed = new String[0];
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:HttpConstraintElement.java
示例5: createConstraint
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
private static SecurityConstraint createConstraint(HttpConstraintElement element, String urlPattern,
boolean alwaysCreate) {
SecurityConstraint constraint = new SecurityConstraint();
SecurityCollection collection = new SecurityCollection();
boolean create = alwaysCreate;
if (element.getTransportGuarantee() != ServletSecurity.TransportGuarantee.NONE) {
constraint.setUserConstraint(element.getTransportGuarantee().name());
create = true;
}
if (element.getRolesAllowed().length > 0) {
String[] roles = element.getRolesAllowed();
for (String role : roles) {
constraint.addAuthRole(role);
}
create = true;
}
if (element.getEmptyRoleSemantic() != EmptyRoleSemantic.PERMIT) {
constraint.setAuthConstraint(true);
create = true;
}
if (create) {
collection.addPattern(urlPattern);
constraint.addCollection(collection);
return constraint;
}
return null;
}
开发者ID:how2j,项目名称:lazycat,代码行数:32,代码来源:SecurityConstraint.java
示例6: HttpConstraintElement
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
/**
* Default constraint is permit with no transport guarantee.
*/
public HttpConstraintElement() {
// Default constructor
this.emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
this.transportGuarantee = TransportGuarantee.NONE;
this.rolesAllowed = new String[0];
}
开发者ID:how2j,项目名称:lazycat,代码行数:10,代码来源:HttpConstraintElement.java
示例7: createConstraint
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
private static SecurityConstraint createConstraint(
HttpConstraintElement element, String urlPattern, boolean alwaysCreate) {
SecurityConstraint constraint = new SecurityConstraint();
SecurityCollection collection = new SecurityCollection();
boolean create = alwaysCreate;
if (element.getTransportGuarantee() !=
ServletSecurity.TransportGuarantee.NONE) {
constraint.setUserConstraint(element.getTransportGuarantee().name());
create = true;
}
if (element.getRolesAllowed().length > 0) {
String[] roles = element.getRolesAllowed();
for (String role : roles) {
constraint.addAuthRole(role);
}
create = true;
}
if (element.getEmptyRoleSemantic() != EmptyRoleSemantic.PERMIT) {
constraint.setAuthConstraint(true);
create = true;
}
if (create) {
collection.addPattern(urlPattern);
constraint.addCollection(collection);
return constraint;
}
return null;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:33,代码来源:SecurityConstraint.java
示例8: isAllowed
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
public static boolean isAllowed ( final HttpConstraint constraint, final HttpServletRequest request )
{
final EmptyRoleSemantic empty = constraint.value ();
final String[] allowedRoles = constraint.rolesAllowed ();
if ( allowedRoles == null || allowedRoles.length <= 0 )
{
// no roles
if ( EmptyRoleSemantic.PERMIT.equals ( empty ) )
{
return true;
}
else
{
return false;
}
}
else
{
// check all roles .. one is ok
for ( final String role : allowedRoles )
{
if ( request.isUserInRole ( role ) )
{
return true;
}
}
// we ran out of options
return false;
}
}
开发者ID:eclipse,项目名称:packagedrone,代码行数:35,代码来源:HttpContraintControllerInterceptor.java
示例9: changePassword
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
@RequestMapping ( "/{userId}/newPassword" )
@HttpConstraint ( value = EmptyRoleSemantic.PERMIT )
public ModelAndView changePassword ( @PathVariable ( "userId" ) final String userId, final HttpServletRequest request )
{
final Map<String, Object> model = new HashMap<> ();
final boolean you = isYou ( userId, request );
if ( !you && !request.isUserInRole ( "ADMIN" ) )
{
return CommonController.createAccessDenied ();
}
final DatabaseUserInformation user = this.storage.getUserDetails ( userId );
if ( user == null )
{
return CommonController.createNotFound ( "user", userId );
}
final DatabaseDetails details = user.getDetails ( DatabaseDetails.class );
if ( details == null )
{
return CommonController.createNotFound ( "details", userId );
}
final NewPassword data = new NewPassword ();
data.setEmail ( details.getEmail () );
model.put ( "you", you );
model.put ( "command", data );
return new ModelAndView ( "user/newPassword", model );
}
开发者ID:eclipse,项目名称:packagedrone,代码行数:34,代码来源:UserController.java
示例10: changePasswordPost
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
@RequestMapping ( value = "/{userId}/newPassword", method = RequestMethod.POST )
@HttpConstraint ( value = EmptyRoleSemantic.PERMIT )
public ModelAndView changePasswordPost ( @PathVariable ( "userId" ) final String userId, @Valid @FormData ( "command" ) final NewPassword data, final BindingResult result, final HttpServletRequest request )
{
final boolean you = isYou ( userId, request );
if ( !you && !request.isUserInRole ( "ADMIN" ) )
{
return CommonController.createAccessDenied ();
}
final Map<String, Object> model = new HashMap<> ();
model.put ( "you", you );
if ( result.hasErrors () )
{
model.put ( "command", data );
return new ModelAndView ( "user/newPassword", model );
}
try
{
if ( !you /* but we are ADMIN */ )
{
this.storage.updatePassword ( userId, null, data.getPassword () );
}
else
{
this.storage.updatePassword ( userId, data.getCurrentPassword (), data.getPassword () );
}
return new ModelAndView ( "redirect:/user/" + userId + "/view" );
}
catch ( final Exception e )
{
return CommonController.createError ( "Error", "Failed to change password", e );
}
}
开发者ID:eclipse,项目名称:packagedrone,代码行数:39,代码来源:UserController.java
示例11: changePassword
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
@RequestMapping ( "/{userId}/newPassword" )
@HttpConstraint ( value = EmptyRoleSemantic.PERMIT )
public ModelAndView changePassword ( @PathVariable ( "userId" ) final String userId, final HttpServletRequest request)
{
final Map<String, Object> model = new HashMap<> ();
final boolean you = isYou ( userId, request );
if ( !you && !request.isUserInRole ( "ADMIN" ) )
{
return CommonController.createAccessDenied ();
}
final DatabaseUserInformation user = this.storage.getUserDetails ( userId );
if ( user == null )
{
return CommonController.createNotFound ( "user", userId );
}
final DatabaseDetails details = user.getDetails ( DatabaseDetails.class );
if ( details == null )
{
return CommonController.createNotFound ( "details", userId );
}
final NewPassword data = new NewPassword ();
data.setEmail ( details.getEmail () );
model.put ( "you", you );
model.put ( "command", data );
return new ModelAndView ( "user/newPassword", model );
}
开发者ID:ctron,项目名称:package-drone,代码行数:34,代码来源:UserController.java
示例12: changePasswordPost
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
@RequestMapping ( value = "/{userId}/newPassword", method = RequestMethod.POST )
@HttpConstraint ( value = EmptyRoleSemantic.PERMIT )
public ModelAndView changePasswordPost ( @PathVariable ( "userId" ) final String userId, @Valid @FormData ( "command" ) final NewPassword data, final BindingResult result, final HttpServletRequest request)
{
final boolean you = isYou ( userId, request );
if ( !you && !request.isUserInRole ( "ADMIN" ) )
{
return CommonController.createAccessDenied ();
}
final Map<String, Object> model = new HashMap<> ();
model.put ( "you", you );
if ( result.hasErrors () )
{
model.put ( "command", data );
return new ModelAndView ( "user/newPassword", model );
}
try
{
if ( !you /* but we are ADMIN */ )
{
this.storage.updatePassword ( userId, null, data.getPassword () );
}
else
{
this.storage.updatePassword ( userId, data.getCurrentPassword (), data.getPassword () );
}
return new ModelAndView ( "redirect:/user/" + userId + "/view" );
}
catch ( final Exception e )
{
return CommonController.createError ( "Error", "Failed to change password", e );
}
}
开发者ID:ctron,项目名称:package-drone,代码行数:39,代码来源:UserController.java
示例13: getEmptyRoleSemantic
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
public EmptyRoleSemantic getEmptyRoleSemantic() {
return emptyRoleSemantic;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:4,代码来源:HttpConstraintElement.java
示例14: HttpConstraintElement
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; //导入依赖的package包/类
/**
* Constructs a default HTTP constraint element
*/
public HttpConstraintElement() {
this(EmptyRoleSemantic.PERMIT);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:HttpConstraintElement.java
注:本文中的javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论