Skip to content

Commit 778e07a

Browse files
Merge pull request #100779 from archieag/patch-30
Update java webapp quickstart steps for ready-to-go downloaded sample
2 parents 9d21c1b + ffc62d0 commit 778e07a

File tree

1 file changed

+62
-41
lines changed

1 file changed

+62
-41
lines changed

articles/active-directory/develop/quickstart-v2-java-webapp.md

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ ms.custom: aaddev, scenarios:getting-started, languages:Java
1818

1919
In this quickstart, you'll learn how to integrate a Java web application with the Microsoft identity platform. Your app will sign in a user, get an access token to call the Microsoft Graph API, and make a request to the Microsoft Graph API.
2020

21-
When you've completed this quickstart, your application will accept sign-ins of personal Microsoft accounts (including outlook.com, live.com, and others) and work or school accounts from any company or organization that uses Azure Active Directory.
22-
23-
![Shows how the sample app generated by this quickstart works](media/quickstart-v2-java-webapp/java-quickstart.svg)
21+
When you've completed this quickstart, your application will accept sign-ins of personal Microsoft accounts (including outlook.com, live.com, and others) and work or school accounts from any company or organization that uses Azure Active Directory. (See [How the sample works](#how-the-sample-works) for an illustration.)
2422

2523
## Prerequisites
2624

2725
To run this sample you will need:
2826

2927
- [Java Development Kit (JDK)](https://openjdk.java.net/) 8 or greater, and [Maven](https://maven.apache.org/).
30-
- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant](https://azure.microsoft.com/documentation/articles/active-directory-howto-tenant/).
3128

3229
> [!div renderon="docs"]
3330
> ## Register and download your quickstart app
@@ -69,7 +66,7 @@ To run this sample you will need:
6966
>
7067
> For the code sample for this quickstart to work, you need to:
7168
>
72-
> 1. Add reply URLs as `https://localhost:8080/msal4jsamples/secure/aad` and `https://localhost:8080/msal4jsamples/graph/me`.
69+
> 1. Add reply URLs as `https://localhost:8080/msal4jsample/secure/aad` and `https://localhost:8080/msal4jsample/graph/me`.
7370
> 1. Create a Client Secret.
7471
> > [!div renderon="portal" id="makechanges" class="nextstepaction"]
7572
> > [Make these changes for me]()
@@ -78,46 +75,65 @@ To run this sample you will need:
7875
> > ![Already configured](media/quickstart-v2-aspnet-webapp/green-check.png) Your application is configured with these attributes.
7976
8077
#### Step 2: Download the code sample
78+
> [!div renderon="docs"]
79+
> [Download the Code Sample](https://github.com/Azure-Samples/ms-identity-java-webapp/archive/master.zip)
8180
82-
[Download the Code Sample](https://github.com/Azure-Samples/ms-identity-java-webapp/archive/master.zip)
83-
84-
#### Step 3: Configure the code sample
85-
86-
1. Extract the zip file to a local folder.
87-
1. If you use an integrated development environment, open the sample in your favorite IDE (optional).
88-
1. Open the application.properties file, which can be found in src/main/resources/ folder and replace the value of the fields *aad.clientId*, *aad.authority* and *aad.secretKey* with the respective values of **Application Id**, **Tenant Id** and **Client Secret** as the following:
89-
90-
```file
91-
aad.clientId=Enter_the_Application_Id_here
92-
aad.authority=https://login.microsoftonline.com/Enter_the_Tenant_Info_Here/
93-
aad.secretKey=Enter_the_Client_Secret_Here
94-
aad.redirectUriSignin=https://localhost:8080/msal4jsample/secure/aad
95-
aad.redirectUriGraph=https://localhost:8080/msal4jsample/graph/me
96-
aad.msGraphEndpointHost="https://graph.microsoft.com/"
97-
```
98-
99-
> [!div renderon="docs"]
100-
> Where:
101-
>
102-
> - `Enter_the_Application_Id_here` - is the Application Id for the application you registered.
103-
> - `Enter_the_Client_Secret_Here` - is the **Client Secret** you created in **Certificates & Secrets** for the application you registered.
104-
> - `Enter_the_Tenant_Info_Here` - is the **Directory (tenant) ID** value of the application you registered.
105-
106-
1. To use https with localhost, fill in the server.ssl.key properties. To generate a self-signed certificate, use the keytool utility (included in JRE).
107-
108-
```
109-
Example:
110-
keytool -genkeypair -alias testCert -keyalg RSA -storetype PKCS12 -keystore keystore.p12 -storepass password
81+
> [!div class="sxs-lookup" renderon="portal"]
82+
> Download the project and extract the zip file to a local folder closer to the root folder - for example, **C:\Azure-Samples**
83+
>
84+
> To use https with localhost, fill in the server.ssl.key properties. To generate a self-signed certificate, use the keytool utility (included in JRE).
85+
>
86+
> ```
87+
> Example:
88+
> keytool -genkeypair -alias testCert -keyalg RSA -storetype PKCS12 -keystore keystore.p12 -storepass password
89+
>
90+
> server.ssl.key-store-type=PKCS12
91+
> server.ssl.key-store=classpath:keystore.p12
92+
> server.ssl.key-store-password=password
93+
> server.ssl.key-alias=testCert
94+
> ```
95+
> Put the generated keystore file in the "resources" folder.
96+
97+
> [!div renderon="portal" id="autoupdate" class="nextstepaction"]
98+
> [Download the code sample]()
11199
112-
server.ssl.key-store-type=PKCS12
113-
server.ssl.key-store=classpath:keystore.p12
114-
server.ssl.key-store-password=password
115-
server.ssl.key-alias=testCert
116-
```
100+
> [!div renderon="docs"]
101+
> #### Step 3: Configure the code sample
102+
> 1. Extract the zip file to a local folder.
103+
> 1. If you use an integrated development environment, open the sample in your favorite IDE (optional).
104+
> 1. Open the application.properties file, which can be found in src/main/resources/ folder and replace the value of the fields *aad.clientId*, *aad.authority* and *aad.secretKey* with the respective values of **Application Id**, **Tenant Id** and **Client Secret** as the following:
105+
>
106+
> ```file
107+
> aad.clientId=Enter_the_Application_Id_here
108+
> aad.authority=https://login.microsoftonline.com/Enter_the_Tenant_Info_Here/
109+
> aad.secretKey=Enter_the_Client_Secret_Here
110+
> aad.redirectUriSignin=https://localhost:8080/msal4jsample/secure/aad
111+
> aad.redirectUriGraph=https://localhost:8080/msal4jsample/graph/me
112+
> aad.msGraphEndpointHost="https://graph.microsoft.com/"
113+
> ```
114+
> Where:
115+
>
116+
> - `Enter_the_Application_Id_here` - is the Application Id for the application you registered.
117+
> - `Enter_the_Client_Secret_Here` - is the **Client Secret** you created in **Certificates & Secrets** for the application you registered.
118+
> - `Enter_the_Tenant_Info_Here` - is the **Directory (tenant) ID** value of the application you registered.
119+
> 1. To use https with localhost, fill in the server.ssl.key properties. To generate a self-signed certificate, use the keytool utility (included in JRE).
120+
>
121+
> ```
122+
> Example:
123+
> keytool -genkeypair -alias testCert -keyalg RSA -storetype PKCS12 -keystore keystore.p12 -storepass password
124+
>
125+
> server.ssl.key-store-type=PKCS12
126+
> server.ssl.key-store=classpath:keystore.p12
127+
> server.ssl.key-store-password=password
128+
> server.ssl.key-alias=testCert
129+
> ```
130+
> Put the generated keystore file in the "resources" folder.
117131
118-
Put the generated keystore file in the "resources" folder.
119132
120-
#### Step 4: Run the code sample
133+
> [!div class="sxs-lookup" renderon="portal"]
134+
> #### Step 3: Run the code sample
135+
> [!div renderon="docs"]
136+
> #### Step 4: Run the code sample
121137
122138
To run the project, you can either:
123139
@@ -133,11 +149,16 @@ If you are running the web application from an IDE, click on run, then navigate
133149
- *Sign Out*: Signs the current user out of the application and redirects them to the home page.
134150
- *Show User Info*: Acquires a token for Microsoft Graph and calls Microsoft Graph with a request containing the token, which returns basic information about the signed-in user.
135151
152+
153+
136154
> [!IMPORTANT]
137155
> This quickstart application uses a client secret to identify itself as confidential client. Because the client secret is added as a plain-text to your project files, for security reasons it is recommended that you use a certificate instead of a client secret before considering the application as production application. For more information on how to use a certificate, see [Certificate credentials for application authentication](https://docs.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials).
138156
139157
## More information
140158
159+
### How the sample works
160+
![Shows how the sample app generated by this quickstart works](media/quickstart-v2-java-webapp/java-quickstart.svg)
161+
141162
### Getting MSAL
142163
143164
MSAL for Java (MSAL4J) is the Java library used to sign in users and request tokens used to access an API protected by the Microsoft identity Platform.

0 commit comments

Comments
 (0)