public class OIDCAuthorization
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
OIDCAuthorization.URLProcessor
The Class URLProcessor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accessResource()
Access some resource previously set by
setResourceURI(String) . |
boolean |
accessResource(java.lang.String url,
java.lang.String presetUsername,
java.awt.Window owner)
Access some resource like
accessResource() , but also provide the URL and presetUsername/owner for the dialog. |
boolean |
accessResource(java.lang.String presetUsername,
java.awt.Window owner)
Access some resource like
accessResource() , but also provide the presetUsername/owner for the dialog. |
boolean |
authorizeByUserAndPW(java.lang.String username,
java.lang.String password)
Connect to the authorization server and get a valid token.
|
java.lang.String |
getClientID()
Gets the client id.
|
java.lang.String |
getClientSecret()
Gets the client secret.
|
javax.swing.JDialog |
getDialog()
Gets the authorization dialog (with null defaults).
|
javax.swing.JDialog |
getDialog(java.lang.String presetUsername,
java.awt.Window owner)
Gets the authorization dialog.
|
static OIDCAuthorization |
getInstance()
Gets the single instance of OIDCAuthorization.
|
java.lang.String |
getIssuerURI()
Gets the issuer URI.
|
java.lang.String |
getLastSuccessfulUser()
Returns the last successful user name.
|
SimpleOIDCClient |
getOIDCClient()
Gets the OIDC client.
|
java.lang.String |
getResourceURI()
Gets the resource URI.
|
OIDCAuthorization.URLProcessor |
getUrlProcessor()
Gets the url processor.
|
java.lang.String |
getUserID()
Gets the unique ID of the user authenticated.
|
void |
init()
Initiates the authorization process by setting the necessary URIs and data to the OIDC client and preparing the URLProcessor.
|
boolean |
isValid()
Checks if OIDC token is valid, so access has been granted.
|
OIDCAuthorization |
setAvailabilityHandler(OIDCResourceAvailabilityHandler availabilityHandler)
Sets the availability handler.
|
void |
setIssuerURI(java.lang.String issuerURI)
Sets the issuer URI.
|
void |
setResourceURI(java.lang.String resourceURI)
Sets the resource URI.
|
void |
setTranslator(Translator translator)
Sets the translator.
|
void |
setTrustStore(java.io.File trustStoreFile)
Sets the trust store.
|
public static OIDCAuthorization getInstance()
public SimpleOIDCClient getOIDCClient() throws java.net.URISyntaxException
java.net.URISyntaxException
- the URI syntax exceptionpublic OIDCAuthorization.URLProcessor getUrlProcessor() throws java.net.URISyntaxException, java.io.IOException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException
java.net.URISyntaxException
- the URI syntax exceptionjava.io.IOException
- Signals that an I/O exception has occurred.java.security.KeyManagementException
- the key management exceptionjava.security.NoSuchAlgorithmException
- the no such algorithm exceptionjava.security.cert.CertificateException
- the certificate exceptionjava.security.KeyStoreException
- the key store exceptionpublic void setTrustStore(java.io.File trustStoreFile) throws java.net.URISyntaxException
trustStoreFile
- the new trust storejava.net.URISyntaxException
- the URI syntax exceptionpublic OIDCAuthorization setAvailabilityHandler(OIDCResourceAvailabilityHandler availabilityHandler)
availabilityHandler
- the availability handlerpublic java.lang.String getIssuerURI()
public void setIssuerURI(java.lang.String issuerURI)
issuerURI
- the new issuer URIpublic java.lang.String getResourceURI()
public void setResourceURI(java.lang.String resourceURI)
resourceURI
- the new resource URIpublic java.lang.String getClientID()
public java.lang.String getClientSecret()
public javax.swing.JDialog getDialog()
public javax.swing.JDialog getDialog(java.lang.String presetUsername, java.awt.Window owner)
presetUsername
- username which should be shown preset when displaying the dialogowner
- the window to which the dialog should belong (to center etc.)public boolean isValid() throws java.net.URISyntaxException
java.net.URISyntaxException
- the URI syntax exceptionpublic java.lang.String getUserID() throws de.enflexit.oidc.OIDCAuthorization.OIDCProblemException, java.net.URISyntaxException
OIDCProblemException
- if the token is not valid/the user is not authenticated yetjava.net.URISyntaxException
- the URI syntax exceptionde.enflexit.oidc.OIDCAuthorization.OIDCProblemException
public void init() throws java.net.URISyntaxException, java.io.IOException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException
java.net.URISyntaxException
- the URI syntax exceptionjava.io.IOException
- Signals that an I/O exception has occurred.java.security.KeyManagementException
- the key management exceptionjava.security.NoSuchAlgorithmException
- the no such algorithm exceptionjava.security.cert.CertificateException
- the certificate exceptionjava.security.KeyStoreException
- the key store exceptionpublic boolean authorizeByUserAndPW(java.lang.String username, java.lang.String password) throws java.net.URISyntaxException, java.io.IOException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException
username
- the usernamepassword
- the passwordjava.net.URISyntaxException
- the URI syntax exceptionjava.io.IOException
- Signals that an I/O exception has occurred.java.security.KeyManagementException
- the key management exceptionjava.security.NoSuchAlgorithmException
- the no such algorithm exceptionjava.security.cert.CertificateException
- the certificate exceptionjava.security.KeyStoreException
- the key store exceptionpublic boolean accessResource() throws java.io.IOException, java.net.URISyntaxException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException
setResourceURI(String)
. If not accessible, show user/password dialogjava.io.IOException
- Signals that an I/O exception has occurred.java.net.URISyntaxException
- the URI syntax exceptionjava.security.KeyManagementException
- the key management exceptionjava.security.NoSuchAlgorithmException
- the no such algorithm exceptionjava.security.cert.CertificateException
- the certificate exceptionjava.security.KeyStoreException
- the key store exceptionpublic boolean accessResource(java.lang.String presetUsername, java.awt.Window owner) throws java.io.IOException, java.net.URISyntaxException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException
accessResource()
, but also provide the presetUsername/owner for the dialog.presetUsername
- the preset usernameowner
- the owner framejava.io.IOException
- Signals that an I/O exception has occurred.java.net.URISyntaxException
- the URI syntax exceptionjava.security.KeyManagementException
- the key management exceptionjava.security.NoSuchAlgorithmException
- the no such algorithm exceptionjava.security.cert.CertificateException
- the certificate exceptionjava.security.KeyStoreException
- the key store exceptionpublic boolean accessResource(java.lang.String url, java.lang.String presetUsername, java.awt.Window owner) throws java.io.IOException, java.net.URISyntaxException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException
accessResource()
, but also provide the URL and presetUsername/owner for the dialog.url
- the urlpresetUsername
- the preset usernameowner
- the owner framejava.io.IOException
- Signals that an I/O exception has occurred.java.net.URISyntaxException
- the URI syntax exceptionjava.security.KeyManagementException
- the key management exceptionjava.security.NoSuchAlgorithmException
- the no such algorithm exceptionjava.security.cert.CertificateException
- the certificate exceptionjava.security.KeyStoreException
- the key store exceptionpublic void setTranslator(Translator translator)
translator
- the new translatorpublic java.lang.String getLastSuccessfulUser()