org.wso2.carbon.registry.core.utils.UUIDGenerator类的使用及代码示例

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

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

UUIDGenerator介绍

暂无

代码示例

代码示例来源: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.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider

String sessionDataKey = UUIDGenerator.generateUUID();

代码示例来源: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.governance/org.wso2.carbon.identity.recovery

OTP = UUIDGenerator.generateUUID();
recoveryScenario = RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_EMAIL_LINK;
notificationType = IdentityRecoveryConstants.NOTIFICATION_TYPE_ADMIN_FORCED_PASSWORD_RESET

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

String contextId = UUIDGenerator.generateUUID();
context.setContextIdentifier(contextId);

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

String contextId = UUIDGenerator.generateUUID();
context.setContextIdentifier(contextId);

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

sessionDTO.setReqQueryString(request.getQueryString());
String sessionDataKey = UUIDGenerator.generateUUID();
addSessionDataToCache(sessionDataKey, sessionDTO);
String commonAuthURL = IdentityUtil.getServerURL(FrameworkConstants.COMMONAUTH, false, true);

相关文章

微信公众号

最新文章

更多

UUIDGenerator类方法