Class KeycloakTestClient

    • Constructor Detail

      • KeycloakTestClient

        public KeycloakTestClient()
    • Method Detail

      • getClientAccessToken

        public String getClientAccessToken()
        Get an access token from the default tenant realm using a client_credentials grant. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property. Client id is set to `quarkus-app` unless it has been configured with the `quarkus.oidc.client-id` property. Client secret is set to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getClientAccessToken

        public String getClientAccessToken​(String clientId)
        Get an access token from the default tenant realm using a client_credentials grant with a the provided client id. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getClientAccessToken

        public String getClientAccessToken​(String clientId,
                                           String clientSecret)
        Get an access token from the default tenant realm using a client_credentials grant with a the provided client id and secret. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property.
      • getClientAccessToken

        public String getClientAccessToken​(String clientId,
                                           String clientSecret,
                                           List<String> scopes)
        Get an access token from the default tenant realm using a client_credentials grant with a the provided client id and secret, and scopes. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property.
      • getRealmClientAccessToken

        public String getRealmClientAccessToken​(String realm)
        Get an access token from the provided realm using a client_credentials grant. Client id is set to `quarkus-app` unless it has been configured with the `quarkus.oidc.client-id` property. Client secret is set to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getRealmClientAccessToken

        public String getRealmClientAccessToken​(String realm,
                                                String clientId)
        Get an access token from the provided realm using a client_credentials grant with a the provided client id. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getRealmClientAccessToken

        public String getRealmClientAccessToken​(String realm,
                                                String clientId,
                                                String clientSecret)
        Get an access token from the provided realm using a client_credentials grant with a the provided client id and secret.
      • getRealmClientAccessToken

        public String getRealmClientAccessToken​(String realm,
                                                String clientId,
                                                String clientSecret,
                                                List<String> scopes)
        Get an access token from the provided realm using a client_credentials grant with a the provided client id and secret, and scopes.
      • getAccessToken

        public String getAccessToken​(String userName)
        Get an access token from the default tenant realm using a password grant with a provided user name. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property. User secret will be the same as the user name. Client id will be set to `quarkus-app` unless it has been configured with the `quarkus.oidc.client-id` property. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getAccessToken

        public String getAccessToken​(String userName,
                                     String clientId)
        Get an access token from the default tenant realm using a password grant with the provided user name and client id. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property. User secret will be the same as the user name. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getAccessToken

        public String getAccessToken​(String userName,
                                     String userSecret,
                                     String clientId)
        Get an access token from the default tenant realm using a password grant with the provided user name, user secret and client id. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property. Client secret will be set to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` propertys.
      • getAccessToken

        public String getAccessToken​(String userName,
                                     String userSecret,
                                     String clientId,
                                     String clientSecret)
        Get an access token from the default tenant realm using a password grant with the provided user name, user secret, client id and secret. Realm name is set to `quarkus` unless it has been configured with the `quarkus.keycloak.devservices.realm-name` property.
      • getAccessToken

        public String getAccessToken​(String userName,
                                     String userSecret,
                                     String clientId,
                                     String clientSecret,
                                     List<String> scopes)
        Get an access token from the default tenant realm using a password grant with the provided user name, user secret, client id and secret, and scopes.
      • getRealmAccessToken

        public String getRealmAccessToken​(String realm,
                                          String userName)
        Get a realm access token using a password grant with a provided user name. User secret will be the same as the user name. Client id will be set to `quarkus-app` unless it has been configured with the `quarkus.oidc.client-id` property. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getRealmAccessToken

        public String getRealmAccessToken​(String realm,
                                          String userName,
                                          String clientId)
        Get a realm access token using a password grant with the provided user name and client id. User secret will be the same as the user name. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getRealmAccessToken

        public String getRealmAccessToken​(String realm,
                                          String userName,
                                          String userSecret,
                                          String clientId)
        Get a realm access token using a password grant with the provided user name, user secret and client id. Client secret will be to `secret` unless it has been configured with the `quarkus.oidc.credentials.secret` property.
      • getRealmAccessToken

        public String getRealmAccessToken​(String realm,
                                          String userName,
                                          String userSecret,
                                          String clientId,
                                          String clientSecret)
        Get a realm access token using a password grant with the provided user name, user secret, client id and secret. Set the client secret to an empty string or null if it is not required.
      • getRealmAccessToken

        public String getRealmAccessToken​(String realm,
                                          String userName,
                                          String userSecret,
                                          String clientId,
                                          String clientSecret,
                                          List<String> scopes)
        Get a realm access token using a password grant with the provided user name, user secret, client id and secret, and scopes. Set the client secret to an empty string or null if it is not required.
      • getAdminAccessToken

        public String getAdminAccessToken()
        Get an admin access token which can be used to create Keycloak realms and perform other Keycloak administration tasks.
      • getAuthServerBaseUrl

        public String getAuthServerBaseUrl()
        Return URL string pointing to a Keycloak base endpoint. For example: 'http://localhost:8081/auth'.
      • getAuthServerUrl

        public String getAuthServerUrl()
        Return URL string pointing to a Keycloak authentication endpoint configured with a 'quarkus.oidc.auth-server' property. For example: 'http://localhost:8081/auth/realms/quarkus'.
      • createRealm

        public void createRealm​(org.keycloak.representations.idm.RealmRepresentation realm)
        Create a realm.
      • deleteRealm

        public void deleteRealm​(String realm)
        Delete a realm
      • deleteRealm

        public void deleteRealm​(org.keycloak.representations.idm.RealmRepresentation realm)
        Delete a realm