Code Review
/
clamp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add new tests to CLAMP
[clamp.git]
/
src
/
main
/
java
/
org
/
onap
/
clamp
/
clds
/
service
/
SecureServiceBase.java
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
89e6c09
..
acbd8bb
100644
(file)
--- a/
src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java
+++ b/
src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java
@@
-23,6
+23,9
@@
package org.onap.clamp.clds.service;
package org.onap.clamp.clds.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
import java.security.Principal;
import javax.ws.rs.NotAuthorizedException;
import java.security.Principal;
import javax.ws.rs.NotAuthorizedException;
@@
-31,21
+34,18
@@
import javax.ws.rs.core.SecurityContext;
import org.onap.clamp.clds.util.LoggingUtils;
import org.onap.clamp.clds.util.LoggingUtils;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
/**
* Base/abstract Service class. Implements shared security methods.
*/
public abstract class SecureServiceBase {
/**
* 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
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
@Context
- private SecurityContext securityContext;
+ private SecurityContext
securityContext;
/**
* Get the userId from AAF/CSP.
/**
* Get the userId from AAF/CSP.
@@
-91,8
+91,12
@@
public abstract class SecureServiceBase {
* app-perm-type|dev|read
*
* @param inPermission
* 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
* @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;
*/
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
*
* 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
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,9
+172,22
@@
public abstract class SecureServiceBase {
return authorized;
}
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;
}
}
public static final void setUserNameHandler(UserNameHandler handler) {
if (handler != null) {
userNameHandler = handler;
}
}
+
+ public void setSecurityContext(SecurityContext securityContext) {
+ this.securityContext = securityContext;
+ }
+
}
}