本文整理汇总了Java中org.identityconnectors.common.Base64类的典型用法代码示例。如果您正苦于以下问题:Java Base64类的具体用法?Java Base64怎么用?Java Base64使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Base64类属于org.identityconnectors.common包,在下文中一共展示了Base64类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAttr
import org.identityconnectors.common.Base64; //导入依赖的package包/类
private <T> void addAttr(ConnectorObjectBuilder builder, String attrName, T attrVal) {
// null value or "" (empty string) we don't return
boolean isNull = false;
if (attrVal == null) {
isNull = true;
} else if (attrVal instanceof String && StringUtil.isEmpty((String) attrVal)) {
isNull = true;
}
if (!isNull) {
if (attrVal instanceof Date) {
builder.addAttribute(attrName, ((Date) attrVal).getTime());
} else if (attrVal instanceof byte[]) {
builder.addAttribute(attrName, Base64.encode((byte[]) attrVal));
} else {
builder.addAttribute(attrName, attrVal);
}
}
}
示例2: set
import org.identityconnectors.common.Base64; //导入依赖的package包/类
@PreAuthorize("hasRole('" + SCIMEntitlement.SCIM_CONF_SET + "')")
public void set(final SCIMConf conf) {
try {
schemaLogic.read(SchemaType.PLAIN, SCIMConf.KEY);
} catch (NotFoundException e) {
PlainSchemaTO scimConf = new PlainSchemaTO();
scimConf.setKey(SCIMConf.KEY);
scimConf.setType(AttrSchemaType.Binary);
scimConf.setMimeType(MediaType.APPLICATION_JSON);
schemaLogic.create(SchemaType.PLAIN, scimConf);
}
conf.setLastChangeDate(new Date());
configurationLogic.set(new AttrTO.Builder().
schema(SCIMConf.KEY).value(Base64.encode(POJOHelper.serialize(conf).getBytes())).build());
}
示例3: SimplePagedResultsSearchStrategy
import org.identityconnectors.common.Base64; //导入依赖的package包/类
public SimplePagedResultsSearchStrategy(ConnectionManager<C> connectionManager,
AbstractLdapConfiguration configuration, AbstractSchemaTranslator<C> schemaTranslator, ObjectClass objectClass,
org.apache.directory.api.ldap.model.schema.ObjectClass ldapObjectClass,
ResultsHandler handler, OperationOptions options) {
super(connectionManager, configuration, schemaTranslator, objectClass, ldapObjectClass, handler, options);
if (options != null && options.getPagedResultsCookie() != null) {
cookie = Base64.decode(options.getPagedResultsCookie());
}
}
示例4: getPagedResultsCookie
import org.identityconnectors.common.Base64; //导入依赖的package包/类
@Override
public String getPagedResultsCookie() {
if (cookie == null) {
return null;
}
return Base64.encode(cookie);
}
示例5: getConnObjectTO
import org.identityconnectors.common.Base64; //导入依赖的package包/类
/**
* Builds {@link ConnObjectTO} out of a collection of {@link Attribute} instances.
*
* @param attrs attributes
* @return transfer object
*/
public static ConnObjectTO getConnObjectTO(final Set<Attribute> attrs) {
final ConnObjectTO connObjectTO = new ConnObjectTO();
if (attrs != null) {
attrs.stream().map(attr -> {
AttrTO attrTO = new AttrTO();
attrTO.setSchema(attr.getName());
if (attr.getValue() != null) {
attr.getValue().stream().filter(value -> value != null).forEachOrdered(value -> {
if (value instanceof GuardedString || value instanceof GuardedByteArray) {
attrTO.getValues().add(getPassword(value));
} else if (value instanceof byte[]) {
attrTO.getValues().add(Base64.encode((byte[]) value));
} else {
attrTO.getValues().add(value.toString());
}
});
}
return attrTO;
}).forEach(attrTO -> {
connObjectTO.getAttrs().add(attrTO);
});
}
return connObjectTO;
}
示例6: toShortString
import org.identityconnectors.common.Base64; //导入依赖的package包/类
public static void toShortString(StringBuilder sb, Control control) {
if (control == null) {
return;
}
if (control instanceof PagedResults) {
sb.append("PagedResults(size=");
sb.append(((PagedResults)control).getSize());
sb.append(", cookie=");
byte[] cookie = ((PagedResults)control).getCookie();
if (cookie == null) {
sb.append("null");
} else {
sb.append(Base64.encode(cookie));
}
sb.append("),");
} else if (control instanceof VirtualListViewRequest) {
sb.append("VLV(beforeCount=");
sb.append(((VirtualListViewRequest)control).getBeforeCount());
sb.append(", afterCount=");
sb.append(((VirtualListViewRequest)control).getAfterCount());
sb.append(", offset=");
sb.append(((VirtualListViewRequest)control).getOffset());
sb.append(", contentCount=");
sb.append(((VirtualListViewRequest)control).getContentCount());
sb.append(", contextID=");
byte[] contextId = ((VirtualListViewRequest)control).getContextId();
if (contextId == null) {
sb.append("null");
} else {
sb.append(Base64.encode(contextId));
}
sb.append("),");
} else if (control instanceof SortRequest) {
sb.append("Sort(");
for (SortKey sortKey: ((SortRequest)control).getSortKeys()) {
sb.append(sortKey.getAttributeTypeDesc());
sb.append(":");
sb.append(sortKey.getMatchingRuleId());
sb.append(":");
if (sortKey.isReverseOrder()) {
sb.append("D");
} else {
sb.append("A");
}
sb.append("),");
}
} else {
String controlDesc = null;
Class<? extends Control> controlClass = control.getClass();
Class<?>[] interfaces = controlClass.getInterfaces();
if (interfaces != null) {
for (Class<?> iface: interfaces) {
if (iface.getPackage().getName().startsWith("org.apache.directory.api")) {
controlDesc = iface.getSimpleName();
break;
}
}
}
if (controlDesc == null) {
controlDesc = controlClass.getName();
}
sb.append(controlDesc);
}
}
示例7: createSearchRequest
import org.identityconnectors.common.Base64; //导入依赖的package包/类
private SearchRequest createSearchRequest(String searchFilter, SyncToken fromToken) {
AdDirSync dirSyncReqControl = new AdDirSyncImpl();
dirSyncReqControl.setCritical(true);
byte[] cookie = null;
if (fromToken != null) {
Object tokenValue = fromToken.getValue();
if (tokenValue instanceof String) {
if (StringUtils.isNotBlank((String) tokenValue)) {
cookie = Base64.decode((String) tokenValue);
}
} else if (tokenValue instanceof byte[]) {
cookie = (byte[]) tokenValue;
} else {
throw new IllegalArgumentException("Unexpected type of sync token: "+tokenValue.getClass());
}
dirSyncReqControl.setCookie(cookie);
}
String baseContext = getConfiguration().getBaseContext();
// Always leave attribute list to default.
// AD does not seem to understand expression such as "* objectGUID" in DirSync
String[] attributesToGet = new String[0];
if (LOG.isOk()) {
LOG.ok("Searching DN {0} with {1}, attrs: {2}, cookie: {3}",
baseContext, searchFilter, Arrays.toString(attributesToGet),
cookie==null?null:Base64.encode(cookie));
}
SearchRequest req = new SearchRequestImpl();
try {
req.setBase(new Dn(baseContext));
req.setFilter(searchFilter);
req.setScope(SearchScope.SUBTREE);
req.addAttributes(attributesToGet);
req.addControl(dirSyncReqControl);
} catch (LdapException e) {
throw new IllegalStateException("Error constructing search request: "+e.getMessage(), e);
}
return req;
}
示例8: hashBytes
import org.identityconnectors.common.Base64; //导入依赖的package包/类
private String hashBytes(byte[] clear, String alg, long seed) {
MessageDigest md = null;
try {
if (alg.equalsIgnoreCase("SSHA") || alg.equalsIgnoreCase("SHA")) {
md = MessageDigest.getInstance("SHA-1");
} else if ( alg.equalsIgnoreCase("SMD5") || alg.equalsIgnoreCase("MD5") ) {
md = MessageDigest.getInstance("MD5");
}
} catch (NoSuchAlgorithmException e) {
throw new ConnectorException("Could not find MessageDigest algorithm: "+alg);
}
if (md == null) {
throw new ConnectorException("Unsupported MessageDigest algorithm: " + alg);
}
byte[] salt = {};
if (alg.equalsIgnoreCase("SSHA") || alg.equalsIgnoreCase("SMD5")) {
Random rnd = new Random();
rnd.setSeed(System.currentTimeMillis() + seed);
salt = new byte[8];
rnd.nextBytes(salt);
}
md.reset();
md.update(clear);
md.update(salt);
byte[] hash = md.digest();
byte[] hashAndSalt = new byte[hash.length + salt.length];
System.arraycopy(hash, 0, hashAndSalt, 0, hash.length);
System.arraycopy(salt, 0, hashAndSalt, hash.length, salt.length);
StringBuilder resSb = new StringBuilder(alg.length() + hashAndSalt.length);
resSb.append('{');
resSb.append(alg);
resSb.append('}');
resSb.append(Base64.encode(hashAndSalt));
return resSb.toString();
}