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


Java Secured类代码示例

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


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

示例1: doSecuredCheck

import org.apache.deltaspike.security.api.authorization.Secured; //导入依赖的package包/类
@Secures
@Secured({ })
@SuppressWarnings("UnusedDeclaration")
public boolean doSecuredCheck(InvocationContext invocationContext) throws Exception
{
    List<Class<? extends AccessDecisionVoter>> voterClasses = new ArrayList<Class<? extends AccessDecisionVoter>>();

    List<Annotation> annotatedTypeMetadata = extractMetadata(invocationContext);

    for (Annotation annotation : annotatedTypeMetadata)
    {
        if (Secured.class.isAssignableFrom(annotation.annotationType()))
        {
            voterClasses.addAll(Arrays.asList(((Secured) annotation).value()));
        }
        else if (voterContext instanceof EditableAccessDecisionVoterContext)
        {
            ((EditableAccessDecisionVoterContext) voterContext)
                    .addMetaData(annotation.annotationType().getName(), annotation);
        }
    }

    invokeVoters(invocationContext, voterClasses);

    //needed by @SecurityBindingType
    //X TODO check the use-cases for it
    return true;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:29,代码来源:SecuredAnnotationAuthorizer.java

示例2: getBlockedResult

import org.apache.deltaspike.security.api.authorization.Secured; //导入依赖的package包/类
@Secured(TestAccessDecisionVoter.class)
public String getBlockedResult()
{
    return "blocked result";
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:6,代码来源:SecuredBean3.java

示例3: getResult

import org.apache.deltaspike.security.api.authorization.Secured; //导入依赖的package包/类
@Secured(TestAccessDecisionVoter.class)
public String getResult()
{
    return "result";
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:6,代码来源:SecuredBean3.java

示例4: invokeVoters

import org.apache.deltaspike.security.api.authorization.Secured; //导入依赖的package包/类
public static void invokeVoters(EditableAccessDecisionVoterContext accessDecisionVoterContext,
                                ConfigDescriptor<?> viewConfigDescriptor)
{
    if (viewConfigDescriptor == null)
    {
        return;
    }

    List<Secured> securedMetaData = viewConfigDescriptor.getMetaData(Secured.class);

    if (securedMetaData.isEmpty())
    {
        return;
    }

    accessDecisionVoterContext.addMetaData(ViewConfig.class.getName(), viewConfigDescriptor.getConfigClass());
    for (Annotation viewMetaData : viewConfigDescriptor.getMetaData())
    {
        if (!viewMetaData.annotationType().equals(Secured.class))
        {
            accessDecisionVoterContext.addMetaData(viewMetaData.annotationType().getName(), viewMetaData);
        }
    }

    Secured.Descriptor securedDescriptor = viewConfigDescriptor
            .getExecutableCallbackDescriptor(Secured.class, Secured.Descriptor.class);

    AccessDecisionState voterState = AccessDecisionState.VOTE_IN_PROGRESS;
    try
    {
        accessDecisionVoterContext.setState(voterState);

        List<Set<SecurityViolation>> violations = securedDescriptor.execute(accessDecisionVoterContext);
        Set<SecurityViolation> allViolations = createViolationResult(violations);

        if (!allViolations.isEmpty())
        {
            voterState = AccessDecisionState.VIOLATION_FOUND;
            for (SecurityViolation violation : allViolations)
            {
                accessDecisionVoterContext.addViolation(violation);
            }

            Class<? extends ViewConfig> errorView = securedMetaData.iterator().next().errorView();
            throw new ErrorViewAwareAccessDeniedException(allViolations, errorView);
        }
    }
    finally
    {
        if (AccessDecisionState.VOTE_IN_PROGRESS.equals(voterState))
        {
            voterState = AccessDecisionState.NO_VIOLATION_FOUND;
        }

        accessDecisionVoterContext.setState(voterState);
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:58,代码来源:SecurityUtils.java


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