浏览代码

Logout null exception

Logout null exception
MaxKey 4 年之前
父节点
当前提交
74f947684a

+ 26 - 2
maxkey-core/src/main/java/org/maxkey/domain/Organizations.java

@@ -85,9 +85,13 @@ public class Organizations extends JpaBaseDomain implements Serializable {
     private String description;
     
     private String status;
+    @Column
+    private String extId;
+    @Column
+    private String extParentId;
 
     public Organizations() {
-        // TODO Auto-generated constructor stub
+        //
     }
 
     public String getId() {
@@ -309,8 +313,24 @@ public class Organizations extends JpaBaseDomain implements Serializable {
     public void setStatus(String status) {
         this.status = status;
     }
+    
+    public String getExtId() {
+		return extId;
+	}
+
+	public void setExtId(String extId) {
+		this.extId = extId;
+	}
+
+	public String getExtParentId() {
+		return extParentId;
+	}
+
+	public void setExtParentId(String extParentId) {
+		this.extParentId = extParentId;
+	}
 
-    @Override
+	@Override
 	public String toString() {
 		StringBuilder builder = new StringBuilder();
 		builder.append("Organizations [id=");
@@ -365,6 +385,10 @@ public class Organizations extends JpaBaseDomain implements Serializable {
 		builder.append(description);
 		builder.append(", status=");
 		builder.append(status);
+		builder.append(", extId=");
+		builder.append(extId);
+		builder.append(", extParentId=");
+		builder.append(extParentId);
 		builder.append("]");
 		return builder.toString();
 	}

+ 30 - 24
maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LogoutEndpoint.java

@@ -112,32 +112,38 @@ public class LogoutEndpoint {
  		_logger.debug("re Login URL : "+ reLoginUrl);
  		
  		modelAndView.addObject("reloginUrl",reLoginUrl);
- 		String onlineTicketId = ((SigninPrincipal)WebContext.getAuthentication().getPrincipal()).getOnlineTicket().getTicketId();
- 		OnlineTicket onlineTicket = onlineTicketServices.get(onlineTicketId);
- 		
- 		Set<Entry<String, Apps>> entrySet = onlineTicket.getAuthorizedApps().entrySet();
- 
-        Iterator<Entry<String, Apps>> iterator = entrySet.iterator();
-        while (iterator.hasNext()) {
-            Entry<String, Apps> mapEntry = iterator.next();
-            _logger.debug("App Id : "+ mapEntry.getKey()+ " , " +mapEntry.getValue());
-            if( mapEntry.getValue().getLogoutType() == LogoutType.BACK_CHANNEL){
-                SingleLogout singleLogout;
-                if(mapEntry.getValue().getProtocol().equalsIgnoreCase(ConstantsProtocols.CAS)) {
-                    singleLogout =new SamlSingleLogout();
-                }else {
-                    singleLogout = new DefaultSingleLogout();
-                }
-                singleLogout.sendRequest(onlineTicket.getAuthentication(), mapEntry.getValue());
-            }
-        }
- 		onlineTicketServices.remove(onlineTicketId);
  		
+ 		//if logined in have onlineTicket ,need remove or logout back
+ 		if(WebContext.getAuthentication() != null) {
+ 			String onlineTicketId = ((SigninPrincipal)WebContext.getAuthentication().getPrincipal()).getOnlineTicket().getTicketId();
+ 	 		OnlineTicket onlineTicket = onlineTicketServices.get(onlineTicketId);
+ 	 		if(onlineTicket != null) {
+		 		Set<Entry<String, Apps>> entrySet = onlineTicket.getAuthorizedApps().entrySet();
+		 
+		        Iterator<Entry<String, Apps>> iterator = entrySet.iterator();
+		        while (iterator.hasNext()) {
+		            Entry<String, Apps> mapEntry = iterator.next();
+		            _logger.debug("App Id : "+ mapEntry.getKey()+ " , " +mapEntry.getValue());
+		            if( mapEntry.getValue().getLogoutType() == LogoutType.BACK_CHANNEL){
+		                SingleLogout singleLogout;
+		                if(mapEntry.getValue().getProtocol().equalsIgnoreCase(ConstantsProtocols.CAS)) {
+		                    singleLogout =new SamlSingleLogout();
+		                }else {
+		                    singleLogout = new DefaultSingleLogout();
+		                }
+		                singleLogout.sendRequest(onlineTicket.getAuthentication(), mapEntry.getValue());
+		            }
+		        }
+		 		onlineTicketServices.remove(onlineTicketId);
+ 	 		}
+ 		}
  		//remove ONLINE_TICKET cookie
- 		WebContext.expiryCookie(WebContext.getResponse(), 
-                this.applicationConfig.getBaseDomainName(), 
-                WebConstants.ONLINE_TICKET_NAME, 
-                UUID.randomUUID().toString());
+ 		WebContext.expiryCookie(
+ 					WebContext.getResponse(), 
+ 					this.applicationConfig.getBaseDomainName(), 
+ 					WebConstants.ONLINE_TICKET_NAME, 
+ 					UUID.randomUUID().toString()
+ 		);
  		
  		request.getSession().invalidate();
  		SecurityContextHolder.clearContext();