@PreAuthorize("hasRole('" + OIDCClientEntitlement.OP_READ + "')") @Transactional(readOnly = true) public OIDCProviderTO read(final String key) { OIDCProvider op = opDAO.find(key); if (op == null) { throw new NotFoundException("OIDC Provider '" + key + "'"); } return binder.getOIDCProviderTO(op); }
@PreAuthorize("hasRole('" + OIDCClientEntitlement.OP_UPDATE + "')") public void update(final OIDCProviderTO oidcProviderTO) { OIDCProvider oidcProvider = opDAO.find(oidcProviderTO.getKey()); if (oidcProvider == null) { throw new NotFoundException("OIDC Provider '" + oidcProviderTO.getKey() + "'"); } if (!oidcProvider.getIssuer().equals(oidcProviderTO.getIssuer())) { LOG.error("Issuers do not match: expected {}, found {}", oidcProvider.getIssuer(), oidcProviderTO.getIssuer()); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidEntity); sce.getElements().add("Issuers do not match"); throw sce; } opDAO.save(binder.update(oidcProvider, oidcProviderTO)); }
@PreAuthorize("hasRole('" + OIDCClientEntitlement.OP_CREATE + "')") public String create(final OIDCProviderTO opTO) { if (opTO.getConnObjectKeyItem() == null) { ItemTO connObjectKeyItem = new ItemTO(); connObjectKeyItem.setIntAttrName("username"); connObjectKeyItem.setExtAttrName("email"); opTO.setConnObjectKeyItem(connObjectKeyItem); } OIDCProvider provider = opDAO.save(binder.create(opTO)); return provider.getKey(); }
@Override protected OIDCProviderTO resolveReference( final Method method, final Object... args) throws UnresolvedReferenceException { String key = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; key == null && i < args.length; i++) { if (args[i] instanceof String) { key = (String) args[i]; } else if (args[i] instanceof OIDCProviderTO) { key = ((OIDCProviderTO) args[i]).getKey(); } } } if (key != null) { try { return binder.getOIDCProviderTO(opDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); } }