e24403272d2920f1cc9cc850d4903fa692f72b35
[portal.git] / ecomp-portal-BE-os / src / main / webapp / WEB-INF / jsp / oid-user.jsp
1 <%--
2   ============LICENSE_START==========================================
3   ONAP Portal
4   ===================================================================
5   Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6   ===================================================================
7  
8   Unless otherwise specified, all software contained herein is licensed
9   under the Apache License, Version 2.0 (the “License”);
10   you may not use this software except in compliance with the License.
11   You may obtain a copy of the License at
12  
13               http://www.apache.org/licenses/LICENSE-2.0
14  
15   Unless required by applicable law or agreed to in writing, software
16   distributed under the License is distributed on an "AS IS" BASIS,
17   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   See the License for the specific language governing permissions and
19   limitations under the License.
20  
21   Unless otherwise specified, all documentation contained herein is licensed
22   under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
23   you may not use this documentation except in compliance with the License.
24   You may obtain a copy of the License at
25  
26               https://creativecommons.org/licenses/by/4.0/
27  
28   Unless required by applicable law or agreed to in writing, documentation
29   distributed under the License is distributed on an "AS IS" BASIS,
30   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31   See the License for the specific language governing permissions and
32   limitations under the License.
33  
34   ============LICENSE_END============================================
35  
36   ECOMP is a trademark and service mark of AT&T Intellectual Property.
37   --%>
38 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
39 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
40 <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
41 <%@ taglib prefix="o" tagdir="/WEB-INF/tags"%>
42 <o:header title="User"/>
43 <o:topbar pageName="User"/>
44 <div class="container-fluid main">
45         <div class="row-fluid">
46                 <div class="span10 offset1">
47
48                         <h1>Hello ${ userInfo.name }</h1>
49
50                         <div>
51                                 <p>This page requires that the user be logged in with a valid account and the <code>ROLE_USER</code> Spring Security authority.
52                                 If you are reading this page, <span class="text-success">you are currently logged in</span>.</p>
53                                 
54                                 <security:authentication var="user" property="principal" />
55                                 
56                                 <p>The authorization provider will create a Principal object based on the <code>iss</code> and <code>sub</code>
57                                 claims associated with your ID token. This value can be used as a globally unique username within the application
58                                 (though it's not meant to be human-readable).
59                                 Your Principal is: <code>${ user }</code></p>
60
61                                 <p>The authorization provider will assign your account a set of authorities depending on how it's configured.
62                                 Your current login has the following Spring Security authorities:</p>
63                                 
64                                 <ul>
65                                         <security:authentication property="authorities" var="authorities" />
66                                         <c:forEach items="${authorities}" var="auth">
67                                                 <li><code>${ auth }</code></li>
68                                         </c:forEach>
69                                 </ul>
70                                 
71                                 <h3>ID Token</h3>
72
73                                 <p>Your ID Token has the following set of claims:</p>
74                                 
75                                 <security:authentication property="idToken" var="idToken" />
76                                 <table class="table table-striped table-hover" id="idTokenTable">
77                                         <thead>
78                                                 <tr>
79                                                         <th class="span1">Name</th>
80                                                         <th class="span11">Value</th>
81                                                 </tr>
82                                         </thead>
83                                         <tbody>
84                                         </tbody>                                
85                                 </table>
86                                 
87                                 <p>The ID Token header contains the following claims:</p>
88                                 
89                                 <table class="table table-striped table-hover" id="idTokenHeader">
90                                         <thead>
91                                                 <tr>
92                                                         <th class="span1">Name</th>
93                                                         <th class="span11">Value</th>
94                                                 </tr>
95                                         </thead>
96                                         <tbody>
97                                         </tbody>                                
98                                 </table>
99
100                                 <h3>User Info</h3>
101                                 
102                                 <p>The call to the User Info Endpoint returned the following set of claims:</p>
103
104                                 <table class="table table-striped table-hover" id="userInfoTable">
105                                         <thead>
106                                                 <tr>
107                                                         <th class="span1">Name</th>
108                                                         <th class="span11">Value</th>
109                                                 </tr>
110                                         </thead>
111                                         <tbody>
112                                         </tbody>                                
113                                 </table>
114
115                         </div>
116
117                 </div>
118         </div>
119 </div>
120
121 <script type="text/javascript">
122         $(document).ready(function () {
123
124                 var idTokenString = "${ idToken.serialize() }";
125                 var idToken = jwt.WebTokenParser.parse(idTokenString);
126                 var idHeader = JSON.parse(jwt.base64urldecode(idToken.headerSegment));
127                 var idClaims = JSON.parse(jwt.base64urldecode(idToken.payloadSegment));
128         
129                 _.each(idClaims, function(val, key, list) {
130                         if (_.contains(["iat", "exp", "auth_time", "nbf"], key)) {
131                                 // it's a date field, parse and print it
132                                 var date = new Date(val * 1000);
133                                 $('#idTokenTable tbody').append('<tr><td>' + _.escape(key) + '</td><td><span title="' + _.escape(val) + '">' + date + '</span></td></tr>');
134                         } else {
135                                 $('#idTokenTable tbody').append('<tr><td>' + _.escape(key) + '</td><td>' + _.escape(val) + '</td></tr>');
136                         }
137                 });
138                 
139                 _.each(idHeader, function(val, key, list) {
140                         if (_.contains(["iat", "exp", "auth_time", "nbf"], key)) {
141                                 // it's a date field, parse and print it
142                                 var date = new Date(val * 1000);
143                                 $('#idTokenHeader tbody').append('<tr><td>' + _.escape(key) + '</td><td><span title="' + _.escape(val) + '">' + date + '</span></td></tr>');
144                         } else {
145                                 $('#idTokenHeader tbody').append('<tr><td>' + _.escape(key) + '</td><td>' + _.escape(val) + '</td></tr>');
146                         }
147                 });
148                 
149                 var userInfo = ${ userInfoJson };
150                 _.each(userInfo, function(val, key, list) {
151                         $('#userInfoTable tbody').append('<tr><td>' + _.escape(key) + '</td><td>' + _.escape(val) + '</td></tr>');
152                 });
153         });
154
155 </script>
156
157 <o:footer />