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.io.IOException;
26 import java.util.GregorianCalendar;
27 import java.util.List;
29 import org.onap.aaf.auth.batch.helpers.LastNotified;
30 import org.onap.aaf.auth.batch.reports.Notify;
31 import org.onap.aaf.auth.env.AuthzTrans;
32 import org.onap.aaf.cadi.Access;
33 import org.onap.aaf.misc.env.util.Chrono;
35 public abstract class NotifyCredBody extends NotifyBody {
37 private final String explanation;
38 private final String instruction;
40 public NotifyCredBody(Access access, String name) {
41 super(access,"cred",name);
44 explanation = "The following Credentials that you are responsible for "
45 + "are expiring on the dates shown. <br><br>"
48 instruction = "<br><h3>Instructions for 'Password':</h3><ul>"
49 + "<li><b><i>Click</i></b> on the Fully Qualified ID to ADD a new Password</li>"
50 + "<li><b>REMEMBER!</b> You are not finished until you <ol>"
51 + "<li><b>CHANGE <i>ALL</i></b> the configurations on <b><i>ALL</i></b> your processes!!</li>"
52 + "<li><b>BOUNCE</b> them</li></ol>"
53 + "<li>IF there is a WARNING, click the link for more information</li>"
58 * Default Dynamic Text. Override is expected
61 protected String dynamic() {
62 return "Failure to act before the expiration date will cause your App's Authentications to fail.";
66 public boolean body(AuthzTrans trans, StringBuilder sb, int indent, Notify n, String id) {
67 print(sb,indent,explanation);
68 print(sb,indent,dynamic());
69 println(sb,indent,instruction);
70 println(sb,indent,"<table>");
72 println(sb,indent,"<tr>");
74 println(sb,indent,"<th>Fully Qualified ID</th>");
75 println(sb,indent,"<th>Unique ID</th>");
76 println(sb,indent,"<th>Type</th>");
77 println(sb,indent,"<th>Expires</th>");
78 println(sb,indent,"<th>Warnings</th>");
80 println(sb,indent,"</tr>");
86 GregorianCalendar gc = new GregorianCalendar();
87 for(List<String> row : rows.get(id)) {
95 type = "x509 (Certificate)";
98 type = "Unknown, see AAF GUI";
101 theid = "<a href=\""+n.guiURL+"/creddetail?ns="+row.get(2)+"\">"+theid+"</a>";
102 gc.setTimeInMillis(Long.parseLong(row.get(5)));
103 expires = Chrono.niceUTCStamp(gc);
108 println(sb,indent,"<tr>");
110 printCell(sb,indent,theid);
111 printCell(sb,indent,info);
112 printCell(sb,indent,type);
113 printCell(sb,indent,expires);
114 printCell(sb,indent,warnings);
116 println(sb,indent,"</tr>");
119 println(sb,indent,"</table>");
125 public void record(AuthzTrans trans, StringBuilder query, String id, List<String> notified, LastNotified ln) {
126 for(List<String> row : rows.get(id)) {
127 for(String n : notified) {
128 // Need to match LastNotified Key ... cred.id + '|' + inst.type + '|' + inst.tag;
129 ln.update(query, n, row.get(0), row.get(1)+'|'+row.get(3)+'|'+row.get(6));
135 public String user(List<String> row) {
136 if( (row != null) && row.size()>1) {