2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
7 * Modifications Copyright (C) 2019 IBM.
8 * ===========================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END====================================================
23 package org.onap.aaf.auth.batch.reports.bodies;
25 import java.util.GregorianCalendar;
26 import java.util.List;
28 import org.onap.aaf.auth.batch.helpers.LastNotified;
29 import org.onap.aaf.auth.batch.reports.Notify;
30 import org.onap.aaf.auth.env.AuthzTrans;
31 import org.onap.aaf.cadi.Access;
32 import org.onap.aaf.misc.env.util.Chrono;
34 public abstract class NotifyCredBody extends NotifyBody {
36 private final String explanation;
37 private final String instruction;
39 public NotifyCredBody(Access access, String name) {
40 super(access,"cred",name);
43 explanation = "The following Credentials that you are responsible for "
44 + "are expiring on the dates shown. <br><br>"
47 instruction = "<br><h3>Instructions for 'Password':</h3><ul>"
48 + "<li><b><i>Click</i></b> on the Fully Qualified ID to ADD a new Password</li>"
49 + "<li><b>REMEMBER!</b> You are not finished until you <ol>"
50 + "<li><b>CHANGE <i>ALL</i></b> the configurations on <b><i>ALL</i></b> your processes!!</li>"
51 + "<li><b>BOUNCE</b> them</li></ol>"
52 + "<li>IF there is a WARNING, click the link for more information</li>"
57 * Default Dynamic Text. Override is expected
60 protected String dynamic() {
61 return "Failure to act before the expiration date will cause your App's Authentications to fail.";
65 public boolean body(AuthzTrans trans, StringBuilder sb, int indent, Notify n, String id) {
66 print(sb,indent,explanation);
67 print(sb,indent,dynamic());
68 println(sb,indent,instruction);
69 println(sb,indent,"<table>");
71 println(sb,indent,"<tr>");
73 println(sb,indent,"<th>Fully Qualified ID</th>");
74 println(sb,indent,"<th>Unique ID</th>");
75 println(sb,indent,"<th>Type</th>");
76 println(sb,indent,"<th>Expires</th>");
77 println(sb,indent,"<th>Warnings</th>");
79 println(sb,indent,"</tr>");
85 GregorianCalendar gc = new GregorianCalendar();
86 for(List<String> row : rows.get(id)) {
94 type = "x509 (Certificate)";
97 type = "Unknown, see AAF GUI";
100 theid = "<a href=\""+n.guiURL+"/creddetail?ns="+row.get(2)+"\">"+theid+"</a>";
101 gc.setTimeInMillis(Long.parseLong(row.get(5)));
102 expires = Chrono.niceUTCStamp(gc);
107 println(sb,indent,"<tr>");
109 printCell(sb,indent,theid);
110 printCell(sb,indent,info);
111 printCell(sb,indent,type);
112 printCell(sb,indent,expires);
113 printCell(sb,indent,warnings);
115 println(sb,indent,"</tr>");
118 println(sb,indent,"</table>");
124 public void record(AuthzTrans trans, StringBuilder query, String id, List<String> notified, LastNotified ln) {
125 for(List<String> row : rows.get(id)) {
126 for(String n : notified) {
127 // Need to match LastNotified Key ... cred.id + '|' + inst.type + '|' + inst.tag;
128 ln.update(query, n, row.get(0), row.get(1)+'|'+row.get(3)+'|'+row.get(6));
134 public String user(List<String> row) {
135 if( (row != null) && row.size()>1) {