diff --git a/maxkey-core/src/main/java/org/maxkey/constants/ldap/ActiveDirectoryUser.java b/maxkey-core/src/main/java/org/maxkey/constants/ldap/ActiveDirectoryUser.java index b01686a9..354b021f 100644 --- a/maxkey-core/src/main/java/org/maxkey/constants/ldap/ActiveDirectoryUser.java +++ b/maxkey-core/src/main/java/org/maxkey/constants/ldap/ActiveDirectoryUser.java @@ -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"); diff --git a/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/endpoint/AssertionEndpoint.java b/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/endpoint/AssertionEndpoint.java index 223ff866..df8f5a73 100644 --- a/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/endpoint/AssertionEndpoint.java +++ b/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/endpoint/AssertionEndpoint.java @@ -72,9 +72,9 @@ public class AssertionEndpoint { } logger.debug("AuthnRequestInfo: {}", authnRequestInfo); - HashMap attributeMap=new HashMap(); - 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; } + + } diff --git a/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/xml/AttributeStatementGenerator.java b/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/xml/AttributeStatementGenerator.java index 2821c7df..748b14c4 100644 --- a/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/xml/AttributeStatementGenerator.java +++ b/maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/provider/xml/AttributeStatementGenerator.java @@ -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> iterator = attributeMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -121,6 +126,29 @@ public class AttributeStatementGenerator { return xsStringValue; } - + public HashMap putUserAttributes(HashMap 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; + } } diff --git a/maxkey-webs/maxkey-web-resources/build.gradle b/maxkey-webs/maxkey-web-resources/build.gradle index e00f1ff1..c9c5a937 100644 --- a/maxkey-webs/maxkey-web-resources/build.gradle +++ b/maxkey-webs/maxkey-web-resources/build.gradle @@ -1,4 +1,4 @@ -description = "maxkey-web-static" +description = "maxkey-web-resources" //add support for Java apply plugin: 'java'