You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/07/29 19:48:51 UTC
[19/50] [abbrv] airavata-php-gateway git commit: fixing Airavata-1746
fixing Airavata-1746
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/4f6a2663
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/4f6a2663
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/4f6a2663
Branch: refs/heads/master
Commit: 4f6a26636c2f6c5df9f230788760666c291869fa
Parents: 2d01866
Author: Supun Nakandala <sc...@apache.org>
Authored: Tue Jul 21 15:44:13 2015 +0530
Committer: Supun Nakandala <sc...@apache.org>
Committed: Tue Jul 21 15:44:13 2015 +0530
----------------------------------------------------------------------
app/controllers/AccountController.php | 8 +
app/libraries/Wsis/Stubs/UserProfileManager.php | 82 +++++
.../Wsis/Stubs/UserProfileManagerStub.php | 365 +++++++++++++++++++
app/libraries/Wsis/Wsis.php | 27 ++
app/views/layout/basic.blade.php | 16 +
5 files changed, 498 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4f6a2663/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 1401fd3..1418dab 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -48,6 +48,9 @@ class AccountController extends BaseController
WSIS::addUser($username, $password, $first_name, $last_name, $email, $organization,
$address, $country, $telephone, $mobile, $im, $url);
+ //update user profile
+ WSIS::updateUserProfile($username, $email, $first_name, $last_name);
+
//creating a default project for user
ProjectUtilities::create_default_project($username);
CommonUtilities::print_success_message('New user created!');
@@ -76,6 +79,11 @@ class AccountController extends BaseController
Session::put("admin-read-only", true);
}
+ $userProfile = WSIS::getUserProfile($username);
+ if($userProfile != null && !empty($userProfile)){
+ Session::put("user-profile", $userProfile);
+ }
+
CommonUtilities::store_id_in_session($username);
CommonUtilities::print_success_message('Login successful! You will be redirected to your home page shortly.');
//TODO::If this option is not safe, have to find a better method to send credentials to identity server on every connection.
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4f6a2663/app/libraries/Wsis/Stubs/UserProfileManager.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/UserProfileManager.php b/app/libraries/Wsis/Stubs/UserProfileManager.php
new file mode 100644
index 0000000..92ef127
--- /dev/null
+++ b/app/libraries/Wsis/Stubs/UserProfileManager.php
@@ -0,0 +1,82 @@
+<?php
+namespace Wsis\Stubs;
+
+use Wsis\Stubs\UserProfileManagerStub;
+
+/**
+ * UserProfileManager class
+ *
+ * This class provide an easy to use interface for
+ * WSO2 IS 5.0.0 UserProfileMgt service.
+ */
+class UserProfileManager {
+ /**
+ * @var UserProfileManagerStub $serviceStub
+ * @access private
+ */
+ private $serviceStub;
+
+ public function __construct($server_url, $options) {
+ $this->serviceStub = new UserProfileManagerStub(
+ $server_url . "UserProfileMgtService?wsdl", $options
+ );
+ }
+
+ /**
+ * Function to get the soap client
+ *
+ * @return SoapClient
+ */
+ public function getSoapClient(){
+ return $this->serviceStub;
+ }
+
+ public function updateUserProfile($username, $email, $firstName, $lastName) {
+ $setUserProfile = new setUserProfile();
+ $setUserProfile->username = $username;
+
+ $profile = new UserProfileDTO();
+ $fieldValues = array();
+
+ $emailDTO = new UserFieldDTO();
+ $emailDTO->claimUri = "http://wso2.org/claims/emailaddress";
+ $emailDTO->fieldValue = $email;
+ array_push($fieldValues, $emailDTO);
+
+ $firstNameDTO = new UserFieldDTO();
+ $firstNameDTO->claimUri = "http://wso2.org/claims/givenname";
+ $firstNameDTO->fieldValue = $firstName;
+ array_push($fieldValues, $firstNameDTO);
+
+ $lastNameDTO = new UserFieldDTO();
+ $lastNameDTO->claimUri = "http://wso2.org/claims/lastname";
+ $lastNameDTO->fieldValue = $lastName;
+ array_push($fieldValues, $lastNameDTO);
+
+ $profile->fieldValues = $fieldValues;
+ $profile->profileName = "default";
+ $setUserProfile->profile = $profile;
+
+ $this->serviceStub->setUserProfile($setUserProfile);
+ }
+
+ public function getUserProfile($username) {
+ $getUserProfile = new getUserProfile();
+ $getUserProfile->username = $username;
+ $getUserProfile->profileName = "default";
+
+ $userProfile = $this->serviceStub->getUserProfile($getUserProfile);
+ $result = array();
+ foreach($userProfile->return->fieldValues as $fieldValue){
+ if($fieldValue->claimUri == "http://wso2.org/claims/emailaddress"){
+ $result["email"] = $fieldValue->fieldValue;
+ }else if($fieldValue->claimUri == "http://wso2.org/claims/givenname"){
+ $result["firstname"] = $fieldValue->fieldValue;
+ }else if($fieldValue->claimUri == "http://wso2.org/claims/lastname"){
+ $result["lastname"] = $fieldValue->fieldValue;
+ }
+ }
+ return $result;
+ }
+}
+?>
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4f6a2663/app/libraries/Wsis/Stubs/UserProfileManagerStub.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/UserProfileManagerStub.php b/app/libraries/Wsis/Stubs/UserProfileManagerStub.php
new file mode 100644
index 0000000..b5995b4
--- /dev/null
+++ b/app/libraries/Wsis/Stubs/UserProfileManagerStub.php
@@ -0,0 +1,365 @@
+<?php
+namespace Wsis\Stubs;
+use SoapClient;
+
+class UserProfileMgtServiceUserProfileException {
+ public $UserProfileException; // UserProfileException
+}
+
+class isReadOnlyUserStore {
+}
+
+class isReadOnlyUserStoreResponse {
+ public $return; // boolean
+}
+
+class getUserProfiles {
+ public $username; // string
+}
+
+class getUserProfilesResponse {
+ public $return; // UserProfileDTO
+}
+
+class setUserProfile {
+ public $username; // string
+ public $profile; // UserProfileDTO
+}
+
+class deleteUserProfile {
+ public $username; // string
+ public $profileName; // string
+}
+
+class getUserProfile {
+ public $username; // string
+ public $profileName; // string
+}
+
+class getUserProfileResponse {
+ public $return; // UserProfileDTO
+}
+
+class getProfileFieldsForInternalStore {
+}
+
+class getProfileFieldsForInternalStoreResponse {
+ public $return; // UserProfileDTO
+}
+
+class isAddProfileEnabled {
+}
+
+class isAddProfileEnabledResponse {
+ public $return; // boolean
+}
+
+class isAddProfileEnabledForDomain {
+ public $domain; // string
+}
+
+class isAddProfileEnabledForDomainResponse {
+ public $return; // boolean
+}
+
+class associateID {
+ public $idpID; // string
+ public $associatedID; // string
+}
+
+class getNameAssociatedWith {
+ public $idpID; // string
+ public $associatedID; // string
+}
+
+class getNameAssociatedWithResponse {
+ public $return; // string
+}
+
+class getAssociatedIDs {
+ public $userName; // string
+}
+
+class getAssociatedIDsResponse {
+ public $return; // string
+}
+
+class removeAssociateID {
+ public $idpID; // string
+ public $associatedID; // string
+}
+
+class getInstance {
+}
+
+class getInstanceResponse {
+ public $return; // UserProfileAdmin
+}
+
+class AbstractAdmin {
+}
+
+class UserProfileException {
+}
+
+class UserProfileDTO {
+ public $fieldValues; // UserFieldDTO
+// public $profileConfigurations; // string
+// public $profileConifuration; // string
+ public $profileName; // string
+}
+
+class UserFieldDTO {
+// public $checkedAttribute; // boolean
+ public $claimUri; // string
+// public $displayName; // string
+// public $displayOrder; // int
+ public $fieldValue; // string
+// public $readOnly; // boolean
+// public $regEx; // string
+// public $required; // boolean
+}
+
+class UserProfileAdmin {
+ public $addProfileEnabled; // boolean
+ public $profileFieldsForInternalStore; // UserProfileDTO
+ public $readOnlyUserStore; // boolean
+}
+
+
+/**
+ * UserProfileManagerStub class
+ *
+ *
+ *
+ * @author {author}
+ * @copyright {copyright}
+ * @package {package}
+ */
+class UserProfileManagerStub extends SoapClient {
+
+ private static $classmap = array(
+ 'UserProfileMgtServiceUserProfileException' => 'UserProfileMgtServiceUserProfileException',
+ 'isReadOnlyUserStore' => 'isReadOnlyUserStore',
+ 'isReadOnlyUserStoreResponse' => 'isReadOnlyUserStoreResponse',
+ 'getUserProfiles' => 'getUserProfiles',
+ 'getUserProfilesResponse' => 'getUserProfilesResponse',
+ 'setUserProfile' => 'setUserProfile',
+ 'deleteUserProfile' => 'deleteUserProfile',
+ 'getUserProfile' => 'getUserProfile',
+ 'getUserProfileResponse' => 'getUserProfileResponse',
+ 'getProfileFieldsForInternalStore' => 'getProfileFieldsForInternalStore',
+ 'getProfileFieldsForInternalStoreResponse' => 'getProfileFieldsForInternalStoreResponse',
+ 'isAddProfileEnabled' => 'isAddProfileEnabled',
+ 'isAddProfileEnabledResponse' => 'isAddProfileEnabledResponse',
+ 'isAddProfileEnabledForDomain' => 'isAddProfileEnabledForDomain',
+ 'isAddProfileEnabledForDomainResponse' => 'isAddProfileEnabledForDomainResponse',
+ 'associateID' => 'associateID',
+ 'getNameAssociatedWith' => 'getNameAssociatedWith',
+ 'getNameAssociatedWithResponse' => 'getNameAssociatedWithResponse',
+ 'getAssociatedIDs' => 'getAssociatedIDs',
+ 'getAssociatedIDsResponse' => 'getAssociatedIDsResponse',
+ 'removeAssociateID' => 'removeAssociateID',
+ 'getInstance' => 'getInstance',
+ 'getInstanceResponse' => 'getInstanceResponse',
+ 'AbstractAdmin' => 'AbstractAdmin',
+ 'UserProfileException' => 'UserProfileException',
+ 'UserProfileDTO' => 'UserProfileDTO',
+ 'UserFieldDTO' => 'UserFieldDTO',
+ 'UserProfileAdmin' => 'UserProfileAdmin',
+ );
+
+ public function UserProfileManagerStub($wsdl = "UserProfileMgtService.xml", $options = array()) {
+ foreach(self::$classmap as $key => $value) {
+ if(!isset($options['classmap'][$key])) {
+ $options['classmap'][$key] = $value;
+ }
+ }
+ parent::__construct($wsdl, $options);
+ }
+
+ /**
+ *
+ *
+ * @param isAddProfileEnabled $parameters
+ * @return isAddProfileEnabledResponse
+ */
+ public function isAddProfileEnabled(isAddProfileEnabled $parameters) {
+ return $this->__soapCall('isAddProfileEnabled', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param getInstance $parameters
+ * @return getInstanceResponse
+ */
+ public function getInstance(getInstance $parameters) {
+ return $this->__soapCall('getInstance', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param isReadOnlyUserStore $parameters
+ * @return isReadOnlyUserStoreResponse
+ */
+ public function isReadOnlyUserStore(isReadOnlyUserStore $parameters) {
+ return $this->__soapCall('isReadOnlyUserStore', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param deleteUserProfile $parameters
+ * @return void
+ */
+ public function deleteUserProfile(deleteUserProfile $parameters) {
+ return $this->__soapCall('deleteUserProfile', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param isAddProfileEnabledForDomain $parameters
+ * @return isAddProfileEnabledForDomainResponse
+ */
+ public function isAddProfileEnabledForDomain(isAddProfileEnabledForDomain $parameters) {
+ return $this->__soapCall('isAddProfileEnabledForDomain', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param getUserProfile $parameters
+ * @return getUserProfileResponse
+ */
+ public function getUserProfile(getUserProfile $parameters) {
+ return $this->__soapCall('getUserProfile', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param getProfileFieldsForInternalStore $parameters
+ * @return getProfileFieldsForInternalStoreResponse
+ */
+ public function getProfileFieldsForInternalStore(getProfileFieldsForInternalStore $parameters) {
+ return $this->__soapCall('getProfileFieldsForInternalStore', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param associateID $parameters
+ * @return void
+ */
+ public function associateID(associateID $parameters) {
+ return $this->__soapCall('associateID', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param removeAssociateID $parameters
+ * @return void
+ */
+ public function removeAssociateID(removeAssociateID $parameters) {
+ return $this->__soapCall('removeAssociateID', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param getAssociatedIDs $parameters
+ * @return getAssociatedIDsResponse
+ */
+ public function getAssociatedIDs(getAssociatedIDs $parameters) {
+ return $this->__soapCall('getAssociatedIDs', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param getUserProfiles $parameters
+ * @return getUserProfilesResponse
+ */
+ public function getUserProfiles(getUserProfiles $parameters) {
+ return $this->__soapCall('getUserProfiles', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param setUserProfile $parameters
+ * @return void
+ */
+ public function setUserProfile(setUserProfile $parameters) {
+ return $this->__soapCall('setUserProfile', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+ /**
+ *
+ *
+ * @param getNameAssociatedWith $parameters
+ * @return getNameAssociatedWithResponse
+ */
+ public function getNameAssociatedWith(getNameAssociatedWith $parameters) {
+ return $this->__soapCall('getNameAssociatedWith', array($parameters), array(
+ 'uri' => 'http://mgt.profile.user.identity.carbon.wso2.org',
+ 'soapaction' => ''
+ )
+ );
+ }
+
+}
+
+?>
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4f6a2663/app/libraries/Wsis/Wsis.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Wsis.php b/app/libraries/Wsis/Wsis.php
index 7ce131f..8512717 100755
--- a/app/libraries/Wsis/Wsis.php
+++ b/app/libraries/Wsis/Wsis.php
@@ -2,6 +2,7 @@
namespace Wsis;
+use Wsis\Stubs\UserProfileManager;
use Wsis\Stubs\UserStoreManager;
use Wsis\Stubs\TenantManager;
@@ -20,6 +21,12 @@ class Wsis {
private $tenantManager;
/**
+ * @var
+ * @access private
+ */
+ private $userProfileManager;
+
+ /**
* @var string
* @access private
*/
@@ -71,6 +78,7 @@ class Wsis {
try {
$this->userStoreManager = new UserStoreManager($service_url, $parameters);
$this->tenantManager = new TenantManager($service_url, $parameters);
+ $this->userProfileManager = new UserProfileManager($service_url, $parameters);
} catch (Exception $ex) {
throw new Exception("Unable to instantiate WSO2 IS client", 0, $ex);
}
@@ -294,4 +302,23 @@ class Wsis {
//throw new Exception("Unable to create Tenant.", 0, $ex);
}
}
+
+ /**
+ * Function to update the user profile
+ * @param $username
+ * @param $email
+ * @param $firstName
+ * @param $lastName
+ */
+ public function updateUserProfile($username, $email, $firstName, $lastName){
+ $this->userProfileManager->updateUserProfile($username, $email, $firstName, $lastName);
+ }
+
+ /**
+ * Function to get the user profile of a user
+ * @param $username
+ */
+ public function getUserProfile($username){
+ return $this->userProfileManager->getUserProfile($username);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4f6a2663/app/views/layout/basic.blade.php
----------------------------------------------------------------------
diff --git a/app/views/layout/basic.blade.php b/app/views/layout/basic.blade.php
index 8dc6ca1..c6c2c1c 100755
--- a/app/views/layout/basic.blade.php
+++ b/app/views/layout/basic.blade.php
@@ -10,6 +10,16 @@
{{ HTML::style('css/bootstrap.min.css')}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
+
+ <?php
+ if(Session::has("user-profile")){
+ echo "<script>\n";
+ echo "var email = '" . Session::get("user-profile")["email"] . "'\n";
+ echo "var fullName = '" . Session::get("user-profile")["firstname"]
+ . " " . Session::get("user-profile")["lastname"] . "'";
+ echo "</script>";
+ }
+ ?>
</head>
<?php
@@ -60,6 +70,9 @@ if (Session::has("admin-alert")) {
e.preventDefault();
showCollectorDialog();
});
+ },fieldValues: {
+ email : email !== 'undefined' ? email : "",
+ fullname : fullName !== 'undefined' ? fullName : ""
}
},
"674243b0": {
@@ -70,6 +83,9 @@ if (Session::has("admin-alert")) {
showCollectorDialog();
});
}
+ },fieldValues: {
+ email : email !== 'undefined' ? email : "",
+ fullname : fullName !== 'undefined' ? fullName : ""
}
});