Exemplo n.º 1
0
  public static Date rptExpirationDate() {
    int lifeTime =
        ConfigurationFactory.instance().getConfiguration().getUmaRequesterPermissionTokenLifetime();
    if (lifeTime <= 0) {
      lifeTime = DEFAULT_PERMISSION_LIFETIME;
    }

    final Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.SECOND, lifeTime);
    return calendar.getTime();
  }
Exemplo n.º 2
0
  private void handleExternalScopes(List<String> p_scopeUrls, List<String> result)
      throws LDAPException {
    for (String scopeUrl : p_scopeUrls) {
      final Filter filter = Filter.create(String.format("&(oxUrl=%s)", scopeUrl));
      final List<ScopeDescription> entries =
          ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
      if (entries != null && !entries.isEmpty()) {
        result.add(entries.get(0).getDn());
      } else { // scope is not in ldap, add it dynamically

        final Boolean addAutomatically =
            ConfigurationFactory.instance().getConfiguration().getUmaAddScopesAutomatically();

        if (addAutomatically != null && addAutomatically) {
          final String inum = inumService.generateInum();
          final ScopeDescription newScope = new ScopeDescription();
          newScope.setInum(inum);
          newScope.setUrl(scopeUrl);
          newScope.setDisplayName(
              scopeUrl); // temp solution : need extract info from scope description on resource
                         // server
          newScope.setId(
              UmaScopeType.EXTERNAL_AUTO
                  .getValue()); // dummy id : not sure what to put right now as id is required by
                                // @NotNull annotation
          newScope.setType(InternalExternal.EXTERNAL_AUTO);

          final boolean persisted = persist(newScope);
          if (persisted) {
            result.add(newScope.getDn());
          }
        } else {
          throw new WebApplicationException(
              Response.status(Response.Status.BAD_REQUEST)
                  .entity(
                      errorResponseFactory.getUmaJsonErrorResponse(
                          UmaErrorResponseType.INVALID_RESOURCE_SET_SCOPE))
                  .build());
        }
      }
    }
  }
Exemplo n.º 3
0
 public static String baseDn() {
   return String.format("ou=scopes,%s", ConfigurationFactory.instance().getBaseDn().getUmaBase());
 }
Exemplo n.º 4
0
 private static String getScopeEndpoint() {
   return ConfigurationFactory.instance().getConfiguration().getBaseEndpoint()
       + UmaConfigurationWS.UMA_SCOPES_SUFFIX;
 }