org.wso2.carbon.registry.core.utils.UUIDGenerator.generateUUID()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(17.0k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.wso2.carbon.registry.core.utils.UUIDGenerator.generateUUID()方法的一些代码示例,展示了UUIDGenerator.generateUUID()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UUIDGenerator.generateUUID()方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.utils.UUIDGenerator
类名称:UUIDGenerator
方法名:generateUUID

UUIDGenerator.generateUUID介绍

暂无

代码示例

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

/**
 * Method generates and returns UUID
 * @return UUID
 */
public String generateUUID(){
  String UUID = UUIDGenerator.generateUUID();
  return UUID;
}

代码示例来源:origin: org.wso2.carbon.identity.governance/org.wso2.carbon.identity.recovery

protected void initNotification(User user, Enum recoveryScenario, Enum recoveryStep, String notificationType) throws IdentityEventException {
    String secretKey = UUIDGenerator.generateUUID();
    initNotification(user, recoveryScenario, recoveryStep, notificationType, secretKey);
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.activities.ui

public ActivityBean getActivities(HttpServletRequest request) {
  String sessionId = UUIDGenerator.generateUUID();
  String userName = request.getParameter("userName");
  String resourcePath = request.getParameter("path");
  String fromDate = request.getParameter("fromDate");
  String toDate = request.getParameter("toDate");
  String filter = request.getParameter("filter");
  String pageStr = request.getParameter("page");
  try {
    return proxy.getActivities(userName, resourcePath, fromDate, toDate, filter, pageStr,
        sessionId);
  } catch (Exception e) {
    String msg = "Failed to get activities from the activity service.";
    log.error(msg, e);
    return null;
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.activities.ui

public ActivityBean getRecentActivitiesForLoginUser(HttpServletRequest request) {
  String sessionId = UUIDGenerator.generateUUID();
  String LOGGED_USER = "logged-user";
  String userName = (String)request.getSession().getAttribute(LOGGED_USER);
  String resourcePath = null;
  String fromDate = null;
  String toDate = null;
  String filter = "all";
  String pageStr = "1";
  try {
    return proxy.getActivities(userName, resourcePath, fromDate, toDate, filter, pageStr,
        sessionId);
  } catch (Exception e) {
    String msg = "Failed to get activities from the activity service.";
    log.error(msg, e);
    return null;
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.user.account.association

/**
 * Generate random number for association key
 *
 * @return random number
 * @throws org.wso2.carbon.identity.user.account.association.exception.UserAccountAssociationException
 */
public static String getRandomNumber() throws UserAccountAssociationException {
  try {
    String secretKey = UUIDGenerator.generateUUID();
    String baseString = UUIDGenerator.generateUUID();
    SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
    Mac mac = Mac.getInstance("HmacSHA1");
    mac.init(key);
    byte[] rawHmac = mac.doFinal(baseString.getBytes());
    String random = Base64.encode(rawHmac);
    random = random.replace("/", "_");
    random = random.replace("=", "a");
    random = random.replace("+", "f");
    return random;
  } catch (Exception e) {
    throw new UserAccountAssociationException("Error when generating a random number.", e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.oauth2/org.wso2.carbon.identity.oauth

/**
 * Generates a random number using two UUIDs and HMAC-SHA1
 *
 * @return generated secure random number
 * @throws IdentityOAuthAdminException Invalid Algorithm or Invalid Key
 */
public static String getRandomNumber() throws IdentityOAuthAdminException {
  try {
    String secretKey = UUIDGenerator.generateUUID();
    String baseString = UUIDGenerator.generateUUID();
    SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(Charsets.UTF_8), ALGORITHM);
    Mac mac = Mac.getInstance(ALGORITHM);
    mac.init(key);
    byte[] rawHmac = mac.doFinal(baseString.getBytes(Charsets.UTF_8));
    String random = Base64.encode(rawHmac);
    // Registry doesn't have support for these character.
    random = random.replace("/", "_");
    random = random.replace("=", "a");
    random = random.replace("+", "f");
    return random;
  } catch (Exception e) {
    throw new IdentityOAuthAdminException("Error when generating a random number.", e);
  }
}

代码示例来源:origin: org.wso2.carbon.extension.identity.authenticator/org.wso2.carbon.extension.identity.sso.cas

public static String generate(String prefix) {
    String verifiedPrefix = (prefix != null) ? prefix : "UNKOWN";
    return verifiedPrefix + "-" + UUIDGenerator.generateUUID().replaceAll("-", "") + "-" +
        ServerConfiguration.getInstance().getFirstProperty("HostName");
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.oauth

/**
 * Generates a random number using two UUIDs and HMAC-SHA1
 *
 * @return generated secure random number
 * @throws IdentityOAuthAdminException Invalid Algorithm or Invalid Key
 */
public static String getRandomNumber() throws IdentityOAuthAdminException {
  try {
    String secretKey = UUIDGenerator.generateUUID();
    String baseString = UUIDGenerator.generateUUID();
    SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(Charsets.UTF_8), ALGORITHM);
    Mac mac = Mac.getInstance(ALGORITHM);
    mac.init(key);
    byte[] rawHmac = mac.doFinal(baseString.getBytes(Charsets.UTF_8));
    String random = Base64.encode(rawHmac);
    // Registry doesn't have support for these character.
    random = random.replace("/", "_");
    random = random.replace("=", "a");
    random = random.replace("+", "f");
    return random;
  } catch (Exception e) {
    throw new IdentityOAuthAdminException("Error when generating a random number.", e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.core

/**
 * Generates a random number using two UUIDs and HMAC-SHA1
 *
 * @return Random Number generated.
 * @throws IdentityException Exception due to Invalid Algorithm or Invalid Key
 */
public static String getRandomNumber() throws IdentityException {
  try {
    String secretKey = UUIDGenerator.generateUUID();
    String baseString = UUIDGenerator.generateUUID();
    SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
    Mac mac = Mac.getInstance("HmacSHA1");
    mac.init(key);
    byte[] rawHmac = mac.doFinal(baseString.getBytes());
    String random = Base64.encode(rawHmac);
    // Registry doesn't have support for these character.
    random = random.replace("/", "_");
    random = random.replace("=", "a");
    random = random.replace("+", "f");
    return random;
  } catch (Exception e) {
    log.error("Error when generating a random number.", e);
    throw IdentityException.error("Error when generating a random number.", e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.core

/**
 * Generates a random number using two UUIDs and HMAC-SHA1
 *
 * @return Random Number generated.
 * @throws IdentityException Exception due to Invalid Algorithm or Invalid Key
 */
public static String getRandomNumber() throws IdentityException {
  try {
    String secretKey = UUIDGenerator.generateUUID();
    String baseString = UUIDGenerator.generateUUID();
    SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
    Mac mac = Mac.getInstance("HmacSHA1");
    mac.init(key);
    byte[] rawHmac = mac.doFinal(baseString.getBytes());
    String random = Base64.encode(rawHmac);
    // Registry doesn't have support for these character.
    random = random.replace("/", "_");
    random = random.replace("=", "a");
    random = random.replace("+", "f");
    return random;
  } catch (Exception e) {
    log.error("Error when generating a random number.", e);
    throw IdentityException.error("Error when generating a random number.", e);
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

/**
 * Generates a random number using two UUIDs and HMAC-SHA1
 *
 * @return Random Number generated.
 * @throws IdentityException Exception due to Invalid Algorithm or Invalid Key
 */
public static String getRandomNumber() throws IdentityException {
  try {
    String secretKey = UUIDGenerator.generateUUID();
    String baseString = UUIDGenerator.generateUUID();
    SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
    Mac mac = Mac.getInstance("HmacSHA1");
    mac.init(key);
    byte[] rawHmac = mac.doFinal(baseString.getBytes());
    String random = Base64.encode(rawHmac);
    // Registry doesn't have support for these character.
    random = random.replace("/", "_");
    random = random.replace("=", "a");
    random = random.replace("+", "f");
    return random;
  } catch (Exception e) {
    log.error("Error when generating a random number.", e);
    throw IdentityException.error("Error when generating a random number.", e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provisioning.connector.salesforce

/**
   * Alter username while changing user to active state to inactive state. This is necessary when adding previously
   * deleted users.
   *
   * @param provisioningEntity
   * @return
   * @throws IdentityProvisioningException
   */
  protected String alterUsername(ProvisioningEntity provisioningEntity) throws IdentityProvisioningException {

    if (StringUtils.isBlank(provisioningEntity.getEntityName())) {
      throw new IdentityProvisioningException("Could Not Find Entity Name from Provisioning Entity");
    }
    String alteredUsername = SalesforceConnectorConstants.SALESFORCE_OLD_USERNAME_PREFIX +
                  UUIDGenerator.generateUUID() + provisioningEntity.getEntityName();

    if (log.isDebugEnabled()) {
      log.debug("Alter username: " + provisioningEntity.getEntityName() + " to: " + alteredUsername +
           "while deleting user");
    }
    return alteredUsername;
  }
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.application.authentication.framework

private void setPASTRCookie(AuthenticationContext context, HttpServletRequest request,
    HttpServletResponse response) {
  if (context.getParameter(FrameworkConstants.PASTR_COOKIE) != null) {
    if (log.isDebugEnabled()) {
      log.debug("PASTR cookie is already set to context : " + context.getContextIdentifier());
    }
    return;
  } else {
    if (log.isDebugEnabled()) {
      log.debug(
          "PASTR cookie is not set to context : " + context.getContextIdentifier() + ". Hence setting the"
              + " " + "cookie");
    }
    String pastrCookieValue = UUIDGenerator.generateUUID();
    FrameworkUtils
        .setCookie(request, response, FrameworkUtils.getPASTRCookieName(context.getContextIdentifier()),
            pastrCookieValue, -1);
    context.addParameter(FrameworkConstants.PASTR_COOKIE, pastrCookieValue);
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

private void setPASTRCookie(AuthenticationContext context, HttpServletRequest request,
    HttpServletResponse response) {
  if (context.getParameter(FrameworkConstants.PASTR_COOKIE) != null) {
    if (log.isDebugEnabled()) {
      log.debug("PASTR cookie is already set to context : " + context.getContextIdentifier());
    }
    return;
  } else {
    if (log.isDebugEnabled()) {
      log.debug(
          "PASTR cookie is not set to context : " + context.getContextIdentifier() + ". Hence setting the"
              + " " + "cookie");
    }
    String pastrCookieValue = UUIDGenerator.generateUUID();
    FrameworkUtils
        .setCookie(request, response, FrameworkUtils.getPASTRCookieName(context.getContextIdentifier()),
            pastrCookieValue, -1);
    context.addParameter(FrameworkConstants.PASTR_COOKIE, pastrCookieValue);
  }
}

代码示例来源:origin: org.apache.stratos/org.apache.stratos.throttling.manager

private static void initializeScheduling(Task throttlingTask) {
  // generate tasks
  if (throttlingTask.getTriggerInterval() < 0) {
    log.info("Throttling manager Validation info service Disabled");
  } else {
    String taskName = UUIDGenerator.generateUUID();
    String groupId = UUIDGenerator.generateUUID();
    TaskDescription taskDescription = new TaskDescription();
    taskDescription.setName(taskName);
    taskDescription.setGroup(groupId);
    // we are triggering only at the period
    taskDescription.setInterval(throttlingTask.getTriggerInterval());
    //Delay first run by given minutes
    Calendar startTime = Calendar.getInstance();
    startTime.add(Calendar.MILLISECOND, throttlingTask.getStartDelayInterval());
    taskDescription.setStartTime(startTime.getTime());
    Map<String, Object> resources = new HashMap<String, Object>();
    resources.put(ThrottlingJob.THROTTLING_TASK_CONTEXT_KEY, throttlingTask);
    TaskScheduler taskScheduler = TaskSchedulerFactory.getTaskScheduler(THROTTLING_TASK_ID);
    if (!taskScheduler.isInitialized()) {
      Properties properties = new Properties();
      taskScheduler.init(properties);
    }
    taskScheduler.scheduleTask(taskDescription, resources, ThrottlingJob.class);
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.mgt

public VerificationBean updateConfirmationCode(int sequence, String username, int tenantId)
    throws IdentityException {
  String confirmationKey = generateUserCode(sequence, username);
  String secretKey = UUIDGenerator.generateUUID();
  UserRecoveryDataDO recoveryDataDO = new UserRecoveryDataDO(username,
      tenantId, confirmationKey, secretKey);
  if (sequence != 3 && sequence != 30) {
    dataStore.invalidate(username, tenantId);
  }
  dataStore.store(recoveryDataDO);
  String externalCode = null;
  try {
    externalCode = getUserExternalCodeStr(confirmationKey);
  } catch (Exception e) {
    throw IdentityException.error("Error occurred while getting external code for user : "
        + username, e);
  }
  return new VerificationBean(username, externalCode);
}

代码示例来源:origin: wso2/carbon-identity-framework

public VerificationBean updateConfirmationCode(int sequence, String username, int tenantId)
    throws IdentityException {
  String confirmationKey = generateUserCode(sequence, username);
  String secretKey = UUIDGenerator.generateUUID();
  UserRecoveryDataDO recoveryDataDO = new UserRecoveryDataDO(username,
      tenantId, confirmationKey, secretKey);
  if (sequence != 3 && sequence != 30) {
    dataStore.invalidate(username, tenantId);
  }
  dataStore.store(recoveryDataDO);
  String externalCode = null;
  try {
    externalCode = getUserExternalCodeStr(confirmationKey);
  } catch (Exception e) {
    throw IdentityException.error("Error occurred while getting external code for user : "
        + username, e);
  }
  return new VerificationBean(username, externalCode);
}

代码示例来源:origin: org.wso2.carbon.identity.governance/org.wso2.carbon.identity.recovery

private NotificationResponseBean validateAndResendNotification(User user, String code, String recoveryScenario,
                                String recoveryStep, String notificationType,
                                Property[] properties)
    throws IdentityRecoveryException {
  validateProvidedRecoveryInfo(user, recoveryScenario, recoveryStep);
  validateProvidedNotificationInfo(user, notificationType);
  setTenantDomainForUser(user);
  setUserStoreDomainForUser(user);
  boolean notificationInternallyManage = isNotificationInternallyManage(user);
  NotificationResponseBean notificationResponseBean = new NotificationResponseBean(user);
  String secretKey = UUIDGenerator.generateUUID();
  validateAndStoreRecoveryData(user, secretKey, recoveryScenario, recoveryStep, code);
  if (notificationInternallyManage) {
    triggerNotification(user, notificationType, secretKey, properties);
  } else {
    notificationResponseBean.setKey(secretKey);
  }
  return notificationResponseBean;
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.sts/org.wso2.carbon.identity.sts.passive.ui

private void handleAuthenticationRequest(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  Map paramMap = request.getParameterMap();
  SessionDTO sessionDTO = new SessionDTO();
  sessionDTO.setAction(getAttribute(paramMap, PassiveRequestorConstants.ACTION));
  sessionDTO.setAttributes(getAttribute(paramMap, PassiveRequestorConstants.ATTRIBUTE));
  sessionDTO.setContext(getAttribute(paramMap, PassiveRequestorConstants.CONTEXT));
  sessionDTO.setReplyTo(getAttribute(paramMap, PassiveRequestorConstants.REPLY_TO));
  sessionDTO.setPseudo(getAttribute(paramMap, PassiveRequestorConstants.PSEUDO));
  sessionDTO.setRealm(getAttribute(paramMap, PassiveRequestorConstants.REALM));
  sessionDTO.setRequest(getAttribute(paramMap, PassiveRequestorConstants.REQUEST));
  sessionDTO.setRequestPointer(getAttribute(paramMap, PassiveRequestorConstants.REQUEST_POINTER));
  sessionDTO.setPolicy(getAttribute(paramMap, PassiveRequestorConstants.POLCY));
  sessionDTO.setTenantDomain(getAttribute(paramMap, MultitenantConstants.TENANT_DOMAIN));
  sessionDTO.setReqQueryString(request.getQueryString());
  String sessionDataKey = UUIDGenerator.generateUUID();
  addSessionDataToCache(sessionDataKey, sessionDTO);
  sendToAuthenticationFramework(request, response, sessionDataKey, sessionDTO);
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sts.passive.ui

private void handleAuthenticationRequest(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  Map paramMap = request.getParameterMap();
  SessionDTO sessionDTO = new SessionDTO();
  sessionDTO.setAction(getAttribute(paramMap, PassiveRequestorConstants.ACTION));
  sessionDTO.setAttributes(getAttribute(paramMap, PassiveRequestorConstants.ATTRIBUTE));
  sessionDTO.setContext(getAttribute(paramMap, PassiveRequestorConstants.CONTEXT));
  sessionDTO.setReplyTo(getAttribute(paramMap, PassiveRequestorConstants.REPLY_TO));
  sessionDTO.setPseudo(getAttribute(paramMap, PassiveRequestorConstants.PSEUDO));
  sessionDTO.setRealm(getAttribute(paramMap, PassiveRequestorConstants.REALM));
  sessionDTO.setRequest(getAttribute(paramMap, PassiveRequestorConstants.REQUEST));
  sessionDTO.setRequestPointer(getAttribute(paramMap, PassiveRequestorConstants.REQUEST_POINTER));
  sessionDTO.setPolicy(getAttribute(paramMap, PassiveRequestorConstants.POLCY));
  sessionDTO.setTenantDomain(getAttribute(paramMap, MultitenantConstants.TENANT_DOMAIN));
  sessionDTO.setReqQueryString(request.getQueryString());
  String sessionDataKey = UUIDGenerator.generateUUID();
  addSessionDataToCache(sessionDataKey, sessionDTO);
  sendToAuthenticationFramework(request, response, sessionDataKey, sessionDTO);
}

相关文章

微信公众号

最新文章

更多

UUIDGenerator类方法