-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): push C-SCALE attributes to LDAP
- Extended LDAP schema with 3 new attributes used by C-SCALE project. - Added attribute module to check allowed values in user category attribute. - Updated XML configu to push new attributes to LDAP.
- Loading branch information
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...run/core/impl/modules/attributes/urn_perun_user_attribute_def_def_cscaleUserCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cz.metacentrum.perun.core.impl.modules.attributes; | ||
|
||
import cz.metacentrum.perun.core.api.Attribute; | ||
import cz.metacentrum.perun.core.api.User; | ||
import cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException; | ||
import cz.metacentrum.perun.core.impl.PerunSessionImpl; | ||
import cz.metacentrum.perun.core.implApi.modules.attributes.UserAttributesModuleAbstract; | ||
import cz.metacentrum.perun.core.implApi.modules.attributes.UserAttributesModuleImplApi; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Check constraint on C-SCALE user categories | ||
* | ||
* @author Pavel Zlámal <zlamal@cesnet.cz> | ||
*/ | ||
public class urn_perun_user_attribute_def_def_cscaleUserCategory extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { | ||
|
||
private final static List<String> allowedValues = Arrays.asList("commercial", "education", "government", "research", "other"); | ||
|
||
/** | ||
* Checks if users category has allowed value | ||
* | ||
* @param sess PerunSession | ||
* @param user user | ||
* @param attribute Attribute of the user | ||
* @throws WrongAttributeValueException if the attribute value has wrong/illegal syntax | ||
*/ | ||
@Override | ||
public void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute) throws WrongAttributeValueException { | ||
if (attribute.getValue() == null) return; | ||
|
||
if (!allowedValues.contains(attribute.valueAsString())) { | ||
throw new WrongAttributeValueException(attribute, "Attribute must have one of allowed values: commercial, education, government, research, other."); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters