|
18 | 18 | */ |
19 | 19 | package org.neo4j.driver.v1; |
20 | 20 |
|
| 21 | +import java.util.Map; |
| 22 | + |
21 | 23 | import org.neo4j.driver.internal.security.InternalAuthToken; |
22 | 24 |
|
23 | 25 | import static org.neo4j.driver.v1.Values.parameters; |
@@ -46,6 +48,62 @@ public static AuthToken basic( String username, String password ) |
46 | 48 | "credentials", password ).asMap( Values.ofValue() ) ); |
47 | 49 | } |
48 | 50 |
|
| 51 | + /** |
| 52 | + * The basic authentication scheme, using a username and a password. |
| 53 | + * @param username this is the "principal", identifying who this token represents |
| 54 | + * @param password this is the "credential", proving the identity of the user |
| 55 | + * @param realm this is the "realm", specifies the authentication provider |
| 56 | + * @return an authentication token that can be used to connect to Neo4j |
| 57 | + * @see GraphDatabase#driver(String, AuthToken) |
| 58 | + */ |
| 59 | + public static AuthToken basic( String username, String password, String realm ) |
| 60 | + { |
| 61 | + return new InternalAuthToken( parameters( |
| 62 | + "scheme", "basic", |
| 63 | + "principal", username, |
| 64 | + "credentials", password, |
| 65 | + "realm", realm).asMap( Values.ofValue() ) ); |
| 66 | + } |
| 67 | + |
| 68 | + |
| 69 | + /** |
| 70 | + * A custom authentication token used for doing custom authentication on the server side. |
| 71 | + * @param principal this used to identify who this token represents |
| 72 | + * @param credentials this is credentials authenticating the principal |
| 73 | + * @param realm this is the "realm:, specifying the authentication provider. |
| 74 | + * @param scheme this it the authentication scheme, specifying what kind of authentication that should be used |
| 75 | + * @return an authentication token that can be used to connect to Neo4j |
| 76 | + * * @see GraphDatabase#driver(String, AuthToken) |
| 77 | + */ |
| 78 | + public static AuthToken custom( String principal, String credentials, String realm, String scheme) |
| 79 | + { |
| 80 | + return new InternalAuthToken( parameters( |
| 81 | + "scheme", scheme, |
| 82 | + "principal", principal, |
| 83 | + "credentials", credentials, |
| 84 | + "realm", realm).asMap( Values.ofValue() ) ); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * A custom authentication token used for doing custom authentication on the server side. |
| 89 | + * @param principal this used to identify who this token represents |
| 90 | + * @param credentials this is credentials authenticating the principal |
| 91 | + * @param realm this is the "realm:, specifying the authentication provider. |
| 92 | + * @param scheme this it the authentication scheme, specifying what kind of authentication that shoud be used |
| 93 | + * @param parameters extra parameters to be sent along the authentication provider. |
| 94 | + * @return an authentication token that can be used to connect to Neo4j |
| 95 | + * * @see GraphDatabase#driver(String, AuthToken) |
| 96 | + */ |
| 97 | + public static AuthToken custom( String principal, String credentials, String realm, String scheme, Map<String, Object> parameters) |
| 98 | + { |
| 99 | + return new InternalAuthToken( parameters( |
| 100 | + "scheme", scheme, |
| 101 | + "principal", principal, |
| 102 | + "credentials", credentials, |
| 103 | + "realm", realm, |
| 104 | + "parameters", parameters).asMap( Values.ofValue() ) ); |
| 105 | + } |
| 106 | + |
49 | 107 | /** |
50 | 108 | * No authentication scheme. This will only work if authentication is disabled |
51 | 109 | * on the Neo4j Instance we are connecting to. |
|
0 commit comments