@@ -486,7 +486,7 @@ public void enableAutoBuildRoleLinks(boolean autoBuildRoleLinks) {
486
486
/**
487
487
* EnableAcceptJsonRequest controls whether to accept json as a request parameter
488
488
*
489
- * @param acceptJsonRequest
489
+ * @param acceptJsonRequest a boolean that indicates whether JSON requests are accepted.
490
490
*/
491
491
public void enableAcceptJsonRequest (boolean acceptJsonRequest ) {
492
492
this .acceptJsonRequest = acceptJsonRequest ;
@@ -782,6 +782,11 @@ public EnforceResult enforceExWithMatcher(String matcher, Object... rvals) {
782
782
783
783
/**
784
784
* addNamedMatchingFunc add MatchingFunc by ptype RoleManager
785
+ *
786
+ * @param ptype the type of the role manager.
787
+ * @param name the name of the matching function to be added.
788
+ * @param fn the matching function.
789
+ * @return whether the matching function was successfully added.
785
790
*/
786
791
public boolean addNamedMatchingFunc (String ptype , String name , BiPredicate <String , String > fn ) {
787
792
if (rmMap .containsKey (ptype )) {
@@ -798,6 +803,11 @@ public boolean addNamedMatchingFunc(String ptype, String name, BiPredicate<Strin
798
803
799
804
/**
800
805
* addNamedMatchingFunc add MatchingFunc by ptype RoleManager
806
+ *
807
+ * @param ptype the type of the role manager.
808
+ * @param name the name of the matching function to be added.
809
+ * @param fn the domain matching function.
810
+ * @return whether the matching function was successfully added.
801
811
*/
802
812
public boolean addNamedDomainMatchingFunc (String ptype , String name , BiPredicate <String , String > fn ) {
803
813
if (rmMap .containsKey (ptype )) {
@@ -813,8 +823,14 @@ public boolean addNamedDomainMatchingFunc(String ptype, String name, BiPredicate
813
823
}
814
824
815
825
/**
816
- * addNamedLinkConditionFunc Add condition function fn for Link userName-> roleName,
826
+ * addNamedLinkConditionFunc Add condition function fn for Link userName-> roleName,
817
827
* when fn returns true, Link is valid, otherwise invalid
828
+ *
829
+ * @param ptype the type of the role manager.
830
+ * @param user the username for which the link condition is being added.
831
+ * @param role the role associated with the user for which the condition is evaluated.
832
+ * @param fn a function that takes an array of parameters (e.g., [user, role]) and returns a Boolean indicating the validity of the link.
833
+ * @return whether the Link is valid.
818
834
*/
819
835
public boolean addNamedLinkConditionFunc (String ptype , String user , String role , Function <String [], Boolean > fn ){
820
836
if (condRmMap .containsKey (ptype )){
@@ -826,8 +842,15 @@ public boolean addNamedLinkConditionFunc(String ptype, String user, String role,
826
842
}
827
843
828
844
/**
829
- * addNamedDomainLinkConditionFunc Add condition function fn for Link userName-> {roleName, domain},
845
+ * addNamedDomainLinkConditionFunc Add condition function fn for Link userName-> {roleName, domain},
830
846
* when fn returns true, Link is valid, otherwise invalid
847
+ *
848
+ * @param ptype the type of the conditional role manager.
849
+ * @param user the username for which the link condition is being added.
850
+ * @param role the role associated with the user for which the condition is evaluated.
851
+ * @param domain the domain associated with the role.
852
+ * @param fn a function that takes an array of parameters (e.g., [user, role, domain]) and returns a Boolean indicating the validity of the link.
853
+ * @return whether the Link is valid.
831
854
*/
832
855
public boolean addNamedDomainLinkConditionFunc (String ptype , String user , String role , String domain , Function <String [], Boolean > fn ) {
833
856
if (condRmMap .containsKey (ptype )){
@@ -839,7 +862,13 @@ public boolean addNamedDomainLinkConditionFunc(String ptype, String user, String
839
862
}
840
863
841
864
/**
842
- * setNamedLinkConditionFuncParams Sets the parameters of the condition function fn for Link userName->roleName
865
+ * setNamedLinkConditionFuncParams Sets the parameters of the condition function fn for Link userName->roleName
866
+ *
867
+ * @param ptype the type of the conditional role manager.
868
+ * @param user the username for which the link condition parameters are being set.
869
+ * @param role the role associated with the user for which the parameters are being configured.
870
+ * @param params an array of parameters to be passed to the condition function.
871
+ * @return whether the Link is valid.
843
872
*/
844
873
public boolean setNamedLinkConditionFuncParams (String ptype , String user , String role , String ... params ){
845
874
if (condRmMap .containsKey (ptype )){
@@ -852,7 +881,14 @@ public boolean setNamedLinkConditionFuncParams(String ptype, String user, String
852
881
853
882
/**
854
883
* setNamedDomainLinkConditionFuncParams Sets the parameters of the condition function fn
855
- * for Link userName->{roleName, domain}
884
+ * for Link userName->{roleName, domain}
885
+ *
886
+ * @param ptype the type of the conditional role manager.
887
+ * @param user the username for which the link condition parameters are being set.
888
+ * @param role the role associated with the user for which the parameters are being configured.
889
+ * @param domain the domain associated with the role and user.
890
+ * @param params an array of parameters to be passed to the condition function, allowing customization of the condition logic.
891
+ * @return whether the parameters were successfully set.
856
892
*/
857
893
public boolean setNamedDomainLinkConditionFuncParams (String ptype , String user , String role , String domain , String ... params ){
858
894
if (condRmMap .containsKey (ptype )){
@@ -863,6 +899,14 @@ public boolean setNamedDomainLinkConditionFuncParams(String ptype, String user,
863
899
return false ;
864
900
}
865
901
902
+ /***
903
+ * getRTokens Retrieves request tokens and populates them into the provided parameters map.
904
+ *
905
+ * @param parameters a map to store the request tokens and their corresponding values.
906
+ * @param rType the type of the request for which tokens are being retrieved, used to access the appropriate model.
907
+ * @param rvals the request needs to be mediated, usually an array
908
+ * of strings, can be class instances if ABAC is used.
909
+ */
866
910
private void getRTokens (Map <String , Object > parameters , String rType , Object ... rvals ) {
867
911
String [] requestTokens = model .model .get ("r" ).get (rType ).tokens ;
868
912
if (requestTokens .length != rvals .length ) {
@@ -874,6 +918,14 @@ private void getRTokens(Map<String, Object> parameters, String rType, Object...
874
918
}
875
919
}
876
920
921
+ /***
922
+ * getPTokens Retrieves policy tokens and populates them into the provided parameters map.
923
+ *
924
+ * @param parameters a map to store the policy tokens and their corresponding values.
925
+ * @param pType the type of the policy for which tokens are being retrieved, used for context.
926
+ * @param pvals a list of values corresponding to the policy tokens.
927
+ * @param pTokens an array of tokens associated with the policy.
928
+ */
877
929
private void getPTokens (Map <String , Object > parameters , String pType , List <String > pvals , String [] pTokens ) {
878
930
if (pTokens .length != pvals .size ()) {
879
931
throw new CasbinMatcherException ("invalid policy size: expected " + pTokens .length +
0 commit comments