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