v3.0.0GA with SAML User Attributes

上级 2c5c2c07
......@@ -178,6 +178,13 @@ public class ActiveDirectoryUser {
public static final String UNICODEPWD = "unicodePwd";
public static final String DISTINGUISHEDNAME = "distinguishedname";
//MaxKey EXTEND
public static final String MANAGERNAME = "managerName";
public static final String USERNAME = "username";
public static final String USERTYPE = "userType";
public static final String GENDER = "gender";
public static final String USERSTATUS = "status";
public static byte[] encodePassword(String password) throws UnsupportedEncodingException {
return ("\"" + password + "\"").getBytes("UTF-16LE");
......
......@@ -72,9 +72,9 @@ public class AssertionEndpoint {
}
logger.debug("AuthnRequestInfo: {}", authnRequestInfo);
HashMap <String,String>attributeMap=new HashMap<String,String>();
attributeMap.put(WebConstants.ONLINE_TICKET_NAME, ((SigninPrincipal)WebContext.getAuthentication().getPrincipal()).getOnlineTicket().getTicketId());
attributeMap.put(WebConstants.ONLINE_TICKET_NAME,
((SigninPrincipal)WebContext.getAuthentication().getPrincipal()).getOnlineTicket().getTicketId());
//saml20Details
Response authResponse = authnResponseGenerator.generateAuthnResponse(
......@@ -97,5 +97,7 @@ public class AssertionEndpoint {
}
return null;
}
}
......@@ -25,9 +25,12 @@ import java.util.Map;
import java.util.Map.Entry;
import org.maxkey.constants.Boolean;
import org.maxkey.constants.ldap.ActiveDirectoryUser;
import org.maxkey.entity.ExtraAttr;
import org.maxkey.entity.ExtraAttrs;
import org.maxkey.entity.UserInfo;
import org.maxkey.entity.apps.AppsSAML20Details;
import org.maxkey.web.WebContext;
import org.opensaml.Configuration;
import org.opensaml.saml2.core.Attribute;
import org.opensaml.saml2.core.AttributeStatement;
......@@ -62,6 +65,8 @@ public class AttributeStatementGenerator {
Attribute attributeGrantedAuthority=builderGrantedAuthority(grantedAuthoritys);
attributeStatement.getAttributes().add(attributeGrantedAuthority);
putUserAttributes(attributeMap);
if(null!=attributeMap){
Iterator<Entry<String, String>> iterator = attributeMap.entrySet().iterator();
while (iterator.hasNext()) {
......@@ -121,6 +126,29 @@ public class AttributeStatementGenerator {
return xsStringValue;
}
public HashMap <String,String> putUserAttributes(HashMap <String,String> attributeMap){
UserInfo userInfo = WebContext.getUserInfo();
attributeMap.put(ActiveDirectoryUser.USERNAME, userInfo.getUsername());
attributeMap.put(ActiveDirectoryUser.UID, userInfo.getUsername());
attributeMap.put(ActiveDirectoryUser.EMPLOYEENUMBER, userInfo.getEmployeeNumber());
attributeMap.put(ActiveDirectoryUser.DEPARTMENTNUMBER, userInfo.getDepartmentId());
attributeMap.put(ActiveDirectoryUser.DEPARTMENT, userInfo.getDepartment());
attributeMap.put(ActiveDirectoryUser.COMPANY, userInfo.getDivision());
attributeMap.put(ActiveDirectoryUser.TITLE, userInfo.getJobTitle());
attributeMap.put(ActiveDirectoryUser.MANAGER, userInfo.getManagerId());
attributeMap.put(ActiveDirectoryUser.MANAGERNAME, userInfo.getManager());
attributeMap.put(ActiveDirectoryUser.DISPLAYNAME, userInfo.getDisplayName());
attributeMap.put(ActiveDirectoryUser.GIVENNAME, userInfo.getGivenName());
attributeMap.put(ActiveDirectoryUser.SN, userInfo.getFamilyName());
attributeMap.put(ActiveDirectoryUser.GENDER, userInfo.getGender() + "");
attributeMap.put(ActiveDirectoryUser.MAIL, userInfo.getEmail());
attributeMap.put(ActiveDirectoryUser.MOBILE, userInfo.getMobile());
attributeMap.put(ActiveDirectoryUser.USERSTATUS, userInfo.getStatus() + "");
return attributeMap;
}
}
description = "maxkey-web-static"
description = "maxkey-web-resources"
//add support for Java
apply plugin: 'java'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册