Skip to content

Commit fea12c5

Browse files
committed
Remove useless XMLEntityException declaration in logout throws clause
This exception is indeed never thrown and it's a checked one, so it makes using Auth.logout heavier then necessary. java-saml already has an abundance of checked exceptions to handle, some of which could easily be translated into unchecked ones or caught and recovered cleanly, this is why I think that, if a useless exception declaration is found, it should better be removed. This indeed is a small source-incompatible change as soon as the consumer code is catching XMLEntityException explicitly (rather than SAMLException, Exception or Throwable). However, fixing this is trivial, just remove XMLEntityException from the catch clause (which will never be triggered anyway).
1 parent 523786b commit fea12c5

File tree

2 files changed

+18
-42
lines changed

2 files changed

+18
-42
lines changed

core/src/main/java/com/onelogin/saml2/logout/LogoutRequest.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,8 @@ public class LogoutRequest {
117117
* The NameID NameQualifier that will be set in the LogoutRequest.
118118
* @param nameIdSPNameQualifier
119119
* The SP Name Qualifier that will be set in the LogoutRequest.
120-
*
121-
* @throws XMLEntityException
122120
*/
123-
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex, String nameIdFormat, String nameIdNameQualifier, String nameIdSPNameQualifier) throws XMLEntityException {
121+
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex, String nameIdFormat, String nameIdNameQualifier, String nameIdSPNameQualifier) {
124122
this.settings = settings;
125123
this.request = request;
126124

@@ -163,10 +161,8 @@ public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId,
163161
* The nameIdFormat that will be set in the LogoutRequest.
164162
* @param nameIdNameQualifier
165163
* The NameID NameQualifier will be set in the LogoutRequest.
166-
*
167-
* @throws XMLEntityException
168164
*/
169-
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex, String nameIdFormat, String nameIdNameQualifier) throws XMLEntityException {
165+
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex, String nameIdFormat, String nameIdNameQualifier) {
170166
this(settings, request, nameId, sessionIndex, nameIdFormat, nameIdNameQualifier, null);
171167
}
172168

@@ -183,10 +179,8 @@ public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId,
183179
* The SessionIndex (taken from the SAML Response in the SSO process).
184180
* @param nameIdFormat
185181
* The nameIdFormat that will be set in the LogoutRequest.
186-
*
187-
* @throws XMLEntityException
188182
*/
189-
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex, String nameIdFormat) throws XMLEntityException {
183+
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex, String nameIdFormat) {
190184
this(settings, request, nameId, sessionIndex, nameIdFormat, null);
191185
}
192186

@@ -201,10 +195,8 @@ public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId,
201195
* The NameID that will be set in the LogoutRequest.
202196
* @param sessionIndex
203197
* The SessionIndex (taken from the SAML Response in the SSO process).
204-
*
205-
* @throws XMLEntityException
206198
*/
207-
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex) throws XMLEntityException {
199+
public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId, String sessionIndex) {
208200
this(settings, request, nameId, sessionIndex, null);
209201
}
210202

@@ -213,10 +205,8 @@ public LogoutRequest(Saml2Settings settings, HttpRequest request, String nameId,
213205
*
214206
* @param settings
215207
* OneLogin_Saml2_Settings
216-
*
217-
* @throws XMLEntityException
218208
*/
219-
public LogoutRequest(Saml2Settings settings) throws XMLEntityException {
209+
public LogoutRequest(Saml2Settings settings) {
220210
this(settings, null, null, null);
221211
}
222212

@@ -226,11 +216,9 @@ public LogoutRequest(Saml2Settings settings) throws XMLEntityException {
226216
* @param settings
227217
* OneLogin_Saml2_Settings
228218
* @param request
229-
* the HttpRequest object to be processed (Contains GET and POST parameters, request URL, ...).
230-
*
231-
* @throws XMLEntityException
219+
* the HttpRequest object to be processed (Contains GET and POST parameters, request URL, ...).
232220
*/
233-
public LogoutRequest(Saml2Settings settings, HttpRequest request) throws XMLEntityException {
221+
public LogoutRequest(Saml2Settings settings, HttpRequest request) {
234222
this(settings, request, null, null);
235223
}
236224

toolkit/src/main/java/com/onelogin/saml2/Auth.java

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.onelogin.saml2.authn.SamlResponse;
2626
import com.onelogin.saml2.exception.SettingsException;
2727
import com.onelogin.saml2.exception.Error;
28-
import com.onelogin.saml2.exception.XMLEntityException;
2928
import com.onelogin.saml2.http.HttpRequest;
3029
import com.onelogin.saml2.logout.LogoutRequest;
3130
import com.onelogin.saml2.logout.LogoutResponse;
@@ -493,12 +492,11 @@ public void login(String returnTo) throws IOException, SettingsException {
493492
* @return the SLO URL with the LogoutRequest if stay = True
494493
*
495494
* @throws IOException
496-
* @throws XMLEntityException
497495
* @throws SettingsException
498496
*/
499497
public String logout(String returnTo, String nameId, String sessionIndex, Boolean stay, String nameidFormat,
500498
String nameIdNameQualifier, String nameIdSPNameQualifier)
501-
throws IOException, XMLEntityException, SettingsException {
499+
throws IOException, SettingsException {
502500
Map<String, String> parameters = new HashMap<String, String>();
503501
return logout(returnTo, nameId, sessionIndex, stay, nameidFormat,
504502
nameIdNameQualifier, nameIdSPNameQualifier, parameters);
@@ -528,12 +526,11 @@ public String logout(String returnTo, String nameId, String sessionIndex, Boolea
528526
* @return the SLO URL with the LogoutRequest if stay = True
529527
*
530528
* @throws IOException
531-
* @throws XMLEntityException
532529
* @throws SettingsException
533530
*/
534531
public String logout(String returnTo, String nameId, String sessionIndex, Boolean stay, String nameidFormat,
535532
String nameIdNameQualifier, String nameIdSPNameQualifier, Map<String, String> parameters)
536-
throws IOException, XMLEntityException, SettingsException {
533+
throws IOException, SettingsException {
537534

538535
if (parameters == null) {
539536
parameters = new HashMap<String, String>();
@@ -593,11 +590,10 @@ public String logout(String returnTo, String nameId, String sessionIndex, Boolea
593590
* @return the SLO URL with the LogoutRequest if stay = True
594591
*
595592
* @throws IOException
596-
* @throws XMLEntityException
597593
* @throws SettingsException
598594
*/
599595
public String logout(String returnTo, String nameId, String sessionIndex, Boolean stay, String nameidFormat,
600-
String nameIdNameQualifier) throws IOException, XMLEntityException, SettingsException {
596+
String nameIdNameQualifier) throws IOException, SettingsException {
601597
return logout(returnTo, nameId, sessionIndex, stay, nameidFormat, nameIdNameQualifier, null);
602598
}
603599

@@ -618,11 +614,10 @@ public String logout(String returnTo, String nameId, String sessionIndex, Boolea
618614
* @return the SLO URL with the LogoutRequest if stay = True
619615
*
620616
* @throws IOException
621-
* @throws XMLEntityException
622617
* @throws SettingsException
623618
*/
624619
public String logout(String returnTo, String nameId, String sessionIndex, Boolean stay, String nameidFormat)
625-
throws IOException, XMLEntityException, SettingsException {
620+
throws IOException, SettingsException {
626621
return logout(returnTo, nameId, sessionIndex, stay, nameidFormat, null);
627622
}
628623

@@ -642,11 +637,10 @@ public String logout(String returnTo, String nameId, String sessionIndex, Boolea
642637
* @return the SLO URL with the LogoutRequest if stay = True
643638
*
644639
* @throws IOException
645-
* @throws XMLEntityException
646640
* @throws SettingsException
647641
*/
648642
public String logout(String returnTo, String nameId, String sessionIndex, Boolean stay)
649-
throws IOException, XMLEntityException, SettingsException {
643+
throws IOException, SettingsException {
650644
return logout(returnTo, nameId, sessionIndex, stay, null);
651645
}
652646

@@ -668,12 +662,11 @@ public String logout(String returnTo, String nameId, String sessionIndex, Boolea
668662
* @param nameIdSPNameQualifier The NameID SP Name Qualifier that will be set in
669663
* the LogoutRequest.
670664
* @throws IOException
671-
* @throws XMLEntityException
672665
* @throws SettingsException
673666
*/
674667
public void logout(String returnTo, String nameId, String sessionIndex, String nameidFormat,
675668
String nameIdNameQualifier, String nameIdSPNameQualifier)
676-
throws IOException, XMLEntityException, SettingsException {
669+
throws IOException, SettingsException {
677670
logout(returnTo, nameId, sessionIndex, false, nameidFormat, nameIdNameQualifier, nameIdSPNameQualifier);
678671
}
679672

@@ -693,11 +686,10 @@ public void logout(String returnTo, String nameId, String sessionIndex, String n
693686
* LogoutRequest.
694687
*
695688
* @throws IOException
696-
* @throws XMLEntityException
697689
* @throws SettingsException
698690
*/
699691
public void logout(String returnTo, String nameId, String sessionIndex, String nameidFormat,
700-
String nameIdNameQualifier) throws IOException, XMLEntityException, SettingsException {
692+
String nameIdNameQualifier) throws IOException, SettingsException {
701693
logout(returnTo, nameId, sessionIndex, false, nameidFormat, nameIdNameQualifier);
702694
}
703695

@@ -713,11 +705,10 @@ public void logout(String returnTo, String nameId, String sessionIndex, String n
713705
* process).
714706
* @param nameidFormat The NameID Format will be set in the LogoutRequest.
715707
* @throws IOException
716-
* @throws XMLEntityException
717708
* @throws SettingsException
718709
*/
719710
public void logout(String returnTo, String nameId, String sessionIndex, String nameidFormat)
720-
throws IOException, XMLEntityException, SettingsException {
711+
throws IOException, SettingsException {
721712
logout(returnTo, nameId, sessionIndex, false, nameidFormat);
722713
}
723714

@@ -733,22 +724,20 @@ public void logout(String returnTo, String nameId, String sessionIndex, String n
733724
* process).
734725
*
735726
* @throws IOException
736-
* @throws XMLEntityException
737727
* @throws SettingsException
738728
*/
739729
public void logout(String returnTo, String nameId, String sessionIndex)
740-
throws IOException, XMLEntityException, SettingsException {
730+
throws IOException, SettingsException {
741731
logout(returnTo, nameId, sessionIndex, false, null);
742732
}
743733

744734
/**
745735
* Initiates the SLO process.
746736
*
747737
* @throws IOException
748-
* @throws XMLEntityException
749738
* @throws SettingsException
750739
*/
751-
public void logout() throws IOException, XMLEntityException, SettingsException {
740+
public void logout() throws IOException, SettingsException {
752741
logout(null, null, null, false);
753742
}
754743

@@ -760,10 +749,9 @@ public void logout() throws IOException, XMLEntityException, SettingsException {
760749
* appended at all when an empty string is provided
761750
*
762751
* @throws IOException
763-
* @throws XMLEntityException
764752
* @throws SettingsException
765753
*/
766-
public void logout(String returnTo) throws IOException, XMLEntityException, SettingsException {
754+
public void logout(String returnTo) throws IOException, SettingsException {
767755
logout(returnTo, null, null);
768756
}
769757

0 commit comments

Comments
 (0)