本文整理汇总了Java中org.xdi.util.security.StringEncrypter类的典型用法代码示例。如果您正苦于以下问题:Java StringEncrypter类的具体用法?Java StringEncrypter怎么用?Java StringEncrypter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringEncrypter类属于org.xdi.util.security包,在下文中一共展示了StringEncrypter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DbConnectionUtil
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
/**
* Default constructor.
*/
private DbConnectionUtil() {
ApplicationConfiguration applicationConfiguration = OxTrustConfiguration.instance().getApplicationConfiguration();
String cryptoConfigurationSalt = OxTrustConfiguration.instance().getCryptoConfigurationSalt();
this.dbUrl = applicationConfiguration.getMysqlUrl();
this.userName = applicationConfiguration.getMysqlUser();
try {
String password = applicationConfiguration.getMysqlPassword();
this.password = StringEncrypter.defaultInstance().decrypt(password, cryptoConfigurationSalt);
log.debug("Url::: " + dbUrl + " User: " + userName + " Password: " + password);
} catch (Exception ex) {
log.error("Error while decrypting MySql connection password: " + applicationConfiguration.getMysqlPassword() + " Msg: "
+ ex.getMessage());
}
}
示例2: createEasySSLContext
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
protected SSLContext createEasySSLContext(ApplicationConfiguration applicationConfiguration) {
try {
String password = applicationConfiguration.getCaCertsPassphrase();
char[] passphrase = null;
if (password != null) {
passphrase = StringEncrypter.defaultInstance().decrypt(password, cryptoConfigurationSalt).toCharArray();
}
KeyStore cacerts = null;
String cacertsFN = applicationConfiguration.getCaCertsLocation();
if (cacertsFN != null) {
cacerts = KeyStore.getInstance(KeyStore.getDefaultType());
FileInputStream cacertsFile = new FileInputStream(cacertsFN);
cacerts.load(cacertsFile, passphrase);
cacertsFile.close();
}
SSLContext context = SSLContext.getInstance("SSL");
context.init(null, new TrustManager[] { new EasyX509TrustManager(cacerts) }, null);
return context;
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new HttpClientError(e.toString());
}
}
示例3: initInternal
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
protected void initInternal() {
this.clientId = appConfiguration.getOpenIdClientId();
this.clientSecret = appConfiguration.getOpenIdClientPassword();
if (StringHelper.isNotEmpty(this.clientSecret)) {
try {
StringEncrypter stringEncrypter = StringEncrypter.instance(this.configuration.getCryptoConfigurationSalt());
this.clientSecret = stringEncrypter.decrypt(this.clientSecret);
} catch (EncryptionException ex) {
logger.warn("Assuming that client password is not encrypted!");
}
}
this.preRegisteredClient = StringHelper.isNotEmpty(this.clientId) && StringHelper.isNotEmpty(this.clientSecret);
loadOpenIdConfiguration();
}
示例4: getStringEncrypter
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
@Produces @ApplicationScoped
public StringEncrypter getStringEncrypter() throws OxIntializationException {
String encodeSalt = configurationFactory.getCryptoConfigurationSalt();
if (StringHelper.isEmpty(encodeSalt)) {
throw new OxIntializationException("Encode salt isn't defined");
}
try {
StringEncrypter stringEncrypter = StringEncrypter.instance(encodeSalt);
return stringEncrypter;
} catch (EncryptionException ex) {
throw new OxIntializationException("Failed to create StringEncrypter instance");
}
}
示例5: createIdToken
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
@Override
public IdToken createIdToken(String nonce, AuthorizationCode authorizationCode, AccessToken accessToken,
AuthorizationGrant authorizationGrant, boolean includeIdTokenClaims)
throws SignatureException, StringEncrypter.EncryptionException, InvalidJwtException, InvalidJweException {
try {
final IdToken idToken = createIdToken(this, nonce, authorizationCode, accessToken, getScopes(),
includeIdTokenClaims);
final String acrValues = authorizationGrant.getAcrValues();
final String sessionDn = authorizationGrant.getSessionDn();
if (idToken.getExpiresIn() > 0) {
final TokenLdap tokenLdap = asToken(idToken);
tokenLdap.setAuthMode(acrValues);
tokenLdap.setSessionDn(sessionDn);
persist(tokenLdap);
}
setAcrValues(acrValues);
setSessionDn(sessionDn);
save();
return idToken;
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
示例6: authenticate
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
/**
* Authenticate client.
*
* @param clientId Client inum.
* @param password Client password.
* @return <code>true</code> if success, otherwise <code>false</code>.
*/
public boolean authenticate(String clientId, String password) {
log.debug("Authenticating Client with LDAP: clientId = {}", clientId);
boolean authenticated = false;
try {
Client client = getClient(clientId);
String decryptedClientSecret = decryptSecret(client.getClientSecret());
authenticated = client != null && decryptedClientSecret != null
&& decryptedClientSecret.equals(password);
} catch (StringEncrypter.EncryptionException e) {
log.error(e.getMessage(), e);
}
return authenticated;
}
示例7: getStringEncrypter
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
@Produces @ApplicationScoped
public StringEncrypter getStringEncrypter() {
String encodeSalt = configurationFactory.getCryptoConfigurationSalt();
if (StringHelper.isEmpty(encodeSalt)) {
throw new ConfigurationException("Encode salt isn't defined");
}
try {
StringEncrypter stringEncrypter = StringEncrypter.instance(encodeSalt);
return stringEncrypter;
} catch (EncryptionException ex) {
throw new ConfigurationException("Failed to create StringEncrypter instance");
}
}
示例8: setSmtpPassword
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
public void setSmtpPassword(String smtpPassword) {
if (smtpPassword != null && !smtpPassword.equals("")) {
this.smtpPassword = smtpPassword;
smtpPasswordStr = smtpPassword;
try {
String cryptoConfigurationSalt = OxTrustConfiguration.instance().getCryptoConfigurationSalt();
smtpPasswordStr = StringEncrypter.defaultInstance().decrypt(smtpPasswordStr, cryptoConfigurationSalt);
} catch (Exception ex) {
log.error("Failed to decrypt password: " + smtpPassword, ex);
}
}
}
示例9: setSmtpPasswordStr
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
public void setSmtpPasswordStr(String smtpPasswordStr) {
if (smtpPasswordStr != null && !smtpPasswordStr.equals("")) {
this.smtpPasswordStr = smtpPasswordStr;
smtpPassword = smtpPasswordStr;
try {
String cryptoConfigurationSalt = OxTrustConfiguration.instance().getCryptoConfigurationSalt();
smtpPassword = StringEncrypter.defaultInstance().encrypt(smtpPassword, cryptoConfigurationSalt);
} catch (Exception ex) {
log.error("Failed to encrypt password: " + smtpPassword, ex);
}
}
}
示例10: encryptString
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
public String encryptString(String value) {
try {
return StringEncrypter.defaultInstance().encrypt(value, cryptoConfigurationSalt);
} catch (EncryptionException ex) {
log.error("Failed to encrypt string: " + value, ex);
}
return null;
}
示例11: processPasswordProperty
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
private void processPasswordProperty(ApplicationConfiguration source, ApplicationConfiguration current, String property) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, EncryptionException {
String currentValue = BeanUtils.getProperty(current, property);
if (StringHelper.equals(currentValue, HIDDEN_PASSWORD_TEXT)) {
String sourceValue = BeanUtils.getSimpleProperty(source, property);
BeanUtils.setProperty(current, property, sourceValue);
} else {
String currentValueEncrypted = StringEncrypter.defaultInstance().encrypt(currentValue, cryptoConfigurationSalt);
BeanUtils.setProperty(current, property, currentValueEncrypted);
}
}
示例12: updateLdapBindPassword
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
public void updateLdapBindPassword() {
String encryptedLdapBindPassword = null;
try {
encryptedLdapBindPassword = StringEncrypter.defaultInstance().encrypt(this.ldapConfig.getBindPassword(), cryptoConfigurationSalt);
} catch (EncryptionException ex) {
log.error("Failed to encrypt LDAP bind password", ex);
}
this.ldapConfig.setBindPassword(encryptedLdapBindPassword);
}
示例13: update
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
@Restrict("#{s:hasPermission('profile', 'access')}")
public String update() {
String result;
GluuAppliance appliance = applianceService.getAppliance();
try {
appliance.setBlowfishPassword(StringEncrypter.defaultInstance().encrypt(newPassword, cryptoConfigurationSalt));
} catch (EncryptionException e) {
log.error("Failed to encrypt password", e);
}
appliance.setUserPassword(newPassword);
if (centralLdapService.isUseCentralServer()) {
GluuAppliance tmpAppliance = new GluuAppliance();
tmpAppliance.setDn(appliance.getDn());
boolean existAppliance = centralLdapService.containsAppliance(tmpAppliance);
if (existAppliance) {
centralLdapService.updateAppliance(appliance);
} else {
centralLdapService.addAppliance(appliance);
}
}
applianceService.updateAppliance(appliance);
result = OxTrustConstants.RESULT_SUCCESS;
return result;
}
示例14: updateBindPassword
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
public void updateBindPassword() {
if (this.activeLdapConfig == null) {
return;
}
try {
this.activeLdapConfig.setBindPassword(StringEncrypter.defaultInstance().encrypt(this.activeLdapConfig.getBindPassword(), cryptoConfigurationSalt));
} catch (EncryptionException ex) {
log.error("Failed to encrypt password", ex);
}
}
示例15: getPassportConfig
import org.xdi.util.security.StringEncrypter; //导入依赖的package包/类
@POST
@Produces({MediaType.APPLICATION_JSON})
public Response getPassportConfig(@FormParam(OxTrustConstants.OXAUTH_ACCESS_TOKEN) final String rpt) throws Exception{
PassportConfigResponse passportConfigResponse = null;
try{
RptStatusService rptStatusService = UmaClientFactory.instance().createRptStatusService(metadataConfiguration);
String umaPatClientId = applicationConfiguration.getOxAuthClientId();
String umaPatClientSecret = applicationConfiguration.getOxAuthClientPassword();
if (umaPatClientSecret != null) {
try {
umaPatClientSecret = StringEncrypter.defaultInstance().decrypt(umaPatClientSecret, cryptoConfigurationSalt);
} catch (EncryptionException ex) {
log.error("Failed to decrypt client password", ex);
}
}
String tokenEndpoint = metadataConfiguration.getTokenEndpoint();
Token patToken = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret);
if((patToken != null) ){
RptIntrospectionResponse tokenStatusResponse = rptStatusService.requestRptStatus(
"Bearer " + patToken.getAccessToken(),
rpt, "");
if((tokenStatusResponse != null) && (tokenStatusResponse.getActive())){
passportConfigResponse = new PassportConfigResponse();
LdapOxPassportConfiguration ldapOxPassportConfiguration = oxPassportService.loadConfigurationFromLdap();
List<org.xdi.config.oxtrust.PassportConfiguration> passportConfigurations =ldapOxPassportConfiguration.getPassportConfigurations();
Map <String ,PassportStrategy> PassportConfigurationsMap = new HashMap<String, PassportStrategy>();
for(org.xdi.config.oxtrust.PassportConfiguration passportConfiguration : passportConfigurations){
if(passportConfiguration.getProvider().equalsIgnoreCase("passport")){
passportConfigResponse.setApplicationEndpoint((passportConfiguration.getApplicationEndpoint()==null) ? "" : passportConfiguration.getApplicationEndpoint() );
passportConfigResponse.setAuthenticationUrl((passportConfiguration.getServerURI()==null) ? "" : passportConfiguration.getServerURI());
passportConfigResponse.setApplicationStartpoint((passportConfiguration.getApplicationStartpoint()==null) ? "" : passportConfiguration.getApplicationStartpoint());
}else{
PassportStrategy passportStrategy = new PassportStrategy();
passportStrategy.setClientID((passportConfiguration.getClientID()==null) ? "" : passportConfiguration.getClientID());
passportStrategy.setClientSecret((passportConfiguration.getClientSecret()==null) ? "" : passportConfiguration.getClientSecret());
PassportConfigurationsMap.put((passportConfiguration.getProvider()==null) ? "" : passportConfiguration.getProvider(), passportStrategy);
}
}
passportConfigResponse.setPassportStrategies(PassportConfigurationsMap);
return Response.status(Response.Status.OK).entity(passportConfigResponse).build();
}else{
log.info("Invalid GAT/RPT token. ");
return Response.status(Response.Status.UNAUTHORIZED).build();
}
}else{
log.info("Unable to get PAT token. ");
return Response.status(Response.Status.SERVICE_UNAVAILABLE).build();
}
}catch(Exception e){
log.error("Exception Occured : {0} ", e.getMessage());
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}