1185 Commits

Author SHA1 Message Date
Miguel Ferreira
de63b94f2d Delegate HTTP protocol activity in RESTServiceConnector to RestClient
- All HTTP protocol activities are now handled by RestClient
- This service is now only responsible for creating requests, and
  dispatching them to the client
- Provides a Simple API for creating, updating, retrieving and deleting
  objects
2015-08-25 17:36:14 +02:00
Miguel Ferreira
8a93bb8d2d Add basic RestClient implentation based on HTTP Components 4.5
- Upgrade version of HTTP Components to 4.5
- Add helper class to create Http clients
- Add helper class to build http requests
- Add enum with the different Http Methods
- Add constants class for HTTP related values
2015-08-25 17:36:13 +02:00
Miguel Ferreira
5fc953eda2 Code clean up in cloud-utils project
- Code formatting
- Remove unused methods
2015-08-25 17:36:11 +02:00
Miguel Ferreira
83fd8f60f3 Refactor cloud-utils project into Maven default structure 2015-08-25 14:50:33 +02:00
Remi Bergsma
9c7e81e748 Merge pull request #695 from karuturi/CLOUDSTACK-8669
CLOUDSTACK-8669: create volume failed due to null charsetAdded a new private method getCharSetFromConnection() which checks if
the connection charset is null and if it is null, returns
StringUtils.getPreferredCharset

regression caused by commit f03411ca0436c8b52f5e60b0c8820fd1d1ba2ff6

* pr/695:
  CLOUDSTACK-8669: create volume failed due to null charset
  CLOUDSTACK-8669: making StringUtils.getDefaultCharset protected

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-08-17 13:54:54 +02:00
Remi Bergsma
64ff67da55 Merge pull request #654 from DaanHoogland/CLOUDSTACK-8656
Cloudstack 8656: do away with more silently ignoring exceptions.a lot of messages added.
some restructuring for test exception assertions and try-with-resource blocks

* pr/654: (29 commits)
  CLOUDSTACK-8656: more logging instead of sysout
  CLOUDSTACK-8656: use catch block for validation
  CLOUDSTACK-8656: class in json specified not found
  CLOUDSTACK-8656: removed unused classes
  CLOUDSTACK-8656: restructure of tests
  CLOUDSTACK-8656: reorganise sychronized block
  CLOUDSTACK-8656: restructure tests to ensure exception throwing
  CLOUDSTACK-8656: validate the throwing of ServerApiException
  CLOUDSTACK-8656: logging ignored exceptions
  CLOUDSTACK-8656: try-w-r removes need for empty catch block
  CLOUDSTACK-8656: try-w-r instead of clunckey close-except
  CLOUDSTACK-8656: deal with empty SQLException catch block by try-w-r
  CLOUDSTACK-8656: unnecessary close construct removed
  CLOUDSTACK-8656: message about timed buffer logging
  CLOUDSTACK-8656: message about invalid number from store
  CLOUDSTACK-8656: move cli test tool to separate file
  CLOUDSTACK-8656: exception is the rule for some tests
  CLOUDSTACK-8656: network related exception logging
  CLOUDSTACK-8656: reporting ignored exceptions in server
  CLOUDSTACK-8656: log in case we are on a platform not supporting UTF8
  ...

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-08-14 21:38:49 +02:00
Daan Hoogland
08e6e1633c CLOUDSTACK-8656: message about timed buffer logging 2015-08-14 13:29:35 +02:00
Daan Hoogland
4213a22127 CLOUDSTACK-8656: message about invalid number from store 2015-08-14 13:21:46 +02:00
Daan Hoogland
3229d96015 CLOUDSTACK-8656: move cli test tool to separate file 2015-08-14 13:15:11 +02:00
Daan Hoogland
f203acc074 CLOUDSTACK-8656: exception is the rule for some tests 2015-08-14 13:07:48 +02:00
Rohit Yadav
1d190fd0bb utils: add HttpUtils test
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 0fcd9cad1e4a687c275095d6e27bdfb3eff4add8)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 11:59:31 +05:30
Rohit Yadav
89f47ece3d CLOUDSTACK-8702: Add/refactor sessionkey checking code to HttpUtils
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit cb7dd7b27dff1408cc41d69152a644c5b8842bfe)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 11:56:55 +05:30
Rajani Karuturi
a65339ff1b CLOUDSTACK-8669: making StringUtils.getDefaultCharset protected
made this protected as its only use is in the Test file.
2015-08-13 17:39:44 +05:30
Daan Hoogland
c0534756d0 CLOUDSTACK-8656: network related exception logging 2015-08-11 18:14:20 +02:00
Mike Tutkowski
8b0266d12e Merge branch 'pr/547'
* pr/547:
  CLOUDSTACK-8601. VMFS storage added as local storage can be re-added as shared storage. Fail addition of a VMFS shared storage pool in case it has already been added as local storage in CS.

Signed-off-by: Mike Tutkowski <mike.tutkowski@solidfire.com>
2015-08-10 19:00:53 -06:00
Remi Bergsma
7b47c49bb0 #651 (@borisroman) CLOUDSTACK-8703: Fixed issue when listing direct..
* pr/651:
  CLOUDSTACK-8703: Fixed issue when listing directory on S3, it would only return objectSummaries when the anwser from the S3 System was truncated.

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-08-04 13:50:29 +02:00
Daan Hoogland
e8a00ed989 CLOUDSTACK-8656: try-with-resource in vmsd reader
moved closeable util function up the hierarchy
2015-08-04 11:37:06 +02:00
Remi Bergsma
60633301ac Merge pull request #647 from @wido
CLOUDSTACK-8640: Revert to AWS SDK 1.3.22

* pr/647:
  CLOUDSTACK-8640: Revert to AWS SDK 1.3.22

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-08-03 20:16:04 +02:00
Boris Schrijver
5f87e9c917 CLOUDSTACK-8703: Fixed issue when listing directory on S3, it would only return objectSummaries when the anwser from the S3 System was truncated. 2015-08-03 17:10:05 +02:00
Wido den Hollander
c32656a7ef CLOUDSTACK-8640: Revert to AWS SDK 1.3.22
The newer SDKs API changed which causes our S3 Template Downloader to never complete.

Although we should fix the Template Downloader we can revert to the old AWS SDK for now.

The fix on the longer run will be rewriting the S3 Template Downloader.

Two methods had to be disabled for now since the old SDK does not support them. They can
be re-enabled when the Template Downloader has been fixed.
2015-07-31 12:52:28 +02:00
Daan Hoogland
85e002b230 CLOUDSTACK-8656: filling empty catch block with info messages
using regexp "catch\s*\(\s*(Exception|Throwable)\s*\w*\)\s*\{\s*\}"
2015-07-30 15:51:52 +02:00
Daan Hoogland
2c110ab709 unittesting: test resolution is not guaranteed to be exact 2015-07-29 10:49:16 +02:00
Daan Hoogland
22f194b888 coverity 1125362, 1125363: assorted resource leaks
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #602
2015-07-27 14:43:11 +02:00
wilderrodrigues
d632d6312b CLOUDSTACK-8660 - Adding new StringUtils.getDefaultCharset() in order to wrap the Charset equivalet method.
- This test was added in order to cover the new StringUtils.getDefaultCharset().
     - One cannot be sure that StringUtils.getPreferredCharset() will always be equals to Charset.defaultCharset()

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #616
2015-07-23 08:08:46 +02:00
wilderrodrigues
245c976ad0 CLOUDSTACK-8660 - Adding a method to check if UTF-8 is supported
- Changing the test to call isUtf8Supported() before checking if the preferred charset is actually UTF-8

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
2015-07-23 08:08:46 +02:00
wilderrodrigues
59d7bc3573 CLOUDSTACK-8660 - Formatting test and utility classes
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
2015-07-23 08:08:45 +02:00
Daan Hoogland
2982fcf615 CLOUDSTACK-8658: test default platform charset
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #612
2015-07-22 10:06:31 +02:00
Daan Hoogland
822ea9c787 CLOUDSTACK-8658: make initializer static instead of default
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
2015-07-22 10:06:31 +02:00
Wido den Hollander
178a9f555d CLOUDSTACK-8581: S3, make connection TTL and TCP KeepAlive configureable
Signed-off-by: Wido den Hollander <wido@widodh.nl>
2015-07-17 10:07:04 +02:00
Rohit Yadav
42940a8828 CLOUDSTACK-8622: Reinstate working sessions in browser
- Login is based on sessionkey HttpOnly Cookie
- ApiServlet does login verification using sessionKey from both the request cookies
  and the API parameters. In both cases, if either or both are passed they should
  match the sessionKey stored in the current session of the HttpRequest
- UI: it no longer needs to read or set sessionkey cookie
- UI: it no longer needs to return g_sessionKey value in the API requests, though
  to support a sso mechanism g_sessionKey is still passed in the API is not null
- Secure jsessionid cookie is set to be HttpOnly and Secure
- SAML login should also set HttpOnly cookie before redirecting to UI
- SAML: listIdps & getSPMetadata APIs are readonly now, won't log out a logged in user

Performed tests (login, saml login if applicable, page refreshes, opening
multiple tabs, logout) with following combinations:
- SAML disabled, normal auth as admin, domain-admin and user
- SAML enabled, normal auth as admin, domain-admin and user; and saml sso as
  admin, domain-admin and user

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #574
This closes #308
2015-07-10 17:25:07 +05:30
Daan Hoogland
bcc8182f2f findbugs: write to static from instance these are the trivial cases of ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD as reported by findbugs
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #539
2015-07-09 15:01:58 +02:00
Daan Hoogland
4ad178e4b1 rats: licenses added
Signed-off-by: Daan Hoogland <daan@onecht.net>

This closes #535
2015-07-07 13:48:20 +02:00
Daan Hoogland
d8ab5f3ab8 findbugs: equals unit tests
Signed-off-by: Daan Hoogland <daan@onecht.net>
2015-07-07 13:48:19 +02:00
Daan Hoogland
34629446b6 findbugs equals(obj) implementations go against the contract these are removed from the call into separate calls
Signed-off-by: Daan Hoogland <daan@onecht.net>
2015-07-07 13:48:19 +02:00
Likitha Shetty
13a98dd196 CLOUDSTACK-8601. VMFS storage added as local storage can be re-added as shared storage.
Fail addition of a VMFS shared storage pool in case it has already been added as local storage in CS.
2015-07-01 10:47:36 +05:30
Rohit Yadav
107595a6a5 CLOUDSTACK-8457: SAML auth plugin improvements for production usage
* Move config options to SAML plugin
  This moves all configuration options from Config.java to SAML auth manager. This
  allows us to use the config framework.
* Make SAML2UserAuthenticator validate SAML token in httprequest
* Make logout API use ConfigKeys defined in saml auth manager
* Before doing SAML auth, cleanup local states and cookies
* Fix configurations in 4.5.1 to 4.5.2 upgrade path
* Fail if idp has no sso URL defined
* Add a default set of SAML SP cert for testing purposes
  Now to enable and use saml, one needs to do a deploydb-saml after doing a deploydb
* UI remembers login selections, IDP server

- CLOUDSTACK-8458:
    * On UI show dropdown list of discovered IdPs
    * Support SAML Federation, where there may be more than one IdP
        - New datastructure to hold metadata of SP or IdP
        - Recursive processing of IdP metadata
        - Fix login/logout APIs to get new interface and metadata data structure
        - Add org/contact information to metadata
        - Add new API: listIdps that returns list of all discovered IdPs
        - Refactor and cleanup code and tests

- CLOUDSTACK-8459:
    * Add HTTP-POST binding to SP metadata
    * Authn requests must use either HTTP POST/Artifact binding

- CLOUDSTACK-8461:
    * Use unspecified x509 cert as a fallback encryption/signing key
      In case a IDP's metadata does not clearly say if their certificates need to be
      used as signing or encryption and we don't find that, fallback to use the
      unspecified key itself.

- CLOUDSTACK-8462:
    * SAML Auth plugin should not do authorization
      This removes logic to create user if they don't exist. This strictly now
      assumes that users have been already created/imported/authorized by admins.
      As per SAML v2.0 spec section 4.1.2, the SP provider should create authn requests using
      either HTTP POST or HTTP Artifact binding to transfer the message through a
      user agent (browser in our case). The use of HTTP Redirect was one of the reasons
      why this plugin failed to work for some IdP servers that enforce this.
    * Add new User Source
      By reusing the source field, we can find if a user has been SAML enabled or not.
      The limitation is that, once say a user is imported by LDAP and then SAML
      enabled - they won't be able to use LDAP for authentication
    * UI should allow users to pass in domain they want to log into, though it is
      optional and needed only when a user has accounts across domains with same
      username and authorized IDP server
    * SAML users need to be authorized before they can authenticate
        - New column entity to track saml entity id for a user
        - Reusing source column to check if user is saml enabled or not
        - Add new source types, saml2 and saml2disabled
        - New table saml_token to solve the issue of multiple users across domains and
          to enforce security by tracking authn token and checking the samlresponse for
          the tokens
        - Implement API: authorizeSamlSso to enable/disable saml authentication for a
          user
        - Stubs to implement saml token flushing/expiry

- CLOUDSTACK-8463:
    * Use username attribute specified in global setting
      Use username attribute defined by admin from a global setting
      In case of encrypted assertion/attributes:
      - Decrypt them
      - Check signature if provided to check authenticity of message using IdP's
        public key and SP's private key
      - Loop through attributes to find the username

- CLOUDSTACK-8538:
    * Add new global config for SAML request sig algorithm

- CLOUDSTACK-8539:
    * Add metadata refresh timer task and token expiring
        - Fix domain path and save it to saml_tokens
        - Expire hour old saml tokens
        - Refresh metadata based on timer task
        - Fix unit tests

This closes #489

(cherry picked from commit 20ce346f3acb794b08a51841bab2188d426bf7dc)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	client/WEB-INF/classes/resources/messages_hu.properties
	plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java
	ui/scripts/ui-custom/login.js
2015-06-29 12:31:51 +02:00
Daan Hoogland
f5847147c0 findbugs: serializable fields
Signed-off-by: Daan Hoogland <daan@onecht.net>

This closes #533
2015-06-26 15:11:16 +02:00
wilderrodrigues
cbf5155f7b Renaming a couple of varibale to avoid misunderstanding
- All "micro" references have been replaced with "nano"

Signed-off-by: Daan Hoogland <daan@onecht.net>

This closes #516
2015-06-24 09:36:41 +02:00
wilderrodrigues
2f145378df Testing the elapsed time between 2 consecultive calls to System.nanoTime()
- 1 test was added

Signed-off-by: Daan Hoogland <daan@onecht.net>
2015-06-24 09:36:40 +02:00
wilderrodrigues
5557ad5588 Offer a getDurationInMillis() method in the Profiler utility class
- New implementation uses nanoseconds. Due to that, the places where the Profiler is used as a Monitor and/or
     a stopwatch will suffer with the difference in the return
   - Also added a getDuration(), which returns the time in nanoseconds in case someone wants to use it instead
   - Added an extra test to check if the getDuration() works fine with nanoseconds
   - Fixed the test that checks the time in milliseconds: I added an error margin to cover the test better

Signed-off-by: Daan Hoogland <daan@onecht.net>
2015-06-24 09:36:40 +02:00
Daan Hoogland
e3daa10960 findbugs: final fields
Signed-off-by: Daan Hoogland <daan@onecht.net>

This closes #517
2015-06-24 09:29:56 +02:00
wilderrodrigues
f29bf1e85c Add unit tests to cover negative cases
- Cover when the profile is not started/stopped

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #509
2015-06-23 10:03:20 +02:00
wilderrodrigues
78c802a539 Replace System.currentTimeMillis() by System.nanoTime()
- System.nanoTime() is the best way to measure elapsed time in Java.
   - It gives a resolution on the order of microseconds

The System.currentTimeMillis() is used when calculating absolut time.

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
2015-06-23 10:03:20 +02:00
Daan Hoogland
ba5b6b152e findbugs: deal with all the encoding issues in a unified way further getBytes() calls can getBytes(StringUtils.getPrefferedCharset()) instead
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #467

This closes #467
2015-06-18 12:13:26 +02:00
Rafael da Fonseca
3d1dde7a31 Remove accidental ~ character :)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #439
2015-06-15 12:10:08 +03:00
Rafael da Fonseca
a670f984d8 Fix findbugs warning HE_EQUALS_USE_HASHCODE in Ip4Address.java When overriding equals(), hashCode() must also be overriden do comply with the directive that equal objects must have equal hashcodes Without this implementation, usage of these kinds of objects in hashmaps for example, will be broken
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-06-15 12:10:07 +03:00
Rafael da Fonseca
a4659d009e Fix findbugs warning in Script.java Unnecessary boxing/unboxing of int value
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #436
2015-06-15 12:10:00 +03:00
Rafael da Fonseca
14f761a976 Fix findbugs warning in NetUtils.java Unnecessary boxing/unboxing of primitive value
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #435
2015-06-15 12:09:58 +03:00
jeff
db69c8e82b Allow PropertiesUtil to read from jar files.
PropertiesUtil has code for reading from jar files, but the
findConfigFile method will prevent it from ever returning a file in a
jar on the classpath since it always wants to have a "file:" URL and
use the File class.

This commit moves the jar file loading attempt from a catch block to
an else clause, executed if a config file:// URL could not be found.

Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #358
2015-06-08 09:19:21 +02:00
Rafael da Fonseca
bec44bffb3 Upgrade Reflections to 0.9.9
Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>

This closes #333
2015-06-03 11:01:32 +05:30