Skip to content

Commit 1830c35

Browse files
author
Christian Pedersen
committed
comments added to sample code
1 parent 460bb6f commit 1830c35

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

com/onelogin/AccountSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void setCertificate(String certificate) {
1313
public String getIdp_sso_target_url() {
1414
return idp_sso_target_url;
1515
}
16-
public void setIdp_sso_target_url(String idp_sso_target_url) {
16+
public void setIdpSsoTargetUrl(String idp_sso_target_url) {
1717
this.idp_sso_target_url = idp_sso_target_url;
1818
}
1919
}

sample/consume.jsp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
"qdt/19BZrpm7zZI6BWzQKimTLS0gYpgkqbreoKK+AdbbwtyXAgMBAAEwAwYBAAMB"+
2020
"AA==";
2121
22+
// user account specific settings. Import the certificate here
2223
AccountSettings accountSettings = new AccountSettings();
2324
accountSettings.setCertificate(certificateS);
2425
2526
Response samlResponse = new Response(accountSettings);
2627
samlResponse.loadXmlFromBase64(request.getParameter("SAMLResponse"));
2728
28-
if(samlResponse.isValid()){
29+
if (samlResponse.isValid()) {
2930
31+
// the signature of the SAML Response is valid. The source is trusted
3032
java.io.PrintWriter writer = response.getWriter();
3133
writer.write("OK!");
3234
String nameId = samlResponse.getNameId();
@@ -35,6 +37,7 @@
3537
3638
} else {
3739
40+
// the signature of the SAML Response is not valid
3841
java.io.PrintWriter writer = response.getWriter();
3942
writer.write("Failed");
4043
writer.flush();

sample/index.jsp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,29 @@
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
88
<title>Auth Request</title>
99
<%
10+
11+
// the appSettings object contain application specific settings used by the SAML library
1012
AppSettings appSettings = new AppSettings();
13+
14+
// set the URL of the consume.jsp (or similar) file for this app. The SAML Response will be posted to this URL
1115
appSettings.setAssertionConsumerServiceUrl("http://68.169.49.120:8080/testOneLogin/consume.jsp");
12-
appSettings.setIssuer("user@onelogin.com");
16+
17+
// set the issuer of the authentication request. This would usually be the URL of the issuing web application
18+
appSettings.setIssuer("https://www.mywebapp.com");
19+
20+
// the accSettings object contains settings specific to the users account.
21+
// At this point, your application must have identified the users origin
1322
AccountSettings accSettings = new AccountSettings();
14-
accSettings.setIdp_sso_target_url("https://app.onelogin.com/saml/signon/20956");
23+
24+
// The URL at the Identity Provider where to the authentication request should be sent
25+
accSettings.setIdpSsoTargetUrl("https://app.onelogin.com/saml/signon/20956");
26+
27+
// Generate an AuthRequest and send it to the identity provider
1528
AuthRequest authReq = new AuthRequest(appSettings, accSettings);
1629
String reqString = accSettings.getIdp_sso_target_url()+"?SAMLRequest=" + AuthRequest.getRidOfCRLF(URLEncoder.encode(authReq.getRequest(AuthRequest.base64),"UTF-8"));
1730
response.sendRedirect(reqString);
1831
%>
1932
</head>
2033
<body>
21-
2234
</body>
2335
</html>

0 commit comments

Comments
 (0)