Skip to content

Commit 985b479

Browse files
committed
- adds missing javadoc comments
- remove unecessary manual mocks - removes duplicated constructs following move from service library
1 parent 96a8881 commit 985b479

11 files changed

Lines changed: 72 additions & 449 deletions

File tree

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package com.microsoft.graph.authentication;
22

3-
public class AuthConstants {
3+
import com.google.common.annotations.VisibleForTesting;
44

5-
public static class Tenants
6-
{
7-
public static final String Common = "common";
8-
public static final String Organizations = "organizations";
9-
public static final String Consumers = "consumers";
10-
}
11-
public static final String BEARER = "Bearer ";
12-
public static final String TOKEN_ENDPOINT = "/oauth2/v2.0/token";
13-
public static final String AUTHORIZATION_HEADER = "Authorization";
14-
}
5+
/**
6+
* Internal only.
7+
* Constants in use for the authentication provider
8+
*/
9+
@VisibleForTesting
10+
class AuthConstants {
11+
/** The bearer value for the authorization request header, contains a space */
12+
@VisibleForTesting
13+
protected static final String BEARER = "Bearer ";
14+
/** The authorization request header name */
15+
@VisibleForTesting
16+
protected static final String AUTHORIZATION_HEADER = "Authorization";
17+
}

‎src/main/java/com/microsoft/graph/authentication/IAuthenticationProvider.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import javax.annotation.Nonnull;
44

55
import com.microsoft.graph.exceptions.AuthenticationException;
6-
import com.microsoft.graph.httpcore.IHttpRequest;
6+
import com.microsoft.graph.http.IHttpRequest;
77

88

99
/**

‎src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
import com.azure.core.credential.TokenCredential;
55
import com.azure.core.credential.TokenRequestContext;
66
import com.microsoft.graph.exceptions.AuthenticationException;
7-
import com.microsoft.graph.exceptions.Error;
8-
import com.microsoft.graph.exceptions.ErrorConstants;
9-
import com.microsoft.graph.httpcore.IHttpRequest;
7+
import com.microsoft.graph.http.IHttpRequest;
108
import okhttp3.Request;
11-
import com.microsoft.graph.exceptions.ErrorConstants.*;
129

1310
import java.net.MalformedURLException;
1411
import java.net.URL;
@@ -20,6 +17,9 @@
2017

2118
import javax.annotation.Nonnull;
2219

20+
/**
21+
* An implementation of the Authentication Provider with Azure-identity
22+
*/
2323
public class TokenCredentialAuthProvider implements IAuthenticationProvider<Request> {
2424

2525
//TokenCredential expected from user
@@ -40,9 +40,7 @@ public class TokenCredentialAuthProvider implements IAuthenticationProvider<Requ
4040
*/
4141
public TokenCredentialAuthProvider(@Nonnull final TokenCredential tokenCredential) throws AuthenticationException {
4242
if(tokenCredential == null) {
43-
throw new AuthenticationException(new Error(Codes.InvalidArgument,
44-
String.format(Messages.NullParameter, "TokenCredential"))
45-
,new IllegalArgumentException());
43+
throw new AuthenticationException(new IllegalArgumentException("tokenCredential parameter cannot be null."));
4644
}
4745

4846
this.tokenCredential = tokenCredential;
@@ -127,7 +125,7 @@ private String getAccessToken() throws AuthenticationException {
127125
final AccessToken token = this.tokenCredential.getToken(this.context).block(this.tokenBlockTimeout);
128126
return token.getToken();
129127
} catch (RuntimeException e) {
130-
throw new AuthenticationException(new Error(ErrorConstants.Codes.GeneralException, ErrorConstants.Messages.AuthTimeOut), e);
128+
throw new AuthenticationException("Authentication failed or timed out.", e);
131129
}
132130
}
133131
}

‎src/main/java/com/microsoft/graph/exceptions/AuthenticationException.java‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,32 @@
22

33
import javax.annotation.Nonnull;
44

5-
public class AuthenticationException extends Exception{
5+
import com.microsoft.graph.core.ClientException;
6+
7+
/**
8+
* Exceptions thrown by the authentication provider when the authentication sequence has failed
9+
*/
10+
public class AuthenticationException extends ClientException {
611

712
/**
813
* serial id
914
*/
1015
private static final long serialVersionUID = 8708883112518988965L;
11-
// Error object to store details of thrown Exception
12-
@Nonnull
13-
public Error error;
14-
1516
/**
16-
*Creates a new AuthenticationException with a specified Error
17+
* Creates a new AuthenticationException with a specified Error as well as an inner exception
1718
*
18-
* @param error The specifying error causing exception to be thrown
19+
* @param message The specified error message causing exception to be thrown
20+
* @param rootCause The underlying exception causing AuthenticationException to be thrown
1921
*/
20-
public AuthenticationException(@Nonnull final Error error) {
21-
super(error.getMessage());
22-
this.error = error;
22+
public AuthenticationException(@Nonnull final String message, @Nonnull final Throwable rootCause) {
23+
super(message, rootCause);
2324
}
24-
2525
/**
26-
*Creates a new AuthenticationException with a specified Error as well as an inner exception
26+
* Creates a new AuthenticationException with a specified Error as well as an inner exception
2727
*
28-
* @param error The specified error causing exception to be thrown
2928
* @param rootCause The underlying exception causing AuthenticationException to be thrown
3029
*/
31-
public AuthenticationException(@Nonnull final Error error, @Nonnull final Throwable rootCause) {
32-
super(error.getMessage(), rootCause);
33-
this.error = error;
30+
public AuthenticationException(@Nonnull final Throwable rootCause) {
31+
super(rootCause.getMessage(), rootCause);
3432
}
3533
}

‎src/main/java/com/microsoft/graph/exceptions/Error.java‎

Lines changed: 0 additions & 89 deletions
This file was deleted.

‎src/main/java/com/microsoft/graph/exceptions/ErrorConstants.java‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎src/main/java/com/microsoft/graph/httpcore/HttpMethod.java‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)