@@ -828,11 +828,9 @@ public Object executeWithContext(DirContext ctx) throws javax.naming.NamingExcep
828
828
*/
829
829
@ Override
830
830
public <T > T lookup (final Name dn , final AttributesMapper <T > mapper ) {
831
- return executeReadOnly (new ContextExecutor <T >() {
832
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
833
- Attributes attributes = ctx .getAttributes (dn );
834
- return mapper .mapFromAttributes (attributes );
835
- }
831
+ return executeReadOnly (ctx -> {
832
+ Attributes attributes = ctx .getAttributes (dn );
833
+ return mapper .mapFromAttributes (attributes );
836
834
});
837
835
}
838
836
@@ -842,11 +840,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
842
840
@ Override
843
841
public <T > T lookup (final String dn , final AttributesMapper <T > mapper ) {
844
842
845
- return executeReadOnly (new ContextExecutor <T >() {
846
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
847
- Attributes attributes = ctx .getAttributes (dn );
848
- return mapper .mapFromAttributes (attributes );
849
- }
843
+ return executeReadOnly (ctx -> {
844
+ Attributes attributes = ctx .getAttributes (dn );
845
+ return mapper .mapFromAttributes (attributes );
850
846
});
851
847
}
852
848
@@ -855,11 +851,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
855
851
*/
856
852
@ Override
857
853
public <T > T lookup (final Name dn , final ContextMapper <T > mapper ) {
858
- return executeReadOnly (new ContextExecutor <T >() {
859
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
860
- Object object = ctx .lookup (dn );
861
- return mapper .mapFromContext (object );
862
- }
854
+ return executeReadOnly (ctx -> {
855
+ Object object = ctx .lookup (dn );
856
+ return mapper .mapFromContext (object );
863
857
});
864
858
}
865
859
@@ -868,11 +862,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
868
862
*/
869
863
@ Override
870
864
public <T > T lookup (final String dn , final ContextMapper <T > mapper ) {
871
- return executeReadOnly (new ContextExecutor <T >() {
872
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
873
- Object object = ctx .lookup (dn );
874
- return mapper .mapFromContext (object );
875
- }
865
+ return executeReadOnly (ctx -> {
866
+ Object object = ctx .lookup (dn );
867
+ return mapper .mapFromContext (object );
876
868
});
877
869
}
878
870
@@ -881,11 +873,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
881
873
*/
882
874
@ Override
883
875
public <T > T lookup (final Name dn , final String [] attributes , final AttributesMapper <T > mapper ) {
884
- return executeReadOnly (new ContextExecutor <T >() {
885
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
886
- Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
887
- return mapper .mapFromAttributes (filteredAttributes );
888
- }
876
+ return executeReadOnly (ctx -> {
877
+ Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
878
+ return mapper .mapFromAttributes (filteredAttributes );
889
879
});
890
880
}
891
881
@@ -894,11 +884,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
894
884
*/
895
885
@ Override
896
886
public <T > T lookup (final String dn , final String [] attributes , final AttributesMapper <T > mapper ) {
897
- return executeReadOnly (new ContextExecutor <T >() {
898
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
899
- Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
900
- return mapper .mapFromAttributes (filteredAttributes );
901
- }
887
+ return executeReadOnly (ctx -> {
888
+ Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
889
+ return mapper .mapFromAttributes (filteredAttributes );
902
890
});
903
891
}
904
892
@@ -907,12 +895,10 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
907
895
*/
908
896
@ Override
909
897
public <T > T lookup (final Name dn , final String [] attributes , final ContextMapper <T > mapper ) {
910
- return executeReadOnly (new ContextExecutor <T >() {
911
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
912
- Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
913
- DirContextAdapter contextAdapter = new DirContextAdapter (filteredAttributes , dn );
914
- return mapper .mapFromContext (contextAdapter );
915
- }
898
+ return executeReadOnly (ctx -> {
899
+ Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
900
+ DirContextAdapter contextAdapter = new DirContextAdapter (filteredAttributes , dn );
901
+ return mapper .mapFromContext (contextAdapter );
916
902
});
917
903
}
918
904
@@ -921,13 +907,11 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
921
907
*/
922
908
@ Override
923
909
public <T > T lookup (final String dn , final String [] attributes , final ContextMapper <T > mapper ) {
924
- return executeReadOnly (new ContextExecutor <T >() {
925
- public T executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
926
- Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
927
- LdapName name = LdapUtils .newLdapName (dn );
928
- DirContextAdapter contextAdapter = new DirContextAdapter (filteredAttributes , name );
929
- return mapper .mapFromContext (contextAdapter );
930
- }
910
+ return executeReadOnly (ctx -> {
911
+ Attributes filteredAttributes = ctx .getAttributes (dn , attributes );
912
+ LdapName name = LdapUtils .newLdapName (dn );
913
+ DirContextAdapter contextAdapter = new DirContextAdapter (filteredAttributes , name );
914
+ return mapper .mapFromContext (contextAdapter );
931
915
});
932
916
}
933
917
@@ -962,11 +946,9 @@ public Object executeWithContext(DirContext ctx) throws javax.naming.NamingExcep
962
946
*/
963
947
@ Override
964
948
public void bind (final Name dn , final Object obj , final Attributes attributes ) {
965
- executeReadWrite (new ContextExecutor <Object >() {
966
- public Object executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
967
- ctx .bind (dn , obj , attributes );
968
- return null ;
969
- }
949
+ executeReadWrite (ctx -> {
950
+ ctx .bind (dn , obj , attributes );
951
+ return null ;
970
952
});
971
953
}
972
954
@@ -975,11 +957,9 @@ public Object executeWithContext(DirContext ctx) throws javax.naming.NamingExcep
975
957
*/
976
958
@ Override
977
959
public void bind (final String dn , final Object obj , final Attributes attributes ) {
978
- executeReadWrite (new ContextExecutor <Object >() {
979
- public Object executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
980
- ctx .bind (dn , obj , attributes );
981
- return null ;
982
- }
960
+ executeReadWrite (ctx -> {
961
+ ctx .bind (dn , obj , attributes );
962
+ return null ;
983
963
});
984
964
}
985
965
@@ -1026,38 +1006,30 @@ public void unbind(final String dn, boolean recursive) {
1026
1006
}
1027
1007
1028
1008
private void doUnbind (final Name dn ) {
1029
- executeReadWrite (new ContextExecutor <Object >() {
1030
- public Object executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
1031
- ctx .unbind (dn );
1032
- return null ;
1033
- }
1009
+ executeReadWrite (ctx -> {
1010
+ ctx .unbind (dn );
1011
+ return null ;
1034
1012
});
1035
1013
}
1036
1014
1037
1015
private void doUnbind (final String dn ) {
1038
- executeReadWrite (new ContextExecutor <Object >() {
1039
- public Object executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
1040
- ctx .unbind (dn );
1041
- return null ;
1042
- }
1016
+ executeReadWrite (ctx -> {
1017
+ ctx .unbind (dn );
1018
+ return null ;
1043
1019
});
1044
1020
}
1045
1021
1046
1022
private void doUnbindRecursively (final Name dn ) {
1047
- executeReadWrite (new ContextExecutor <Object >() {
1048
- public Object executeWithContext (DirContext ctx ) {
1049
- deleteRecursively (ctx , LdapUtils .newLdapName (dn ));
1050
- return null ;
1051
- }
1023
+ executeReadWrite (ctx -> {
1024
+ deleteRecursively (ctx , LdapUtils .newLdapName (dn ));
1025
+ return null ;
1052
1026
});
1053
1027
}
1054
1028
1055
1029
private void doUnbindRecursively (final String dn ) {
1056
- executeReadWrite (new ContextExecutor <Object >() {
1057
- public Object executeWithContext (DirContext ctx ) throws javax .naming .NamingException {
1058
- deleteRecursively (ctx , LdapUtils .newLdapName (dn ));
1059
- return null ;
1060
- }
1030
+ executeReadWrite (ctx -> {
1031
+ deleteRecursively (ctx , LdapUtils .newLdapName (dn ));
1032
+ return null ;
1061
1033
});
1062
1034
}
1063
1035
@@ -1897,15 +1869,15 @@ private enum AuthenticationStatus {
1897
1869
*/
1898
1870
UNDEFINED_FAILURE (false );
1899
1871
1900
- private boolean success ;
1872
+ private final boolean success ;
1901
1873
1902
1874
AuthenticationStatus (boolean success ) {
1903
1875
this .success = success ;
1904
1876
}
1905
1877
1906
1878
/**
1907
1879
* Return true if the authentication attempt was successful
1908
- * @return
1880
+ * @return true if the authentication attempt was successful
1909
1881
*/
1910
1882
public boolean isSuccess () {
1911
1883
return this .success ;
0 commit comments