com.atlassian.applinks.api
Class CredentialsRequiredException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.atlassian.applinks.api.CredentialsRequiredException
All Implemented Interfaces:
AuthorisationURIGenerator, java.io.Serializable

public class CredentialsRequiredException
extends java.lang.Exception
implements AuthorisationURIGenerator

Thrown by ApplicationLinkRequestFactory.createRequest(com.atlassian.sal.api.net.Request.MethodType, java.lang.String) when the endpoint requires authentication, but no credentials are available. Consumers should redirect the user to the appropriate authorisation URI to allow the user to authenticate with the remote application.

Since:
3.0
See Also:
AuthorisationURIGenerator.getAuthorisationURI(), Serialized Form

Constructor Summary
CredentialsRequiredException(AuthorisationURIGenerator authorisationURIGenerator, java.lang.String message)
           
 
Method Summary
 java.net.URI getAuthorisationURI()
          Provides a URI that can be used to configure authentication for the requested resource.
 java.net.URI getAuthorisationURI(java.net.URI callback)
           The URI that can be used to configure authentication for the requested resource.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CredentialsRequiredException

public CredentialsRequiredException(AuthorisationURIGenerator authorisationURIGenerator,
                                    java.lang.String message)
Method Detail

getAuthorisationURI

public java.net.URI getAuthorisationURI()
Description copied from interface: AuthorisationURIGenerator
Provides a URI that can be used to configure authentication for the requested resource. This URI will not result in a callback. ApplicationLinkRequestFactory implementations that support authorisation URIs must return non-null values for this method at a minimum. Support for AuthorisationURIGenerator.getAuthorisationURI(URI callback) is optional.

Specified by:
getAuthorisationURI in interface AuthorisationURIGenerator
Returns:
the URL that can be used to configure authentication for the requested resource, or null if this request factory doesn't support authorisation via user intervention. If AuthorisationURIGenerator.getAuthorisationURI(URI) returns a non-null value, this method MUST also return a non-null value.
See Also:
AuthorisationURIGenerator.getAuthorisationURI(URI)

getAuthorisationURI

public java.net.URI getAuthorisationURI(java.net.URI callback)
Description copied from interface: AuthorisationURIGenerator

The URI that can be used to configure authentication for the requested resource.

The typical scenario is a call to an OAuth-protected remote resource for which the caller does not have an access token. If the caller has the ability to send a redirect (in case of a plugin servlet or webwork action), it would do so using this URL. This URL will take the user to a local endpoint that will perform the "OAuth dance":

  • request a Request Token from the remote OAuth provider
  • redirect the client to the provider's authorize URL, using itself for the callback
  • on successful approval by the user, swap the request token for an access token
  • redirect the user back to original resource (the plugin's servlet or action)
  • If the caller does not have the ability to perform an HTTP redirect to this URL (possibly because it's a Web Panel), it can display a link or button that will open the URL in a popup dialog with an iframe, allowing the user to perform the oauth dance at a later time.

    Specified by:
    getAuthorisationURI in interface AuthorisationURIGenerator
    Parameters:
    callback - the URI to redirect to after authentication is complete
    Returns:
    the URL that can be used to provide authentication for the requested resource, or null if this request factory doesn't support authorisation via user intervention. Note, if this method returns a non-null value, AuthorisationURIGenerator.getAuthorisationURI() MUST also return a non-null value.


    Copyright © 2011 Atlassian. All Rights Reserved.