if (aaaCertServiceConfig == null) {
throw new IllegalArgumentException("Certificate Manager service configuration is null");
}
- if (aaaCertServiceConfig.isUseConfig()) {
+ if (aaaCertServiceConfig.getUseConfig()) {
if (aaaCertServiceConfig.getCtlKeystore() != null
&& aaaCertServiceConfig.getCtlKeystore().getStorePassword() != null
&& aaaCertServiceConfig.getCtlKeystore().getStorePassword().isEmpty()) {
aaaCertServiceConfig = new AaaCertServiceConfigBuilder(aaaCertServiceConfig).setCtlKeystore(ctlKeystore)
.setTrustKeystore(trustKeystore).build();
}
- if (aaaCertServiceConfig.isUseMdsal()) {
+ if (aaaCertServiceConfig.getUseMdsal()) {
aaaCertProvider = new DefaultMdsalSslData(new AaaCertMdsalProvider(dataBroker, encryptionSrv),
aaaCertServiceConfig.getBundleName(), aaaCertServiceConfig.getCtlKeystore(),
aaaCertServiceConfig.getTrustKeystore());
* .apache.shiro.authc.AuthenticationToken)
*/
@Override
- protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
-
+ protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken token)
+ throws AuthenticationException {
// Delegates all AuthN lookup responsibility to the super class
try {
final String username = getUsername(token);
return super.doGetAuthenticationInfo(token);
} catch (ClassCastException e) {
LOG.info("Couldn't service the LDAP connection", e);
+ return null;
}
- return null;
}
/**
* @throws ClassCastException The incoming token is not username/password (i.e., X.509
* certificate)
*/
- public static String getUsername(AuthenticationToken token) throws ClassCastException {
- if (null == token) {
- return null;
- }
- return (String) token.getPrincipal();
+ public static String getUsername(final AuthenticationToken token) throws ClassCastException {
+ return token == null ? null : (String) token.getPrincipal();
}
/**
* username/password form (i.e., X.509 certificate)
*/
protected String getUsername(final PrincipalCollection principals) throws ClassCastException {
-
- if (null == principals) {
- return null;
- }
- return (String) getAvailablePrincipal(principals);
+ return principals == null ? null : (String) getAvailablePrincipal(principals);
}
@Override
- protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+ protected AuthorizationInfo doGetAuthorizationInfo(final PrincipalCollection principals) {
AuthorizationInfo ai = null;
try {
* .PrincipalCollection, org.apache.shiro.realm.ldap.LdapContextFactory)
*/
@Override
- protected AuthorizationInfo queryForAuthorizationInfo(PrincipalCollection principals,
- LdapContextFactory ldapContextFactory) throws
- NamingException {
+ protected AuthorizationInfo queryForAuthorizationInfo(final PrincipalCollection principals,
+ final LdapContextFactory ldapContextFactory) throws NamingException {
AuthorizationInfo authorizationInfo = null;
try {
}
public static AuthorizationInfo buildAuthorizationInfo(final Set<String> roleNames) {
- if (null == roleNames) {
- return null;
- }
- return new SimpleAuthorizationInfo(roleNames);
+ return roleNames == null ? null : new SimpleAuthorizationInfo(roleNames);
}
/**
* @return A set of roles
* @throws NamingException If the ldap search fails
*/
- protected Set<String> getRoleNamesForUser(final String username,
- final LdapContext ldapContext) throws NamingException {
+ protected Set<String> getRoleNamesForUser(final String username, final LdapContext ldapContext)
+ throws NamingException {
final Set<String> roleNames = new LinkedHashSet<>();
final SearchControls searchControls = createSearchControls();
LOG.debug("LDAP returned \"{}\" attribute for \"{}\"", attr.getID(), username);
if (attr.getID().equals(ldapAttributeForComparison)) {
final Collection<String> groupNamesExtractedFromLdap = LdapUtils.getAllAttributeValues(attr);
- final Map<String, Set<String>> groupsToRoles = this.GROUPS_TO_ROLES_MAPPING_STRATEGY
+ final Map<String, Set<String>> groupsToRoles = GROUPS_TO_ROLES_MAPPING_STRATEGY
.mapGroupsToRoles(groupNamesExtractedFromLdap, ROLE_NAMES_DELIMITER, groupRolesMap);
final Collection<String> roleNamesFromLdapGroups;