X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Factions%2FURFutureApprove.java;fp=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Factions%2FURFutureApprove.java;h=0000000000000000000000000000000000000000;hb=d86e3224e6a5af2bd2b713f93bea5e6677d3ebc2;hp=a228a8ca68db758096f081c71c0843ea4802a657;hpb=e3163b2d5609753f874e2f52fd5ef67fa063af7a;p=aaf%2Fauthz.git diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApprove.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApprove.java deleted file mode 100644 index a228a8ca..00000000 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApprove.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * ============LICENSE_START==================================================== - * org.onap.aaf - * =========================================================================== - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * =========================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END==================================================== - * - */ - -package org.onap.aaf.auth.batch.actions; - -import java.io.IOException; -import java.util.Date; -import java.util.GregorianCalendar; - -import org.onap.aaf.auth.batch.helpers.Approval; -import org.onap.aaf.auth.batch.helpers.UserRole; -import org.onap.aaf.auth.dao.cass.FutureDAO; -import org.onap.aaf.auth.dao.cass.NsDAO; -import org.onap.aaf.auth.dao.hl.Function; -import org.onap.aaf.auth.dao.hl.Question; -import org.onap.aaf.auth.dao.hl.Function.FUTURE_OP; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.layer.Result; -import org.onap.aaf.auth.org.Organization.Expiration; -import org.onap.aaf.misc.env.APIException; -import org.onap.aaf.misc.env.util.Chrono; - -import com.datastax.driver.core.Cluster; - -public class URFutureApprove extends ActionDAO implements Action, Key { - private final Date start; - private final Date expires; - - public URFutureApprove(AuthzTrans trans, Cluster cluster, boolean dryRun) throws APIException, IOException { - super(trans,cluster, dryRun); - GregorianCalendar gc = new GregorianCalendar(); - start = gc.getTime(); - expires = trans.org().expiration(gc, Expiration.Future).getTime(); - } - - public URFutureApprove(AuthzTrans trans, ActionDAO adao) { - super(trans, adao); - GregorianCalendar gc = new GregorianCalendar(); - start = gc.getTime(); - expires = trans.org().expiration(gc, Expiration.Future).getTime(); - } - - @Override - public Result exec(AuthzTrans trans, UserRole ur,String text) { - if (dryRun) { - return Result.ok(text); - } else { - Result rns = q.deriveNs(trans, ur.ns()); - if (rns.isOK()) { - - FutureDAO.Data data = new FutureDAO.Data(); - data.id=null; // let Create function assign UUID - data.target=Function.FOP_USER_ROLE; - - data.memo = key(ur); - data.start = start; - data.expires = ur.expires(); - try { - data.construct = ur.urdd().bytify(); - } catch (IOException e) { - return Result.err(e); - } - Result rfuture = f.createFuture(trans, data, Function.FOP_USER_ROLE, ur.user(), rns.value, FUTURE_OP.A); - if (rfuture.isOK()) { - trans.info().log(rfuture.value, text, ur.user(), data.memo); - } else { - trans.error().log(rfuture.details, text); - } - return rfuture; - } else { - return Result.err(rns); - } - } - } - - @Override - public String key(UserRole ur) { - String expire; - if (expires.before(start)) { - expire = "' - EXPIRED "; - } else { - expire = "' - expiring "; - } - - if (Question.OWNER.equals(ur.rname())) { - return Approval.RE_VALIDATE_OWNER + ur.ns() + expire + Chrono.dateOnlyStamp(ur.expires()); - } else if (Question.ADMIN.equals(ur.rname())) { - return Approval.RE_VALIDATE_ADMIN + ur.ns() + expire + Chrono.dateOnlyStamp(ur.expires()); - } else { - return Approval.RE_APPROVAL_IN_ROLE + ur.role() + expire + Chrono.dateOnlyStamp(ur.expires()); - } - } - -} \ No newline at end of file