Example usage for javax.servlet HttpConstraintElement HttpConstraintElement

List of usage examples for javax.servlet HttpConstraintElement HttpConstraintElement

Introduction

In this page you can find the example usage for javax.servlet HttpConstraintElement HttpConstraintElement.

Prototype

public HttpConstraintElement(EmptyRoleSemantic semantic, TransportGuarantee guarantee, String... roleNames) 

Source Link

Document

Constructor to establish all of getEmptyRoleSemantic, getRolesAllowed, and getTransportGuarantee.

Usage

From source file:com.jsmartframework.web.manager.ContextControl.java

private HttpConstraintElement getHttpConstraintElement(SecureMethod secureMethod) {
    HttpConstraintElement constraintElement = null;

    if (secureMethod.getEmptyRole() != null && secureMethod.getTransport() != null) {

        EmptyRoleSemantic emptyRole = getEmptyRoleSemantic(secureMethod.getEmptyRole());

        TransportGuarantee transport = getTransportGuarantee(secureMethod.getTransport());

        if (transport == null || emptyRole == null) {
            throw new RuntimeException(
                    "Invalid transport or emptyRole attribute for [secure-method] tag! Values allowed are [confidential, none].");
        }//from   w  w w . j  a va 2  s .  com
        constraintElement = new HttpConstraintElement(emptyRole, transport,
                secureMethod.getRoles() != null ? secureMethod.getRoles() : new String[] {});

    } else if (secureMethod.getTransport() != null) {

        TransportGuarantee transport = getTransportGuarantee(secureMethod.getTransport());

        if (transport == null) {
            throw new RuntimeException(
                    "Invalid transport attribute for [secure-method] tag! Values allowed are [confidential, none].");
        }
        constraintElement = new HttpConstraintElement(transport,
                secureMethod.getRoles() != null ? secureMethod.getRoles() : new String[] {});

    } else if (secureMethod.getEmptyRole() != null) {

        EmptyRoleSemantic emptyRole = getEmptyRoleSemantic(secureMethod.getEmptyRole());

        if (emptyRole == null) {
            throw new RuntimeException(
                    "Invalid emptyRole attribute for [secure-method] tag! Values allowed are [deny, permit].");
        }
        constraintElement = new HttpConstraintElement(emptyRole);
    }

    return constraintElement;
}