Package org.jboss.ws.metadata.wsse

Examples of org.jboss.ws.metadata.wsse.Config


         return config.getDefaultConfig();

      Operation operation = port.getOperations().get(opName);
      if (operation == null)
      {
         Config portConfig = port.getDefaultConfig();
         return (portConfig == null) ? config.getDefaultConfig() : portConfig;

      }

      return operation.getConfig();
View Full Code Here


   public static void handleInbound(CommonMessageContext ctx) throws SOAPException, SOAPFaultException
   {
      WSSecurityConfiguration config = getSecurityConfig(ctx);
      SOAPMessageImpl soapMessage = (SOAPMessageImpl)ctx.getSOAPMessage();
      Config actualConfig = getActualConfig(config, null);

      SOAPHeader soapHeader = soapMessage.getSOAPHeader();
      QName secQName = new QName(Constants.WSSE_NS, "Security");

      Element secHeaderElement = (soapHeader != null) ? Util.findElement(soapHeader, secQName) : null;
     
      if (secHeaderElement == null)
      {
         // This is ok, we always allow faults to be received because WS-Security does not encrypt faults
         if (soapMessage.getSOAPBody().getFault() != null)
            return;

         OperationMetaData opMetaData = ctx.getOperationMetaData();
         if (opMetaData == null)
         {
            // Get the operation meta data from the soap message
            // for the server side inbound message.
            EndpointMetaData epMetaData = ctx.getEndpointMetaData();
            opMetaData = soapMessage.getOperationMetaData(epMetaData);
         }

         String operation = null;
         String port = null;
         if (opMetaData != null)
         {
            operation = opMetaData.getQName().toString();
            port = opMetaData.getEndpointMetaData().getPortName().getLocalPart();
         }
         

         if (hasRequirements(config, operation, port))
            throw convertToFault(new InvalidSecurityHeaderException("This service requires <wsse:Security>, which is missing."));
      }

      try
      {

         Config operationConfig = getConfig(ctx, config, soapMessage);
         if (secHeaderElement != null)
         {
            decodeHeader(ctx, config, operationConfig, soapMessage, secHeaderElement);
         }
View Full Code Here

      Operation operation = port.getOperations().get(opName != null ? opName.toString() : null);
      if (operation == null)
      {
         //if the operation name was not available or didn't match any wsse configured operation,
         //we fall back to the port wsse config (if available) or the default config.
         Config portConfig = port.getDefaultConfig();
         return (portConfig == null) ? configuration.getDefaultConfig() : portConfig;
      }
      return operation.getConfig();
   }
View Full Code Here

      return operation.getConfig();
   }

   private static boolean hasRequirements(WSSecurityConfiguration config, String operation, String port)
   {
      Config operationConfig = getConfig(config, port, operation);
      return (operationConfig != null && operationConfig.getRequires() != null);
   }
View Full Code Here

      return (operationConfig != null && operationConfig.getRequires() != null);
   }

   private static List<OperationDescription<RequireOperation>> buildRequireOperations(WSSecurityConfiguration config, String operation, String port)
   {     
    Config operationConfig = getConfig(config, port, operation);
      if (operationConfig == null)
         return null;

      Requires requires = operationConfig.getRequires();
      if (requires == null)
         return null;

      ArrayList<OperationDescription<RequireOperation>> operations = new ArrayList<OperationDescription<RequireOperation>>();
      RequireTimestamp requireTimestamp = requires.getRequireTimestamp();
View Full Code Here

      String opName = null;
      OperationMetaData opMetaData = ctx.getOperationMetaData();
      if (opMetaData != null)
         opName = opMetaData.getQName().toString();

      Config opConfig = getConfig(config, port, opName);
      log.debug("WS-Security config: " + opConfig);

      // Nothing to process
      if (opConfig == null)
         return;

      ArrayList<OperationDescription<EncodingOperation>> operations = new ArrayList<OperationDescription<EncodingOperation>>();
      Timestamp timestamp = opConfig.getTimestamp();
      if (timestamp != null)
      {
         operations.add(new OperationDescription<EncodingOperation>(TimestampOperation.class, null, null, timestamp.getTtl(), null));
      }

      NonceGenerator nonceGenerator = null;
      Username username = opConfig.getUsername();
      if (username != null)
      {
         Object user = ctx.get(Stub.USERNAME_PROPERTY);
         Object pass = ctx.get(Stub.PASSWORD_PROPERTY);

         if (user == null && pass == null)
         {
            user = ctx.get(BindingProvider.USERNAME_PROPERTY);
            pass = ctx.get(BindingProvider.PASSWORD_PROPERTY);
         }

         if (user != null && pass != null)
         {
            operations.add(new OperationDescription<EncodingOperation>(SendUsernameOperation.class, null, user.toString(), pass.toString(), null,username.isDigestPassword(), username.isUseNonce(), username.isUseCreated()));
            ctx.put(StubExt.PROPERTY_AUTH_TYPE, StubExt.PROPERTY_AUTH_TYPE_WSSE);
         }

         NonceFactory factory = Util.loadFactory(NonceFactory.class, config.getNonceFactory(), DefaultNonceFactory.class);
         nonceGenerator = factory.getGenerator();
      }

      Sign sign = opConfig.getSign();
      if (sign != null)
      {
         List<Target> targets = convertTargets(sign.getTargets());
         if (sign.isIncludeTimestamp())
         {
            if (timestamp == null)
               operations.add(new OperationDescription<EncodingOperation>(TimestampOperation.class, null, null, null, null));

            if (targets != null && targets.size() > 0)
               targets.add(new WsuIdTarget("timestamp"));
         }

         operations.add(new OperationDescription<EncodingOperation>(SignatureOperation.class, targets, sign.getAlias(), null, null));
      }

      Encrypt encrypt = opConfig.getEncrypt();
      if (encrypt != null)
      {
         List<Target> targets = convertTargets(encrypt.getTargets());
         operations.add(new OperationDescription<EncodingOperation>(EncryptionOperation.class, targets, encrypt.getAlias(), null, encrypt.getAlgorithm()));
      }
View Full Code Here

    */
   public void testDefaultRoles() throws Exception
   {
      WSSecurityConfiguration wsConfig = load("jboss-wsse-default-roles.xml");

      Config config = wsConfig.getDefaultConfig();
      Authorize authorize = config.getAuthorize();
      assertFalse("Unchecked", authorize.isUnchecked());
      List<Role> roles = authorize.getRoles();

      assertEquals("Expected 2 roles", 2, roles.size());

View Full Code Here

   public void testPortRoles() throws Exception
   {
      WSSecurityConfiguration wsConfig = load("jboss-wsse-port-roles.xml");

      Port port = wsConfig.getPorts().get("TestPort");
      Config config = port.getDefaultConfig();
      Authorize authorize = config.getAuthorize();
      assertFalse("Unchecked", authorize.isUnchecked());
      List<Role> roles = authorize.getRoles();

      assertEquals("Expected 2 roles", 2, roles.size());
View Full Code Here

    */
   public void testDefaultRole() throws Exception
   {
      WSSecurityConfiguration wsConfig = load("jboss-wsse-default-role.xml");

      Config config = wsConfig.getDefaultConfig();
      Authorize authorize = config.getAuthorize();
      assertFalse("Unchecked", authorize.isUnchecked());
      List<Role> roles = authorize.getRoles();

      assertEquals("Expected 1 roles", 1, roles.size());

View Full Code Here

   public void testPortRole() throws Exception
   {
      WSSecurityConfiguration wsConfig = load("jboss-wsse-port-role.xml");

      Port port = wsConfig.getPorts().get("TestPort");
      Config config = port.getDefaultConfig();
      Authorize authorize = config.getAuthorize();
      assertFalse("Unchecked", authorize.isUnchecked());
      List<Role> roles = authorize.getRoles();

      assertEquals("Expected 1 roles", 1, roles.size());
View Full Code Here

TOP

Related Classes of org.jboss.ws.metadata.wsse.Config

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.