Ibm Practical File 20222
Ibm Practical File 20222
PRACTICAL FILE
Section E
PRACTICAL - 1
Objective: Create Cloud Foundry Application and deploy the application on
IBM cloud.
Step 5 – Click on Overview and scroll down and click on Enable Continuous Delivery.
Step 6 – Click on Delivery Pipeline and Click on New to create new API Key
Step 7 – Click on Eclipse Orion Web IDE editor to open your app editor.
Step 1: Open the Eclipse Orion Web IDE editor of your application.
Step 1: Create a Clone application using Cloud foundry as above and click on Eclipse editor.
We have to create three files 1) package.json 2) manifest.yml 3) app.js
Step 2: Create app.js file and write the code below.
Code: -
var http = require("http");
var port = process.env.VCAP_APP_PORT || 8080;
http.createServer(function(request, response){ response.writeHead(200,{'content-
Type':'text/plain'});
response.end('Hello Everyone!');
}).listen(port);
Step 3: Create manifest.yml file and write the below code.
Code: -
applications:
- path: .
memory: 128M
instances: 1
name: privatecloud
host: cloud
disk_qutta: 1024M
Step 4: Create package.json file and write the below code.
Code: -
{
"name": "NodejsStarterApp",
"version":"0.0.1",
"discription":"Hello World Nodejs example",
"scripts":{
"start":"node app.js"
}}
Step 5: Click on the File and select export to zip and download the zip file.
Step 6: Extract the zip file and open command prompt in the extracted folder. In order to use
IBM CLI we have to install it from the link - https://github.com/IBM-Cloud/ibm-cloud-cli-
release/releases/
Step 7
Step 8 - https://node-red-sqsvu-2022-03-15.eu-gb.mybluemix.net/ui
Step 5: Drag and Drop inject node, translator node and debug node and connect everyone as
below.
Step 6 – Configure Inject node.
PRACTICAL – 7
def signin(request):
if not request.session.session_key:
request.session.create()
session_key = request.session.session_key
identity_provider_url = 'https://identity-provider.com/sso/saml'
provider_entity_id = 'https://service-provider.com/metadata'
assertion_consumer_service_url = 'https://service-provider.com/acs'
'xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
'xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
'ProtocolBinding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Version': '2.0',
'ID': session_key,
'ProviderName': provider_entity_id,
'IssueInstant': dt.now().isoformat(),
'Destination': identity_provider_url,
'AssertionConsumerServiceURL': assertion_consumer_service_url
})
issuer = cElementTree.SubElement(
root,
'saml:Issuer',
text='http://sp.example.com/demo1/metadata.php'
name_id_policy = cElementTree.SubElement(
root,
'samlp:NameIDPolicy',
attrib={
'Format': 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
'AllowCreate': 'true'
}
)
authentication_context = cElementTree.SubElement(
root,
'samlp:RequestedAuthnContext',
attrib={
'Comparison': 'exact'
authentication_context_class_ref = cElementTree.SubElement(
authentication_context,
'saml:AuthnContextClassRef',
text='urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport'
base64_encoded_authentication_request = b64encode(authentication_request)
return HttpResponseRedirect(f'{identity_provider_url}?
AuthNRequest={base64_encoded_authentication_request}’)
import binascii
@csrf_exempt
def validate_saml_response(request):
try:
saml_response = request.POST['SAMLResponse']
except KeyError:
return HttpResponseBadRequest()
try:
saml_response_xml = b64decode(saml_response)
except binascii.Error:
return HttpResponseBadRequest()
namespaces = {
'ns1': "urn:oasis:names:tc:SAML:2.0:assertion",
'ns2': http://www.w3.org/2000/09/xmldsig#
xml_verifier = XMLVerifier()
try:
verified_xml = xml_verifier.verify(
except:
return HttpResponseBadRequest()
try:
user = User.objects.get(email=email)
except User.DoesNotExist:
return HttpResponseNotFound()
login(request, user)
PRACTICAL – 10
Create vpc
While creating Subnet choose vpc
Created 2 subnets
Create two route tables for public and private
Subnet