本文整理汇总了Java中org.identityconnectors.common.security.GuardedString类的典型用法代码示例。如果您正苦于以下问题:Java GuardedString类的具体用法?Java GuardedString怎么用?Java GuardedString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GuardedString类属于org.identityconnectors.common.security包,在下文中一共展示了GuardedString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toGuardedString
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
public static GuardedString toGuardedString(ProtectedStringType ps, Protector protector, String propertyName) {
if (ps == null) {
return null;
}
if (!protector.isEncrypted(ps)) {
if (ps.getClearValue() == null) {
return null;
}
// LOGGER.warn("Using cleartext value for {}", propertyName);
return new GuardedString(ps.getClearValue().toCharArray());
}
try {
return new GuardedString(protector.decryptString(ps).toCharArray());
} catch (EncryptionException e) {
// LOGGER.error("Unable to decrypt value of element {}: {}",
// new Object[] { propertyName, e.getMessage(), e });
throw new SystemException("Unable to decrypt value of element " + propertyName + ": "
+ e.getMessage(), e);
}
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:ConnIdUtil.java
示例2: testChangePassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
@Test(dependsOnMethods = {"testEnableUser"})
public void testChangePassword() throws IOException {
Set<Attribute> attributes = new HashSet<Attribute>();
attributes.add(AttributeBuilder.build(Name.NAME, USER_NAME));
String newPassword = "Test5678";
GuardedString password = new GuardedString(newPassword.toCharArray());
attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_NAME, password));
OperationOptions operationOptions = null;
sapConnector.update(ACCOUNT_OBJECT_CLASS, new Uid(USER_NAME), attributes, operationOptions);
String fileName = "testChangePass.properties";
SapConfiguration sapConf = null;
sapConf = readSapConfigurationFromFile(fileName);
SapConnector sapConn = new SapConnector();
try {
sapConn.init(sapConf);
sapConn.test();
} catch (Exception e) {
// authentificated, but don't have privileges
if (!e.toString().contains("No RFC authorization for function module RFCPING")) {
throw e;
}
}
}
开发者ID:Evolveum,项目名称:connector-sap,代码行数:26,代码来源:TestClient.java
示例3: changePassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private void changePassword(final DummyAccount account, Attribute attr) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
final String[] passwdArray = { null };
if (attr.getValue() != null && !attr.getValue().isEmpty()) {
Object passwdObject = attr.getValue().get(0);
if (!(passwdObject instanceof GuardedString)) {
throw new IllegalArgumentException(
"Password was provided as " + passwdObject.getClass().getName() + " while expecting GuardedString");
}
((GuardedString)passwdObject).access(new Accessor() {
@Override
public void access(char[] passwdChars) {
String password = new String(passwdChars);
checkPasswordPolicies(password);
passwdArray[0] = password;
}
});
} else {
// empty password => null
checkPasswordPolicies(null);
}
account.setPassword(passwdArray[0]);
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:23,代码来源:DummyConnector.java
示例4: processModificationsBeforeUpdate
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private Modification[] processModificationsBeforeUpdate(List<Modification> modifications) {
Modification[] out = new Modification[modifications.size()];
int i = 0;
for (final Modification modification: modifications) {
if (modification.getAttribute() != null && modification.getAttribute().get() != null) {
Value<?> val = modification.getAttribute().get();
if (val instanceof GuardedStringValue) {
((GuardedStringValue)val).getGuardedStringValue().access(new GuardedString.Accessor() {
@Override
public void access(char[] clearChars) {
DefaultAttribute attr = new DefaultAttribute( modification.getAttribute().getId(), new String(clearChars));
modification.setAttribute(attr);
}
});
}
}
out[i] = modification;
i++;
}
return out;
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:22,代码来源:AbstractLdapConnector.java
示例5: processEntryBeforeCreate
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private void processEntryBeforeCreate(Entry entry) {
for(final org.apache.directory.api.ldap.model.entry.Attribute attribute: entry.getAttributes()) {
Value<?> val = attribute.get();
if (val instanceof GuardedStringValue) {
attribute.remove(val);
((GuardedStringValue)val).getGuardedStringValue().access(new GuardedString.Accessor() {
@Override
public void access(char[] clearChars) {
try {
attribute.add(new String(clearChars));
} catch (LdapInvalidAttributeValueException e) {
throw new InvalidAttributeValueException(e.getMessage(), e);
}
}
});
}
}
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:20,代码来源:AbstractLdapConnector.java
示例6: execute
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
/**
* Executes the request using the HTTP client.
*/
public CloseableHttpResponse execute(HttpUriRequest request) {
try {
if (AbstractRestConfiguration.AuthMethod.TOKEN.name().equals(getConfiguration().getAuthMethod())) {
final StringBuilder token = new StringBuilder();
if (getConfiguration().getTokenValue() != null) {
getConfiguration().getTokenValue().access(new GuardedString.Accessor() {
@Override
public void access(char[] chars) {
token.append(new String(chars));
}
});
}
request.setHeader(getConfiguration().getTokenName(), token.toString());
}
return getHttpClient().execute(request);
} catch (IOException e) {
throw new ConnectorIOException(e.getMessage(), e);
}
}
开发者ID:Evolveum,项目名称:polygon,代码行数:25,代码来源:AbstractRestConnector.java
示例7: getPassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
/**
* Extract password value from passed value (if instance of GuardedString or GuardedByteArray).
*
* @param pwd received from the underlying connector
* @return password value
*/
public static String getPassword(final Object pwd) {
final StringBuilder result = new StringBuilder();
if (pwd instanceof GuardedString) {
result.append(SecurityUtil.decrypt((GuardedString) pwd));
} else if (pwd instanceof GuardedByteArray) {
result.append(SecurityUtil.decrypt((GuardedByteArray) pwd));
} else if (pwd instanceof String) {
result.append((String) pwd);
} else {
result.append(pwd.toString());
}
return result.toString();
}
开发者ID:apache,项目名称:syncope,代码行数:22,代码来源:ConnObjectUtils.java
示例8: getPassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
/**
* Extract password value from passed value (if instance of GuardedString or
* GuardedByteArray).
*
* @param pwd received from the underlying connector
* @return password value
*/
private String getPassword(final Object pwd) {
final StringBuilder result = new StringBuilder();
if (pwd instanceof GuardedString) {
((GuardedString) pwd).access(new GuardedString.Accessor() {
@Override
public void access(final char[] clearChars) {
result.append(clearChars);
}
});
} else if (pwd instanceof GuardedByteArray) {
((GuardedByteArray) pwd).access(new GuardedByteArray.Accessor() {
@Override
public void access(final byte[] clearBytes) {
result.append(new String(clearBytes));
}
});
} else if (pwd instanceof String) {
result.append((String) pwd);
} else {
result.append(pwd.toString());
}
return result.toString();
}
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:35,代码来源:SyncJob.java
示例9: getString
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
public static String getString(GuardedString string) {
if (string != null) {
GuardedStringAccessor accessor = new GuardedStringAccessor();
string.access(accessor);
String out = accessor.getString();
accessor.clear();
return out;
} else {
return null;
}
}
开发者ID:CESNET,项目名称:kerberos-connector,代码行数:13,代码来源:GuardedStringAccessor.java
示例10: getPlainPassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private String getPlainPassword() {
final StringBuilder sb = new StringBuilder();
if (password != null) {
password.access(new GuardedString.Accessor() {
@Override
public void access(char[] chars) {
sb.append(new String(chars));
}
});
} else {
return null;
}
return sb.toString();
}
开发者ID:Evolveum,项目名称:connector-sap,代码行数:15,代码来源:SapConfiguration.java
示例11: testDelete
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
@Test(dependsOnMethods = {"testCreateFull"})
public void testDelete() throws RemoteException {
String userName = USER_NAME+"Del";
// create new
Set<Attribute> attributes = new HashSet<Attribute>();
attributes.add(AttributeBuilder.build(Name.NAME, userName));
GuardedString password = new GuardedString("Test1234".toCharArray());
attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_NAME, password));
OperationOptions operationOptions = null;
sapConnector.create(ACCOUNT_OBJECT_CLASS, attributes, operationOptions);
// delete it
sapConnector.delete(ACCOUNT_OBJECT_CLASS, new Uid(userName), operationOptions);
boolean deleted = false;
try {
SapFilter query = new SapFilter();
query.setByUsernameEquals(userName);
final boolean[] found = {false};
ResultsHandler handler = new ResultsHandler() {
@Override
public boolean handle(ConnectorObject connectorObject) {
found[0] = true;
return true; // continue
}
};
OperationOptions options = null;
sapConnector.executeQuery(ACCOUNT_OBJECT_CLASS, query, handler, options);
} catch (UnknownUidException e) {
deleted = true;
}
Assert.assertTrue(deleted, "User " + userName + " was not deleted");
}
开发者ID:Evolveum,项目名称:connector-sap,代码行数:37,代码来源:TestClient.java
示例12: icfTypeToXsdType
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
public static QName icfTypeToXsdType(Class<?> type, boolean isConfidential) {
// For arrays we are only interested in the component type
if (isMultivaluedType(type)) {
type = type.getComponentType();
}
QName propXsdType = null;
if (GuardedString.class.equals(type) ||
(String.class.equals(type) && isConfidential)) {
// GuardedString is a special case. It is a ICF-specific
// type
// implementing Potemkin-like security. Use a temporary
// "nonsense" type for now, so this will fail in tests and
// will be fixed later
// propXsdType = SchemaConstants.T_PROTECTED_STRING_TYPE;
propXsdType = ProtectedStringType.COMPLEX_TYPE;
} else if (GuardedByteArray.class.equals(type) ||
(Byte.class.equals(type) && isConfidential)) {
// GuardedString is a special case. It is a ICF-specific
// type
// implementing Potemkin-like security. Use a temporary
// "nonsense" type for now, so this will fail in tests and
// will be fixed later
// propXsdType = SchemaConstants.T_PROTECTED_BYTE_ARRAY_TYPE;
propXsdType = ProtectedByteArrayType.COMPLEX_TYPE;
} else {
propXsdType = XsdTypeMapper.toXsdType(type);
}
return propXsdType;
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:30,代码来源:ConnIdUtil.java
示例13: convertValueFromIcf
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private Object convertValueFromIcf(Object icfValue, QName propName) {
if (icfValue == null) {
return null;
}
if (icfValue instanceof GuardedString) {
return fromGuardedString((GuardedString) icfValue);
}
return icfValue;
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:ConnIdConvertor.java
示例14: fromGuardedString
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private ProtectedStringType fromGuardedString(GuardedString icfValue) {
final ProtectedStringType ps = new ProtectedStringType();
icfValue.access(new GuardedString.Accessor() {
@Override
public void access(char[] passwordChars) {
try {
ps.setClearValue(new String(passwordChars));
protector.encrypt(ps);
} catch (EncryptionException e) {
throw new IllegalStateException("Protector failed to encrypt password");
}
}
});
return ps;
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:16,代码来源:ConnIdConvertor.java
示例15: convertToIcf
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private Object convertToIcf(PrismPropertyValue<?> pval, Class<?> expectedType) throws ConfigurationException {
Object midPointRealValue = pval.getValue();
if (expectedType.equals(GuardedString.class)) {
// Guarded string is a special ICF beast
// The value must be ProtectedStringType
if (midPointRealValue instanceof ProtectedStringType) {
ProtectedStringType ps = (ProtectedStringType) pval.getValue();
return ConnIdUtil.toGuardedString(ps, pval.getParent().getElementName().getLocalPart(), protector);
} else {
throw new ConfigurationException(
"Expected protected string as value of configuration property "
+ pval.getParent().getElementName().getLocalPart() + " but got "
+ midPointRealValue.getClass());
}
} else if (expectedType.equals(GuardedByteArray.class)) {
// Guarded string is a special ICF beast
// TODO
// return new GuardedByteArray(Base64.decodeBase64((ProtectedByteArrayType) pval.getValue()));
return new GuardedByteArray(((ProtectedByteArrayType) pval.getValue()).getClearBytes());
} else if (midPointRealValue instanceof PolyString) {
return ((PolyString)midPointRealValue).getOrig();
} else if (midPointRealValue instanceof PolyStringType) {
return ((PolyStringType)midPointRealValue).getOrig();
} else if (expectedType.equals(File.class) && midPointRealValue instanceof String) {
return new File((String)midPointRealValue);
} else if (expectedType.equals(String.class) && midPointRealValue instanceof ProtectedStringType) {
try {
return protector.decryptString((ProtectedStringType)midPointRealValue);
} catch (EncryptionException e) {
throw new ConfigurationException(e);
}
} else {
return midPointRealValue;
}
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:37,代码来源:ConnIdConfigurationTransformer.java
示例16: convertFromPassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private void convertFromPassword(Set<Attribute> attributes, PropertyDelta<ProtectedStringType> passwordDelta) throws SchemaException {
if (passwordDelta == null) {
throw new IllegalArgumentException("No password was provided");
}
QName elementName = passwordDelta.getElementName();
if (StringUtils.isBlank(elementName.getNamespaceURI())) {
if (!QNameUtil.match(elementName, PasswordType.F_VALUE)) {
return;
}
} else if (!passwordDelta.getElementName().equals(PasswordType.F_VALUE)) {
return;
}
PrismProperty<ProtectedStringType> newPassword = passwordDelta.getPropertyNewMatchingPath();
if (newPassword == null || newPassword.isEmpty()) {
// This is the case of setting no password. E.g. removing existing password
LOGGER.debug("Setting null password.");
attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_NAME, Collections.EMPTY_LIST));
} else if (newPassword.getRealValue().canGetCleartext()) {
// We have password and we can get a cleartext value of the passowrd. This is normal case
GuardedString guardedPassword = ConnIdUtil.toGuardedString(newPassword.getRealValue(), "new password", protector);
attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_NAME, guardedPassword));
} else {
// We have password, but we cannot get a cleartext value. Just to nothing.
LOGGER.debug("We would like to set password, but we do not have cleartext value. Skipping the opearation.");
}
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:28,代码来源:ConnectorInstanceConnIdImpl.java
示例17: authenticate
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Uid authenticate(final ObjectClass objectClass, final String userName, final GuardedString password, final OperationOptions options) {
log.info("authenticate::begin");
Uid uid = null;
log.info("authenticate::end");
return uid;
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:DummyConnector.java
示例18: authenticate
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Uid authenticate(final ObjectClass objectClass, final String userName, final GuardedString password, final OperationOptions options) {
log.info("authenticate::begin");
Uid uid = null; //TODO: implement
log.info("authenticate::end");
return uid;
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:DummyConnector.java
示例19: getWinRmPassword
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
private String getWinRmPassword() {
GuardedString winRmPassword = getConfiguration().getWinRmPassword();
if (winRmPassword == null) {
winRmPassword = getConfiguration().getBindPassword();
}
if (winRmPassword == null) {
return null;
}
GuardedStringAccessor accessor = new GuardedStringAccessor();
winRmPassword.access(accessor);
return new String(accessor.getClearChars());
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:13,代码来源:AdLdapConnector.java
示例20: toIcfType
import org.identityconnectors.common.security.GuardedString; //导入依赖的package包/类
public Class<?> toIcfType(LdapSyntax syntax, String icfAttributeName) {
if (OperationalAttributeInfos.PASSWORD.is(icfAttributeName)) {
return GuardedString.class;
}
if (syntax == null) {
// We may be in a quirks mode. Server schema may not be consistent (e.g. 389ds schema).
// Therefore syntax may be null. Fall back to default in that case.
return String.class;
}
Class<?> type = null;
TypeSubType typeSubtype = SYNTAX_MAP.get( syntax.getName() );
if (typeSubtype != null) {
type = typeSubtype.type;
if (type == Date.class) {
if (AbstractLdapConfiguration.TIMESTAMP_PRESENTATION_UNIX_EPOCH.equals(getConfiguration().getTimestampPresentation())) {
type = long.class;
} else {
type = String.class;
}
}
}
if (type == null) {
LOG.warn("No type mapping for syntax {0}, using string", syntax.getName());
return String.class;
} else {
return type;
}
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:31,代码来源:AbstractSchemaTranslator.java
注:本文中的org.identityconnectors.common.security.GuardedString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论