-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement of getting software migration list
- Loading branch information
Showing
11 changed files
with
631 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package common | ||
|
||
import ( | ||
"encoding/base64" | ||
"errors" | ||
"github.com/cloud-barista/cm-grasshopper/lib/rsautil" | ||
honeybee "github.com/cloud-barista/cm-honeybee/server/pkg/api/rest/model" | ||
"github.com/jollaman999/utils/logger" | ||
) | ||
|
||
func ConnectionInfoDecryptSecrets(connectionInfo *honeybee.ConnectionInfo) (*honeybee.ConnectionInfo, error) { | ||
encryptedUser, err := base64.StdEncoding.DecodeString(connectionInfo.User) | ||
if err != nil { | ||
errMsg := "error occurred while decrypting the base64 encoded encrypted user (" + err.Error() + ")" | ||
logger.Println(logger.ERROR, true, errMsg) | ||
|
||
return nil, errors.New(errMsg) | ||
} | ||
|
||
decryptedUserBytes, err := rsautil.DecryptWithPrivateKey(encryptedUser, HoneybeePrivateKey) | ||
if err != nil { | ||
errMsg := "error occurred while decrypting user (" + err.Error() + ")" | ||
logger.Println(logger.ERROR, true, errMsg) | ||
|
||
return nil, errors.New(errMsg) | ||
} | ||
connectionInfo.User = string(decryptedUserBytes) | ||
|
||
encryptedPassword, err := base64.StdEncoding.DecodeString(connectionInfo.Password) | ||
if err != nil { | ||
errMsg := "error occurred while decrypting the base64 encoded encrypted password (" + err.Error() + ")" | ||
logger.Println(logger.ERROR, true, errMsg) | ||
|
||
return nil, errors.New(errMsg) | ||
} | ||
|
||
decryptedPasswordBytes, err := rsautil.DecryptWithPrivateKey(encryptedPassword, HoneybeePrivateKey) | ||
if err != nil { | ||
errMsg := "error occurred while decrypting password (" + err.Error() + ")" | ||
logger.Println(logger.ERROR, true, errMsg) | ||
|
||
return nil, errors.New(errMsg) | ||
} | ||
connectionInfo.Password = string(decryptedPasswordBytes) | ||
|
||
encryptedPrivateKey, err := base64.StdEncoding.DecodeString(connectionInfo.PrivateKey) | ||
if err != nil { | ||
errMsg := "error occurred while decrypting the base64 encoded encrypted private key (" + err.Error() + ")" | ||
logger.Println(logger.ERROR, true, errMsg) | ||
|
||
return nil, errors.New(errMsg) | ||
} | ||
|
||
decryptedPrivateKeyBytes, err := rsautil.DecryptWithPrivateKey(encryptedPrivateKey, HoneybeePrivateKey) | ||
if err != nil { | ||
errMsg := "error occurred while decrypting private key (" + err.Error() + ")" | ||
logger.Println(logger.ERROR, true, errMsg) | ||
|
||
return nil, errors.New(errMsg) | ||
} | ||
connectionInfo.PrivateKey = string(decryptedPrivateKeyBytes) | ||
|
||
return connectionInfo, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.