X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fservice%2Fmapper%2FMapper_2_0.java;h=7abbcf6f6181551b14fd53825663501cb58c1574;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=56ba5f5f098aff9b43e648b1e99a49c5e96260c2;hpb=0c883163f5d2da8573e56fab3ddb62a1ca5b889e;p=aaf%2Fauthz.git diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/mapper/Mapper_2_0.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/mapper/Mapper_2_0.java index 56ba5f5f..7abbcf6f 100644 --- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/mapper/Mapper_2_0.java +++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/mapper/Mapper_2_0.java @@ -7,9 +7,9 @@ * 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. @@ -103,7 +103,7 @@ public class Mapper_2_0 implements Mapper() { @@ -230,14 +230,14 @@ public class Mapper_2_0 implements Mapper perms(AuthzTrans trans, List from, Perms to, String[] nss, boolean filter) { List perms = to.getPerm(); @@ -268,7 +268,7 @@ public class Mapper_2_0 implements Mapper() { @@ -283,7 +283,7 @@ public class Mapper_2_0 implements Mapper nss = q.deriveNsSplit(trans, p.getType()); PermDAO.Data pd = new PermDAO.Data(); - if (nss.isOK()) { + if (nss.isOK()) { pd.ns=nss.value.ns; pd.type = nss.value.name; pd.instance = p.getInstance(); @@ -313,12 +313,12 @@ public class Mapper_2_0 implements Mapper permkey(AuthzTrans trans, Pkey from) { return q.permFrom(trans, from.getType(),from.getInstance(),from.getAction()); } - + @Override public Result permFromRPRequest(AuthzTrans trans, Request req) { RolePermRequest from = (RolePermRequest)req; @@ -326,19 +326,19 @@ public class Mapper_2_0 implements Mapper nss = q.deriveNsSplit(trans, perm.getType()); PermDAO.Data pd = new PermDAO.Data(); - if (nss.isOK()) { + if (nss.isOK()) { pd.ns=nss.value.ns; pd.type = nss.value.name; pd.instance = from.getPerm().getInstance(); pd.action = from.getPerm().getAction(); trans.checkpoint(pd.fullPerm(), Env.ALWAYS); - + String[] roles = {}; - + if (from.getRole() != null) { roles = from.getRole().split(","); } - for (String role : roles) { + for (String role : roles) { pd.roles(true).add(role); } return Result.ok(pd); @@ -346,13 +346,13 @@ public class Mapper_2_0 implements Mapper roleFromRPRequest(AuthzTrans trans, Request req) { RolePermRequest from = (RolePermRequest)req; Result nss = q.deriveNsSplit(trans, from.getRole()); RoleDAO.Data rd = new RoleDAO.Data(); - if (nss.isOK()) { + if (nss.isOK()) { rd.ns = nss.value.ns; rd.name = nss.value.name; trans.checkpoint(rd.fullName(), Env.ALWAYS); @@ -361,39 +361,39 @@ public class Mapper_2_0 implements Mapper perm(AuthzTrans trans, Request req) { PermRequest from = (PermRequest)req; String type = from.getType(); if(type==null) { - return Result.err(Result.ERR_BadData, "Invalid Perm Type"); + return Result.err(Result.ERR_BadData, "Invalid Perm Type"); } PermDAO.Data pd = new PermDAO.Data(); if(type.contains("@")) { - String[] split = Split.splitTrim(':', type); - pd.ns = split[0]; - pd.type=split.length>1?split[1]:""; - pd.instance = from.getInstance(); - pd.action = from.getAction(); - pd.description = from.getDescription(); - return Result.ok(pd); + String[] split = Split.splitTrim(':', type); + pd.ns = split[0]; + pd.type=split.length>1?split[1]:""; + pd.instance = from.getInstance(); + pd.action = from.getAction(); + pd.description = from.getDescription(); + return Result.ok(pd); } else { - Result nss = q.deriveNsSplit(trans, from.getType()); - if (nss.isOK()) { - pd.ns=nss.value.ns; - pd.type = nss.value.name; - pd.instance = from.getInstance(); - pd.action = from.getAction(); - pd.description = from.getDescription(); - trans.checkpoint(pd.fullPerm(), Env.ALWAYS); - return Result.ok(pd); - } else { - return Result.err(nss); - } - } - } - + Result nss = q.deriveNsSplit(trans, from.getType()); + if (nss.isOK()) { + pd.ns=nss.value.ns; + pd.type = nss.value.name; + pd.instance = from.getInstance(); + pd.action = from.getAction(); + pd.description = from.getDescription(); + trans.checkpoint(pd.fullPerm(), Env.ALWAYS); + return Result.ok(pd); + } else { + return Result.err(nss); + } + } + } + @Override public Request ungrantRequest(AuthzTrans trans, String role, String type, String instance, String action) { RolePermRequest rpr = new RolePermRequest(); @@ -402,7 +402,7 @@ public class Mapper_2_0 implements Mapper roles(AuthzTrans trans, List from, Roles to, boolean filter) { - final boolean needNS = trans.requested(REQD_TYPE.ns); + final boolean needNS = trans.requested(REQD_TYPE.ns); for (RoleDAO.Data frole : from) { // Only Add Data to view if User is allowed to see this Role if (!filter || q.mayUser(trans, trans.user(), frole,Access.read).isOK()) { @@ -443,7 +443,7 @@ public class Mapper_2_0 implements Mapper rpa = PermDAO.Data.decodeToArray(trans,q,p); if (rpa.notOK()) return Result.err(rpa); - + String[] pa = rpa.value; Pkey pKey = new Pkey(); pKey.setType(pa[0]+'.'+pa[1]); @@ -460,7 +460,7 @@ public class Mapper_2_0 implements Mapper0) { - return Result.err(Status.ERR_BadData,ok); - } - } - if (passwd != null) { - to.cred = ByteBuffer.wrap(passwd.getBytes()); - to.type = CredDAO.RAW; - } else { - to.type = CredDAO.NONE; - } - } - + String passwd = from.getPassword(); + if (requiresPass) { + String ok = trans.org().isValidPassword(trans, to.id,passwd); + if (ok.length()>0) { + return Result.err(Status.ERR_BadData,ok); + } + } + if (passwd != null) { + to.cred = ByteBuffer.wrap(passwd.getBytes()); + to.type = CredDAO.RAW; + } else { + to.type = CredDAO.NONE; + } + } + // Note: Ensure requested EndDate created will match Organization Password Rules // P.S. Do not apply TempPassword rule here. Do that when you know you are doing a Create/Reset (see Service) to.expires = getExpires(trans.org(),Expiration.Password,base,from.getId()); @@ -550,7 +550,7 @@ public class Mapper_2_0 implements Mapper cred(List from, Users to) { List cu = to.getUser(); @@ -564,7 +564,7 @@ public class Mapper_2_0 implements Mapper cert(List from, Certs to) { List lc = to.getCert(); @@ -572,7 +572,7 @@ public class Mapper_2_0 implements Mapper future(AuthzTrans trans, String table, Request from, + public Result future(AuthzTrans trans, String table, Request from, Bytification content, boolean enableApproval, Memo memo, MayChange mc) { Result rMayChange; - boolean needsAppr = enableApproval?trans.requested(REQD_TYPE.future):false; + boolean needsAppr = enableApproval?trans.requested(REQD_TYPE.future):false; if (!needsAppr && (needsAppr = (rMayChange=mc.mayChange()).notOK())) { if (enableApproval) { if (!trans.requested(AuthzTrans.REQD_TYPE.future)) { @@ -601,16 +601,16 @@ public class Mapper_2_0 implements Mapper getClass(API api) { switch(api) { @@ -753,17 +753,17 @@ public class Mapper_2_0 implements Mapper> approvals(Approvals apprs) { List lappr = new ArrayList<>(); @@ -815,7 +815,7 @@ public class Mapper_2_0 implements Mapper