X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Fservice%2FSecureServiceBase.java;h=19813ebaf14871696e52f07c5ca9e519e13ba735;hb=9bce8befd2f8627867a3c81b3830e584b58b527f;hp=89e6c092a0f9ca2655e2dcedc3f41c9435f494d1;hpb=24a56d20da89c70134cf7434d8de185519a948f0;p=clamp.git diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java index 89e6c092..19813eba 100644 --- a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java +++ b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java @@ -38,14 +38,14 @@ import com.att.eelf.configuration.EELFManager; * Base/abstract Service class. Implements shared security methods. */ public abstract class SecureServiceBase { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SecureServiceBase.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SecureServiceBase.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); // By default we'll set it to a default handler - private static UserNameHandler userNameHandler = new DefaultUserNameHandler(); + private static UserNameHandler userNameHandler = new DefaultUserNameHandler(); @Context - private SecurityContext securityContext; + private SecurityContext securityContext; /** * Get the userId from AAF/CSP. @@ -91,8 +91,12 @@ public abstract class SecureServiceBase { * app-perm-type|dev|read * * @param inPermission - * @return + * The permission to validate + * @return A boolean to indicate if the user has the permission to do + * execute the inPermission * @throws NotAuthorizedException + * In case of issues with the permission test, error is returned + * in this exception */ public boolean isAuthorized(SecureServicePermission inPermission) throws NotAuthorizedException { boolean authorized = false; @@ -133,11 +137,12 @@ public abstract class SecureServiceBase { * it will be authorized if the inPermission to check is: * app-perm-type|dev|read * - * @param aafPermission - * @return - * @throws NotAuthorizedException + * @param inPermission + * The permission to validate + * @return A boolean to indicate if the user has the permission to do + * execute the inPermission */ - public boolean isAuthorizedNoException(SecureServicePermission inPermission) throws NotAuthorizedException { + public boolean isAuthorizedNoException(SecureServicePermission inPermission) { boolean authorized = false; logger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission); // check if the user has the permission key or the permission key with a @@ -167,6 +172,14 @@ public abstract class SecureServiceBase { return authorized; } + /** + * This method can be used by the Application.class to set the + * UserNameHandler that must be used in this class. The UserNameHandler + * where to get the User name + * + * @param handler + * The Handler impl to use + */ public static final void setUserNameHandler(UserNameHandler handler) { if (handler != null) { userNameHandler = handler;