Package org.jboss.metadata.web.spec

Examples of org.jboss.metadata.web.spec.SecurityConstraintMetaData


    * @param securityConstraintsMD security constraints meta data
    * @return new security constraing meta data
    */
   public static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraintsMD)
   {
      final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();

      securityConstraintsMD.add(securityConstraintMD);

      return securityConstraintMD;
   }
View Full Code Here


         {
            final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper
                  .getSecurityConstraints(jbossWebMD);

            // security-constraint
            final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper
                  .newSecurityConstraint(securityConstraints);

            // web-resource-collection
            final WebResourceCollectionsMetaData webResourceCollections = WebMetaDataHelper
                  .getWebResourceCollections(securityConstraint);
View Full Code Here

            if (ejbEndpoint instanceof HttpEndpoint && (hasAuthMethod || hasTransportGuarantee)) {
                final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper
                        .getSecurityConstraints(jbossWebMD);

                // security-constraint
                final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper
                        .newSecurityConstraint(securityConstraints);

                // web-resource-collection
                final WebResourceCollectionsMetaData webResourceCollections = WebMetaDataHelper
                        .getWebResourceCollections(securityConstraint);
View Full Code Here

     *
     * @param securityConstraintsMD security constraints meta data
     * @return new security constraing meta data
     */
    public static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraintsMD) {
        final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();

        securityConstraintsMD.add(securityConstraintMD);

        return securityConstraintMD;
    }
View Full Code Here

            if (securityContraints == null)
            {
               securityContraints = new ArrayList<SecurityConstraintMetaData>();
               jbwmd.setSecurityContraints(securityContraints);
            }
            SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
            securityContraints.add(securityConstraint);
           
            WebResourceCollectionsMetaData resourceCollections = securityConstraint.getResourceCollections();
            if (resourceCollections == null)
            {
               resourceCollections = new WebResourceCollectionsMetaData();
               securityConstraint.setResourceCollections(resourceCollections);
            }
            WebResourceCollectionMetaData resourceCollection = new WebResourceCollectionMetaData();
            resourceCollections.add(resourceCollection);
           
            resourceCollection.setWebResourceName(ejbName);
            resourceCollection.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() }));
            ArrayList<String> httpMethods = new ArrayList<String>();
            resourceCollection.setHttpMethods(httpMethods);
            if (Boolean.TRUE.equals(secureWSDLAccess))
            {
               httpMethods.add("GET");
            }
            httpMethods.add("POST");

            // Optional auth-constraint
            if (beanAuthMethod != null)
            {
               // Only the first auth-method gives the war login-config/auth-method
               if (authMethod == null)
                  authMethod = beanAuthMethod;

               AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
               authConstraint.setRoleNames(Arrays.asList(new String[] { "*" }));
               securityConstraint.setAuthConstraint(authConstraint);
            }
            // Optional user-data-constraint
            if (transportGuarantee != null)
            {
               UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
               userDataConstraint.setTransportGuarantee(TransportGuaranteeType.valueOf(transportGuarantee));
               securityConstraint.setUserDataConstraint(userDataConstraint);
            }
         }
      }

      // Optional login-config/auth-method
View Full Code Here

   {
      WebMetaData webApp = unmarshal();
      List<SecurityConstraintMetaData> scs = webApp.getSecurityContraints();
      assertEquals(8, scs.size());
      // SC1
      SecurityConstraintMetaData sc1 = scs.get(0);
      WebResourceCollectionsMetaData sc1WRC = sc1.getResourceCollections();
      assertEquals(2, sc1WRC.size());
      WebResourceCollectionMetaData sc1WRC1 = sc1WRC.get(0);
      assertEquals(Collections.emptyList(), sc1WRC1.getHttpMethods());
      List<String> sc1WRC1URLs = sc1WRC1.getUrlPatterns();
      assertEquals(4, sc1WRC1URLs.size());
      assertEquals("/excluded/*", sc1WRC1URLs.get(0));
      assertEquals("/restricted/get-only/excluded/*", sc1WRC1URLs.get(1));
      assertEquals("/restricted/post-only/excluded/*", sc1WRC1URLs.get(2));
      assertEquals("/restricted/any/excluded/*", sc1WRC1URLs.get(3));
      WebResourceCollectionMetaData sc1WRC2 = sc1WRC.get(1);
      List<String> sc1WRC2URLs =  sc1WRC2.getUrlPatterns();
      assertEquals(1, sc1WRC2URLs.size());
      assertEquals("/restricted/*", sc1WRC2URLs.get(0));
      List<String> sc1WRC2Http = sc1WRC2.getHttpMethods();
      ArrayList<String> sc1WRC2HttpExpected = new ArrayList<String>();
      sc1WRC2HttpExpected.add("DELETE");
      sc1WRC2HttpExpected.add("PUT");
      sc1WRC2HttpExpected.add("HEAD");
      sc1WRC2HttpExpected.add("OPTIONS");
      sc1WRC2HttpExpected.add("TRACE");
      sc1WRC2HttpExpected.add("GET");
      sc1WRC2HttpExpected.add("POST");
      assertEquals(sc1WRC2HttpExpected, sc1WRC2Http);
      AuthConstraintMetaData sc1AC = sc1.getAuthConstraint();
      List<String> sc1Roles = sc1AC.getRoleNames();
      assertEquals(null, sc1Roles);
      TransportGuaranteeType sc1TG = sc1.getTransportGuarantee();
      assertEquals(TransportGuaranteeType.NONE, sc1TG);
      sc1Roles = sc1.getRoleNames();
      assertEquals(0, sc1Roles.size());
      assertTrue(sc1.isExcluded());
      assertFalse(sc1.isUnchecked());
      // SC2
      SecurityConstraintMetaData sc2 = scs.get(1);
      // SC8
      SecurityConstraintMetaData sc8 = scs.get(7);
      AuthConstraintMetaData sc8AC = sc8.getAuthConstraint();
      assertEquals(null, sc8AC);
      WebResourceCollectionMetaData sc8ACWRC = sc8.getResourceCollections().get(0);
      assertEquals("/restricted/not/*", sc8ACWRC.getUrlPatterns().get(0));
      assertFalse(sc8.isExcluded());
      assertTrue(sc8.isUnchecked());
   }
View Full Code Here

   </security-constraint>
   */
   private void addProtectedASC(List securityContraints)
   {
      // security-constraint/ display-name = ASC
      SecurityConstraintMetaData sc1 = new SecurityConstraintMetaData();
      sc1.setDisplayName("ASC");
      WebResourceCollectionMetaData wrc = new WebResourceCollectionMetaData();
      wrc.setName("exact, get method, roleA");
      sc1.getResourceCollections().add(wrc);
      securityContraints.add(sc1);

      // web-resource-collection/web-resource-name = exact, get method, roleA
      wrc.getUrlPatterns().add("/protected/exact/get/roleA");
      wrc.getHttpMethods().add("GET");

      // auth-constraint/role-name = RoleA
      AuthConstraintMetaData ac = new AuthConstraintMetaData();
      ArrayList<String> roles = new ArrayList<String>();
      roles.add("RoleA");
      ac.setRoleNames(roles);
      sc1.setAuthConstraint(ac);

      // user-data-constraint/transport-guarantee
      UserDataConstraintMetaData none = new UserDataConstraintMetaData();
      none.setTransportGuarantee(TransportGuaranteeType.NONE);
      sc1.setUserDataConstraint(none);
   }
View Full Code Here

   </security-constraint>
   */
   private void addProtectedBSC(List securityContraints)
   {
      // security-constraint/ display-name = ASC
      SecurityConstraintMetaData sc1 = new SecurityConstraintMetaData();
      sc1.setDisplayName("ASC");
      WebResourceCollectionMetaData wrc = new WebResourceCollectionMetaData();
      wrc.setName("exact, get method, roleA verifier");
      sc1.getResourceCollections().add(wrc);
      securityContraints.add(sc1);

      // web-resource-collection/web-resource-name = exact, get method, roleA verifier
      wrc.getUrlPatterns().add("/protected/exact/get/roleA");
      wrc.getHttpMethods().add("POST");
      wrc.getHttpMethods().add("PUT");
      wrc.getHttpMethods().add("HEAD");
      wrc.getHttpMethods().add("TRACE");
      wrc.getHttpMethods().add("OPTIONS");
      wrc.getHttpMethods().add("DELETE");

      // auth-constraint/role-name = RoleB
      AuthConstraintMetaData ac = new AuthConstraintMetaData();
      ArrayList<String> roles = new ArrayList<String>();
      roles.add("RoleB");
      ac.setRoleNames(roles);
      sc1.setAuthConstraint(ac);
   }
View Full Code Here

   }

   private void addRestrictedAnySC(WebMetaData wmd, List<SecurityConstraintMetaData> securityContraints)
   {
      // security-constraint/ display-name = RestrictedAnySC
      SecurityConstraintMetaData sc1 = new SecurityConstraintMetaData();
      sc1.setDisplayName("RestrictedAnySC");
      // web-resource-collection/web-resource-name = Restricted Access - Any
      WebResourceCollectionMetaData wrc1 = new WebResourceCollectionMetaData();
      wrc1.setName("Restricted Access - Any");
      sc1.getResourceCollections().add(wrc1);

      // All Access
      wrc1.getUrlPatterns().add("/restricted/any/*");
      wrc1.getHttpMethods().add("DELETE");
      wrc1.getHttpMethods().add("PUT");
      wrc1.getHttpMethods().add("HEAD");
      wrc1.getHttpMethods().add("OPTIONS");
      wrc1.getHttpMethods().add("TRACE");
      wrc1.getHttpMethods().add("GET");
      wrc1.getHttpMethods().add("POST");

      // auth-constraint/role-name = GetRole
      AuthConstraintMetaData ac1 = new AuthConstraintMetaData();
      ac1.getRoleNames().add("GetRole");
      ac1.getRoleNames().add("PostRole");
      sc1.setAuthConstraint(ac1);

      // user-data-constraint/transport-guarantee
      UserDataConstraintMetaData none = new UserDataConstraintMetaData();
      none.setTransportGuarantee(TransportGuaranteeType.NONE);
      sc1.setUserDataConstraint(none);
      securityContraints.add(sc1);    
   }
View Full Code Here

   }

   private void addUnrestrictedSC(List<SecurityConstraintMetaData> securityContraints)
   {
      // security-constraint/ display-name = UnrestrictedSC
      SecurityConstraintMetaData sc1 = new SecurityConstraintMetaData();
      sc1.setDisplayName("UnrestrictedSC");
      // web-resource-collection/web-resource-name = Restricted Access - Any
      WebResourceCollectionMetaData wrc1 = new WebResourceCollectionMetaData();
      wrc1.setName("Restricted Access - Any");
      sc1.getResourceCollections().add(wrc1);

      // All Access
      wrc1.getUrlPatterns().add("/restricted/not/*");
      wrc1.getHttpMethods().add("DELETE");
      wrc1.getHttpMethods().add("PUT");
      wrc1.getHttpMethods().add("HEAD");
      wrc1.getHttpMethods().add("OPTIONS");
      wrc1.getHttpMethods().add("TRACE");
      wrc1.getHttpMethods().add("GET");
      wrc1.getHttpMethods().add("POST");

      // auth-constraint/role-name = unchecked
      sc1.setAuthConstraint(null);

      // user-data-constraint/transport-guarantee
      UserDataConstraintMetaData none = new UserDataConstraintMetaData();
      none.setTransportGuarantee(TransportGuaranteeType.NONE);
      sc1.setUserDataConstraint(none);
      securityContraints.add(sc1);
   }
View Full Code Here

TOP

Related Classes of org.jboss.metadata.web.spec.SecurityConstraintMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.