use of org.wso2.carbon.security.keystore.service.CertData in project carbon-identity-framework by wso2.
the class KeyStoreManagementServiceImpl method getAliasList.
private List<String> getAliasList(KeyStoreData keyStoreData) {
List<String> aliasList = new ArrayList<>();
CertData key = keyStoreData.getKey();
if (key != null && key.getAlias() != null) {
aliasList.add(key.getAlias());
}
CertData[] certDataArray = keyStoreData.getCerts();
for (CertData certData : certDataArray) {
String alias = certData.getAlias();
if (alias != null) {
aliasList.add(alias);
}
}
return aliasList;
}
use of org.wso2.carbon.security.keystore.service.CertData in project carbon-identity-framework by wso2.
the class IdentityApplicationManagementUtil method fillCertData.
/**
* @param cert
* @param formatter
* @return
* @throws CertificateEncodingException
*/
private static CertData fillCertData(X509Certificate cert, Format formatter) throws CertificateEncodingException {
CertData certData = new CertData();
certData.setSubjectDN(cert.getSubjectDN().getName());
certData.setIssuerDN(cert.getIssuerDN().getName());
certData.setSerialNumber(cert.getSerialNumber());
certData.setVersion(cert.getVersion());
certData.setNotAfter(formatter.format(cert.getNotAfter()));
certData.setNotBefore(formatter.format(cert.getNotBefore()));
certData.setPublicKey(Base64.encode(cert.getPublicKey().getEncoded()));
return certData;
}
use of org.wso2.carbon.security.keystore.service.CertData in project carbon-identity-framework by wso2.
the class IdentityApplicationManagementUtil method getCertDataArray.
/**
* Generate CertData array
*
* @param certificateInfo array of certificate info
* @return CertData array
* @throws CertificateException
*/
public static List<CertData> getCertDataArray(CertificateInfo[] certificateInfo) throws CertificateException {
if (ArrayUtils.isNotEmpty(certificateInfo)) {
List<CertData> certDataList = new ArrayList<>();
HashMap<CertData, String> certDataMap = new HashMap<>();
int i = 0;
for (CertificateInfo certificateInfoVal : certificateInfo) {
String certVal = certificateInfoVal.getCertValue();
CertData certData = createCertData(certVal);
certDataList.add(certData);
certDataMap.put(certData, certVal);
i++;
}
setCertDataMap(certDataMap);
return certDataList;
} else {
String errorMsg = "Certificate info array is empty";
if (log.isDebugEnabled()) {
log.debug(errorMsg);
}
throw new IllegalArgumentException(errorMsg);
}
}
use of org.wso2.carbon.security.keystore.service.CertData in project carbon-identity-framework by wso2.
the class Util method doFilter.
public static CertData[] doFilter(String filter, CertData[] certDataSet) {
if (certDataSet == null || certDataSet.length == 0) {
return new CertData[0];
}
String regPattern = filter.replace("*", ".*");
List<CertData> list = new ArrayList<>();
for (CertData cert : certDataSet) {
if (cert != null && cert.getAlias().toLowerCase().matches(regPattern.toLowerCase())) {
list.add(cert);
}
}
return list.toArray(new CertData[list.size()]);
}
use of org.wso2.carbon.security.keystore.service.CertData in project carbon-identity-framework by wso2.
the class KeyStoreAdmin method doPaging.
/**
* This method is used internally to do the pagination purposes.
*
* @param pageNumber page Number
* @param certDataSet set of keyStoreData
* @return PaginatedPolicySetDTO object containing the number of pages and the set of policies
* that reside in the given page.
*/
private PaginatedCertData doPaging(int pageNumber, CertData[] certDataSet) {
PaginatedCertData paginatedCertData = new PaginatedCertData();
if (certDataSet.length == 0) {
paginatedCertData.setCertDataSet(new CertData[0]);
return paginatedCertData;
}
int itemsPerPageInt = SecurityConstants.ITEMS_PER_PAGE;
int numberOfPages = (int) Math.ceil((double) certDataSet.length / itemsPerPageInt);
if (pageNumber > numberOfPages - 1) {
pageNumber = numberOfPages - 1;
}
int startIndex = pageNumber * itemsPerPageInt;
int endIndex = (pageNumber + SecurityConstants.CACHING_PAGE_SIZE) * itemsPerPageInt;
CertData[] returnedCertDataSet = new CertData[itemsPerPageInt * SecurityConstants.CACHING_PAGE_SIZE];
for (int i = startIndex, j = 0; i < endIndex && i < certDataSet.length; i++, j++) {
returnedCertDataSet[j] = certDataSet[i];
}
paginatedCertData.setCertDataSet(returnedCertDataSet);
paginatedCertData.setNumberOfPages(numberOfPages);
return paginatedCertData;
}
Aggregations