List of usage examples for java.security Principal getName
public String getName();
From source file:com.epam.ta.reportportal.ws.controller.impl.UserFilterController.java
@Override @RequestMapping(method = RequestMethod.PUT) @ResponseBody/*from ww w .j a va2 s. c o m*/ @ResponseStatus(HttpStatus.OK) @ApiOperation("Update list of user filters") public List<OperationCompletionRS> updateUserFilters(@PathVariable String projectName, @RequestBody @Validated CollectionsRQ<BulkUpdateFilterRQ> updateRQ, Principal principal) { return updateUserFilterHandler.updateUserFilter(updateRQ, principal.getName(), EntityUtils.normalizeProjectName(projectName)); }
From source file:alfio.controller.api.admin.ConfigurationApiController.java
@RequestMapping(value = "/configuration/events/{eventId}/categories/{categoryId}/load", method = GET) public Map<ConfigurationKeys.SettingCategory, List<Configuration>> loadCategoryConfiguration( @PathVariable("eventId") int eventId, @PathVariable("categoryId") int categoryId, Principal principal) { return configurationManager.loadCategoryConfig(eventId, categoryId, principal.getName()); }
From source file:alfio.controller.api.admin.ConfigurationApiController.java
@RequestMapping(value = "/configuration/event/{eventId}/key/{key}", method = DELETE) public boolean deleteEventLevelKey(@PathVariable("eventId") int eventId, @PathVariable("key") ConfigurationKeys key, Principal principal) { configurationManager.deleteEventLevelByKey(key.getValue(), eventId, principal.getName()); return true;//from w w w . jav a2 s . co m }
From source file:com.deepsky.spring_security.samples.ServletApiController.java
/** * Demonstrate handing of Access Denied which may happen if user has not appropriate role * @param user//from ww w .ja v a 2 s . c o m * @return */ @RequestMapping(value = "/403", method = RequestMethod.GET) public ModelAndView accessDenied(Principal user) { ModelAndView model = new ModelAndView(); if (user != null) { model.addObject("msg", "Hi " + user.getName() + ", you do not have permission to access this page!"); } else { model.addObject("msg", "You do not have permission to access this page!"); } model.setViewName("403"); return model; }
From source file:io.gravitee.management.service.impl.PermissionServiceImpl.java
@Override public void hasPermission(Principal principal, String item, PermissionType permissionType) { if (principal != null) { final UserEntity user = userService.findByName(principal.getName()); if (user != null && user.getRoles().contains("ADMIN")) { LOGGER.debug("User {} has full access because of admin role", principal.getName()); return; }/*from w ww. jav a 2 s .c o m*/ } if (permissionType == PermissionType.VIEW_API || permissionType == PermissionType.EDIT_API) { validateApi(principal, item, permissionType); } else if (permissionType == PermissionType.VIEW_APPLICATION || permissionType == PermissionType.EDIT_APPLICATION) { validateApplication(principal, item, permissionType); } }
From source file:org.apache.hadoop.gateway.hive.HiveHttpClientDispatch.java
protected void addCredentialsToRequest(HttpUriRequest request) { if (isBasicAuthPreemptive()) { Principal principal = getPrimaryPrincipal(); if (principal != null) { UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(principal.getName(), PASSWORD_PLACEHOLDER); request.addHeader(BasicScheme.authenticate(credentials, "US-ASCII", false)); }/*w w w . j a v a 2s .com*/ } }
From source file:org.bombusim.networking.NetworkSocketDataStream.java
public void setTLS() throws IOException { LimeLog.i("Socket", "Switching to secure socket layer", null); //TODO: check on different devices: // !!! ENSURE TLS enabled in account settings before test // 1. emulator/2.2 - SSLPeerUnverifiedException (jabber.ru, google.com) - bug in emulator v2.2 // 2. cyanogen/2.3 - works (all hosts) // 3. emulator/ics - works // 4. Gratia/2.2 - works SSLSocketFactory sf =/*from w ww .j a va2 s. c o m*/ //SSLCertificateSocketFactory.getDefault(20000, null); SSLCertificateSocketFactory.getInsecure(20000, null); //TODO: check on different devices: // 1. emulator/2.2 - works // 2. cyanogen/2.3 - works //KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); //trustStore.load(null, null); //SSLSocketFactory sf = new AndroidSSLSocketFactory(trustStore); //sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); final SSLSocket ssls = (SSLSocket) sf.createSocket(socket, host, port, true); ssls.addHandshakeCompletedListener(new HandshakeCompletedListener() { @Override public void handshakeCompleted(HandshakeCompletedEvent event) { X509Certificate[] certs; try { certs = ssls.getSession().getPeerCertificateChain(); } catch (SSLPeerUnverifiedException e) { return; } StringBuilder so = new StringBuilder(); for (X509Certificate cert : certs) { so.append("X509 Certificate:\n").append(" Subject:"); appendPrincipal(so, cert.getSubjectDN()); so.append("\n Issued by:"); appendPrincipal(so, cert.getIssuerDN()); so.append("\n Valid from: ").append(DateFormat.getInstance().format(cert.getNotBefore())); so.append("\n Expired after: ").append(DateFormat.getInstance().format(cert.getNotAfter())); so.append("\n\n"); } certificateInfo = so.toString(); LimeLog.i("Socket", "Certificate chain verified", certificateInfo); } private void appendPrincipal(StringBuilder so, Principal p) { String name = p.getName(); if (name == null) { so.append("<null>\n"); return; } String elements[] = name.split(","); for (String e : elements) { so.append("\n ").append(e); } so.append("\n"); } }); ssls.startHandshake(); socket = ssls; istream = socket.getInputStream(); ostream = socket.getOutputStream(); }
From source file:alfio.controller.api.admin.AdminReservationApiController.java
@RequestMapping(value = "/event/{eventName}/{reservationId}/notify", method = RequestMethod.PUT) public Result<Boolean> notifyReservation(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId, @RequestBody AdminReservationModification arm, Principal principal) { return adminReservationManager.notify(eventName, reservationId, arm, principal.getName()); }
From source file:alfio.controller.api.admin.ConfigurationApiController.java
@RequestMapping(value = "/configuration/load", method = GET) public Map<ConfigurationKeys.SettingCategory, List<Configuration>> loadConfiguration(Principal principal) { return configurationManager.loadAllSystemConfigurationIncludingMissing(principal.getName()); }
From source file:com.epam.ta.reportportal.ws.controller.impl.WidgetController.java
@Override @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/*from w ww. j a v a 2s. c om*/ @ResponseBody @ApiOperation("Create new widget") public EntryCreatedRS createWidget(@PathVariable String projectName, @RequestBody @Validated(WidgetRQCustomValidator.class) WidgetRQ createWidgetRQ, Principal principal) { return createHandler.createWidget(createWidgetRQ, EntityUtils.normalizeProjectName(projectName), principal.getName()); }