use of org.maxkey.entity.ExtraAttrs in project MaxKey by dromara.
the class ExtendApiQiye163ExmailAdapter method authorize.
@Override
public ModelAndView authorize(ModelAndView modelAndView) {
Apps details = (Apps) app;
// extraAttrs from Applications
ExtraAttrs extraAttrs = null;
if (details.getIsExtendAttr() == 1) {
extraAttrs = new ExtraAttrs(details.getExtendAttr());
}
String time = System.currentTimeMillis() + "";
// 域名,请使用企业自己的域名
String domain = details.getPrincipal();
String account_name = this.userInfo.getEmail();
// String lang = "0";
String src = account_name + domain + time;
String privateKey = details.getCredentials();
String enc = null;
try {
enc = HexUtils.bytes2HexString(RSAUtils.sign(src.getBytes("UTF-8"), (RSAPrivateKey) RSAUtils.privateKey(HexUtils.hex2Bytes(privateKey)), null));
String loginUrl = String.format(REDIRECT_URI, domain, account_name, time, enc);
_logger.debug("LoginUrl {} ", loginUrl);
modelAndView.addObject("redirect_uri", loginUrl);
} catch (UnsupportedEncodingException e) {
_logger.error("UnsupportedEncodingException ", e);
} catch (Exception e) {
_logger.error("Exception ", e);
}
return modelAndView;
}
use of org.maxkey.entity.ExtraAttrs in project MaxKey by dromara.
the class AttributeStatementGenerator method generateAttributeStatement.
public AttributeStatement generateAttributeStatement(AppsSAML20Details saml20Details, ArrayList<GrantedAuthority> grantedAuthoritys, HashMap<String, String> attributeMap) {
AttributeStatementBuilder attributeStatementBuilder = (AttributeStatementBuilder) builderFactory.getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
AttributeStatement attributeStatement = attributeStatementBuilder.buildObject();
Attribute attributeGrantedAuthority = builderGrantedAuthority(grantedAuthoritys);
attributeStatement.getAttributes().add(attributeGrantedAuthority);
putUserAttributes(attributeMap);
if (null != attributeMap) {
Iterator<Entry<String, String>> iterator = attributeMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next();
String key = entry.getKey();
String value = entry.getValue();
Attribute attribute = builderAttribute(key, value, Attribute.BASIC);
attributeStatement.getAttributes().add(attribute);
}
}
logger.debug("ExtendAttr " + saml20Details.getExtendAttr());
if (ConstsBoolean.isTrue(saml20Details.getIsExtendAttr()) && saml20Details.getExtendAttr() != null) {
ExtraAttrs extraAttrs = new ExtraAttrs(saml20Details.getExtendAttr());
for (ExtraAttr extraAttr : extraAttrs.getExtraAttrs()) {
extraAttr.setValue(extraAttr.getValue().replaceAll(COMMA_ISO8859_1, COMMA));
logger.debug("Attribute : {} , Vale : {} , Type : {}", extraAttr.getAttr(), extraAttr.getValue(), extraAttr.getType());
attributeStatement.getAttributes().add(builderAttribute(extraAttr.getAttr(), extraAttr.getValue(), extraAttr.getType()));
}
}
return attributeStatement;
}
Aggregations