Upgrade to latest oparent
[aaf/authz.git] / authz-batch / src / main / java / com / att / authz / actions / CredPrint.java
1 /*******************************************************************************
2  * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
3  *******************************************************************************/
4 package com.att.authz.actions;
5
6 import com.att.authz.env.AuthzTrans;
7 import com.att.authz.layer.Result;
8 import com.att.dao.aaf.cass.CredDAO;
9 import org.onap.aaf.inno.env.util.Chrono;
10
11 public class CredPrint implements Action<CredDAO.Data,Void> {
12         private String text;
13
14         public CredPrint(String text) {
15                 this.text = text;
16         }
17
18         @Override
19         public Result<Void> exec(AuthzTrans trans, CredDAO.Data cred) {
20                 trans.info().log(text,cred.id,type(cred.type),Chrono.dateOnlyStamp(cred.expires));
21                 return Result.ok();
22         }
23         
24         
25         public static String type(int type) {
26                 switch(type) {
27                         case CredDAO.BASIC_AUTH: // 1
28                                         return "OLD";
29                         case CredDAO.BASIC_AUTH_SHA256: // 2 
30                                         return "U/P"; 
31                         case CredDAO.CERT_SHA256_RSA: // 200
32                                         return "Cert"; 
33                         default: 
34                                 return "Unknown";
35                 }
36         }
37
38 }