summaryrefslogtreecommitdiffstats
path: root/authz-batch/src/main/java/com/att/authz/actions/CredPrint.java
blob: ff3f7ff27b72fe75651db5e1554db041125d5ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*******************************************************************************
 * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
 *******************************************************************************/
package com.att.authz.actions;

import com.att.authz.env.AuthzTrans;
import com.att.authz.layer.Result;
import com.att.dao.aaf.cass.CredDAO;
import com.att.inno.env.util.Chrono;

public class CredPrint implements Action<CredDAO.Data,Void> {
	private String text;

	public CredPrint(String text) {
		this.text = text;
	}

	@Override
	public Result<Void> exec(AuthzTrans trans, CredDAO.Data cred) {
		trans.info().log(text,cred.id,type(cred.type),Chrono.dateOnlyStamp(cred.expires));
		return Result.ok();
	}
	
	
	public static String type(int type) {
		switch(type) {
			case CredDAO.BASIC_AUTH: // 1
					return "OLD";
			case CredDAO.BASIC_AUTH_SHA256: // 2 
					return "U/P"; 
			case CredDAO.CERT_SHA256_RSA: // 200
					return "Cert"; 
			default: 
				return "Unknown";
		}
	}

}