private AuthenticationFailedException newException(final String message, final Exception cause) { final String fullMessage = "PKCSAuthenticator: Authentication of client failed due to: " + message; if (cause != null) { return new AuthenticationFailedException(fullMessage, cause); } else { return new AuthenticationFailedException(fullMessage); } }
if (result instanceof AuthenticationFailedException) { final AuthenticationFailedException afe = (AuthenticationFailedException) result; if ("REPLY_REFUSED".equals(afe.getMessage())) { throw new AuthenticationFailedException(s, afe.getCause()); } else { throw new AuthenticationFailedException(s, afe);
} else if (ex instanceof AuthenticationFailedException) { AuthenticationFailedException failed = (AuthenticationFailedException) ex; String exStr = failed.getLocalizedMessage(); if (failed.getCause() != null) { exStr += " : " + failed.getCause().getLocalizedMessage(); getName() + ": Security exception: " + exStr)); refuseHandshake(failed.getMessage(), Handshake.REPLY_EXCEPTION_AUTHENTICATION_FAILED); failConnectionAttempt(); } else {
break; // no need to continue after SecurityException } catch (AuthenticationFailedException ignore) { getGfsh().logToFile(ignore.getMessage(), ignore); jmxManagerAuthEnabled = true; break; // no need to continue after AuthenticationFailedException
@Override public Object authenticate(final Properties credentials) throws AuthenticationFailedException { String user = credentials.getProperty(ResourceConstants.USER_NAME); String password = credentials.getProperty(ResourceConstants.PASSWORD); User userObj = this.userNameToUser.get(user); if (userObj == null) { throw new AuthenticationFailedException("TestSecurityManager: wrong username/password"); } if (user != null && !userObj.password.equals(password) && !"".equals(user)) { throw new AuthenticationFailedException("TestSecurityManager: wrong username/password"); } return user; }
@Override public Object authenticate(final Properties credentials) throws AuthenticationFailedException { String username = credentials.getProperty("security-username"); String password = credentials.getProperty("security-password"); if (username != null && username.equals(password)) { return username; } throw new AuthenticationFailedException("invalid username/password"); }
@Override public Object authenticate(final Properties credentials) throws AuthenticationFailedException { String username = credentials.getProperty("security-username"); String password = credentials.getProperty("security-password"); if (username != null && username.equals(password)) { return username; } throw new AuthenticationFailedException("invalid username/password"); }
@Override public Object authenticate(final Properties credentials) throws AuthenticationFailedException { String user = credentials.getProperty(ResourceConstants.USER_NAME); String password = credentials.getProperty(ResourceConstants.PASSWORD); User userObj = this.userNameToUser.get(user); if (userObj == null) { throw new AuthenticationFailedException("ExampleSecurityManager: wrong username/password"); } if (user != null && !userObj.password.equals(password) && !"".equals(user)) { throw new AuthenticationFailedException("ExampleSecurityManager: wrong username/password"); } return user; }
@Override public Principal authenticate(Properties props, DistributedMember member) throws AuthenticationFailedException { throw new AuthenticationFailedException("expected authenticate error"); }
@Override public Properties getCredentials(final Properties securityProperties, final DistributedMember server, final boolean isPeer) throws AuthenticationFailedException { String userName = securityProperties.getProperty(USER_NAME); if (userName == null) { throw new AuthenticationFailedException( "UserPasswordAuthInit: user name property [" + USER_NAME + "] not set."); } String password = securityProperties.getProperty(PASSWORD); if (password == null) { password = ""; } Properties securityPropertiesCopy = new Properties(); securityPropertiesCopy.setProperty(USER_NAME, userName); securityPropertiesCopy.setProperty(PASSWORD, password); return securityPropertiesCopy; }
@Override public Properties getCredentials(Properties props, DistributedMember server, boolean isPeer) throws AuthenticationFailedException { throw new AuthenticationFailedException("expected get credential error"); }
@Override public void init(LogWriter systemLogger, LogWriter securityLogger) throws AuthenticationFailedException { throw new AuthenticationFailedException("expected init error"); }
@Override public Properties getCredentials(Properties props, DistributedMember server, boolean isPeer) throws AuthenticationFailedException { throw new AuthenticationFailedException("expected get credential error"); }
@Override public void init(Properties securityProps, LogWriter systemLogger, LogWriter securityLogger) throws AuthenticationFailedException { throw new AuthenticationFailedException("expected init error"); }
@Override public void init(final Properties securityProperties) throws NotAuthorizedException { String jsonPropertyValue = securityProperties != null ? securityProperties.getProperty(SECURITY_JSON) : null; if (jsonPropertyValue == null) { jsonPropertyValue = DEFAULT_JSON_FILE_NAME; } if (!initializeFromJsonResource(jsonPropertyValue)) { throw new AuthenticationFailedException("TestSecurityManager: unable to find json resource \"" + jsonPropertyValue + "\" as specified by [" + SECURITY_JSON + "]."); } }
@Override public Principal authenticate(Properties props, DistributedMember member) throws AuthenticationFailedException { // Expect "security-username" and "security-password" to (a) match and (b) define permissions. String username = props.getProperty("security-username"); String password = props.getProperty("security-password"); if (StringUtils.isNotBlank(username) && !username.equals(password)) { throw new AuthenticationFailedException( "SimpleAuthenticator expects username to match password."); } return new UsernamePrincipal(username); }
@Override public Properties getCredentials(Properties props, DistributedMember server, boolean isPeer) throws AuthenticationFailedException { throw new AuthenticationFailedException("expected get credential error"); }
@Override public void init(final Properties securityProperties) throws NotAuthorizedException { String jsonPropertyValue = securityProperties != null ? securityProperties.getProperty(SECURITY_JSON) : null; if (jsonPropertyValue == null) { jsonPropertyValue = DEFAULT_JSON_FILE_NAME; } if (!initializeFromJsonResource(jsonPropertyValue)) { throw new AuthenticationFailedException( "ExampleSecurityManager: unable to find json resource \"" + jsonPropertyValue + "\" as specified by [" + SECURITY_JSON + "]."); } }
@Override public void init(final Properties securityProps, final LogWriter systemLogWriter, final LogWriter securityLogWriter) throws AuthenticationFailedException { logger.info("Initializing LdapUserAuthenticator with {}", securityProps); this.ldapServer = securityProps.getProperty(LDAP_SERVER_NAME); if (this.ldapServer == null || this.ldapServer.length() == 0) { throw new AuthenticationFailedException( "LdapUserAuthenticator: LDAP server property [" + LDAP_SERVER_NAME + "] not specified"); } this.baseDomainName = securityProps.getProperty(LDAP_BASEDN_NAME); if (this.baseDomainName == null || this.baseDomainName.length() == 0) { throw new AuthenticationFailedException( "LdapUserAuthenticator: LDAP base DN property [" + LDAP_BASEDN_NAME + "] not specified"); } final String sslName = securityProps.getProperty(LDAP_SSL_NAME); if (sslName != null && sslName.toLowerCase().equals("true")) { this.ldapUrlScheme = "ldaps://"; } else { this.ldapUrlScheme = "ldap://"; } }
private Properties getValidJavaSSLProperties() { final File jks = findTrustedJKS(); try { final Properties props = new Properties(); props.setProperty("javax.net.ssl.trustStore", jks.getCanonicalPath()); props.setProperty("javax.net.ssl.trustStorePassword", "password"); props.setProperty("javax.net.ssl.keyStore", jks.getCanonicalPath()); props.setProperty("javax.net.ssl.keyStorePassword", "password"); return props; } catch (IOException ex) { throw new AuthenticationFailedException( "SSL: Exception while opening the key store: " + ex.getMessage(), ex); } }