Example usage for javax.naming AuthenticationException AuthenticationException

List of usage examples for javax.naming AuthenticationException AuthenticationException

Introduction

In this page you can find the example usage for javax.naming AuthenticationException AuthenticationException.

Prototype

public AuthenticationException() 

Source Link

Document

Constructs a new instance of AuthenticationException.

Usage

From source file:org.axway.grapes.utils.client.GrapesClient.java

/**
 *
 * Provide Jersey client for the targeted Grapes server with authentication
 *
 * @param user/*ww w  . ja v a 2 s. c om*/
 * @param password
 * @return
 * @throws javax.naming.AuthenticationException
 */
private Client getClient(final String user, final String password) throws AuthenticationException {
    if (user == null || password == null) {
        LOG.error(
                "You are currently using a method that requires credentials. Please use '-user' '-password'.");
        throw new AuthenticationException();
    }

    final Client client = getClient();
    client.addFilter(new HTTPBasicAuthFilter(user, password));

    return client;
}

From source file:org.ligoj.app.plugin.id.ldap.dao.UserLdapRepositoryTest.java

@Test
public void setPasswordBadPassword() throws NamingException {
    final UserOrg user = new UserOrg();
    user.setDn("cn=Any");
    final LdapContext mockCtx = newLdapContext();
    Mockito.doThrow(new AuthenticationException()).when(mockCtx).modifyAttributes(ArgumentMatchers.eq("cn=Any"),
            ArgumentMatchers.any(ModificationItem[].class));
    MatcherUtil.assertThrows(/*  ww w  .  ja  v  a2 s . c  o m*/
            Assertions.assertThrows(ValidationJsonException.class,
                    () -> repository.setPassword(user, "wrong-old-password", "new-password")),
            "password", "login");
}

From source file:org.sakaiproject.mediasite.tool.MediasiteContentLaunch.java

private Document Connect()
        throws AuthenticationException, ParserConfigurationException, SAXException, IOException {
    java.util.Date startDate = new java.util.Date();

    String responseString = "";
    String outputString = "";
    int responseStatus = -1;

    try {/* w  ww  .  ja  v  a  2 s .  c  om*/
        responseStatus = this.connection.getResponseCode();
        CommonUtilities.WriteLog(String.format("WebApiUtilities.Connect: %s returned %d.",
                this.connection.getURL().toString(), responseStatus));
        if (responseStatus == HttpURLConnection.HTTP_OK) {
            InputStreamReader isr = new InputStreamReader(this.connection.getInputStream());
            BufferedReader in = new BufferedReader(isr);
            while ((responseString = in.readLine()) != null) {
                outputString += responseString;
            }
        } else if (responseStatus == HttpURLConnection.HTTP_UNAUTHORIZED) {
            // bad credentials or insufficient privs
            CommonUtilities.WriteLog(String.format(
                    "WebApiUtilities.Connect: \n\tURL: %s\n\tResponse Code: %s\n\tResponse Message: %s\n\tUser: %s",
                    this.connection.getURL().toString(), responseStatus, this.connection.getResponseMessage(),
                    ""), null, true);
            throw new AuthenticationException();
        } else {
            String errorMessage = readStream(this.connection.getErrorStream());
            CommonUtilities.WriteLog(String.format(
                    "WebApiUtilities.Connect: \n\tURL: %s\n\tResponse Code: %s\n\tResponse Message: %s\n\t%s",
                    this.connection.getURL().toString(), responseStatus, this.connection.getResponseMessage(),
                    errorMessage), null, true);
            throw new AuthenticationException(); //WebApiHTTPException(responseStatus, null, errorMessage);
        }
    } catch (SSLHandshakeException e) {
        CommonUtilities.WriteLog(String.format(
                "WebApiUtilities.Connect: An SSL/Certificate error has occurred. Response Code: %s",
                responseStatus), e, true);
    } catch (IOException e) {
        CommonUtilities.WriteLog(
                String.format("WebApiUtilities.Connect: A general error has occurred. Response Code: %s",
                        responseStatus),
                e, true);
    }
    CommonUtilities.WriteLog("WebApiUtilities.Connect executed in "
            + (System.currentTimeMillis() - startDate.getTime()) + " milliseconds.");
    return CommonUtilities.isNullOrEmpty(outputString) ? null : parseXmlFile(outputString);
}