1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package com.att.authz.cadi;
\r
25 import static com.att.authz.layer.Result.OK;
\r
27 import java.util.Date;
\r
29 import com.att.authz.env.AuthzEnv;
\r
30 import com.att.authz.env.AuthzTrans;
\r
31 import com.att.authz.layer.Result;
\r
32 import com.att.cadi.CredVal;
\r
33 import com.att.dao.DAOException;
\r
34 import com.att.dao.aaf.hl.Question;
\r
37 * DirectAAFUserPass is intended to provide password Validation directly from Cassandra Database, and is only
\r
38 * intended for use in AAF itself. The normal "AAF Taf" objects are, of course, clients.
\r
42 public class DirectAAFUserPass implements CredVal {
\r
43 private final AuthzEnv env;
\r
44 private final Question question;
\r
46 public DirectAAFUserPass(AuthzEnv env, Question question, String appPass) {
\r
48 this.question = question;
\r
52 public boolean validate(String user, Type type, byte[] pass) {
\r
54 AuthzTrans trans = env.newTransNoAvg();
\r
55 Result<Date> result = question.doesUserCredMatch(trans, user, pass);
\r
56 trans.logAuditTrail(env.info());
\r
57 switch(result.status) {
\r
62 env.warn().log(user, "failed Password Validation:",result.errorString());
\r
64 } catch (DAOException e) {
\r
65 System.out.println(" exception in DirectAAFUserPass class ");
\r
66 e.printStackTrace();
\r
67 env.error().log(e,"Cannot validate User/Pass from Cassandra");
\r